简体   繁体   English

如何在Git中提交和推送所选文件,但不是全部

[英]How to commit & push selected files but not all in Git

I have a git repo with two branches: develop and master . 我有两个分支的git repo: developmaster I work mostly at develop and when files are ready (sometimes not so sticky to this affirmation) I merge them to master branch to put them on production. 我主要从事develop工作,当文件准备就绪时(有时对这种肯定不那么粘)我将它们合并到master分支以将它们投入生产。 Take a look to this pic: 看看这张照片:

在此输入图像描述

All that files comes from develop branch and was merged but I only want to commit and push RepresentativeRestController.php but any time I do right click => commit all of them are included on the commit. 所有这些文件都来自develop分支并被合并但我只想提交并推送RepresentativeRestController.php但任何时候我点击右键=>提交所有这些文件都包含在提交中。 How I get rid, temporary since they will be added later, of the ones I don't want to be included on the commit? 我是如何摆脱暂时的,因为它们将在以后添加,我不想被包含在提交中的那些? I use Smartgit as a GUI client for Bitbucket repository. 我使用Smartgit作为Bitbucket存储库的GUI客户端。 Any advice? 有什么建议?

Use terminal to commit selected file : like: you have 100 files (10 type) 使用终端提交所选文件:如:你有100个文件(10种类型)

git add *.* all file git add *.*所有文件

git add *.jpg all jpg file git add *.jpg所有jpg文件

$ git add . # add to index only files created/modified and not those deleted #添加仅索引创建/修改的文件,而不是删除的文件

$ git add -u # add to index only files deleted/modified and not those created $ git add -u #仅添加已删除/修改的文件的索引,而不是创建的文件

you can use source tree for all git work. 您可以将源代码树用于所有git工作。

When you make a commit, all the staged file are included in the commit. 进行提交时,所有暂存文件都包含在提交中。 If you wish to exclude certain files from a commit, unstage those files first. 如果您希望从提交中排除某些文件,请首先取消暂存这些文件。

I'm not sure how to do that with the Git UI you are using, but there should be a screen or something to manage which files with changes are staged and which aren't. 我不确定如何使用你正在使用的Git UI做到这一点,但是应该有一个屏幕或者某些东西来管理哪些文件带有更改,哪些不是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM