Reputation: 714
Some observations and questions while working on a FeatureA
branch.
Following are the initial steps I took:
git checkout -b FeatureA
// modify X.c, Y.c, Z.c files
git add <modified files>
git commit -m <msg>
git push -u origin FeatureA // creates a PR for a merge into master
Turns out I see some merge conflicts. Also realizes I didn't update the local repo prior to pushing (files I modified was recently modified and pushed by another developer thus I ended up working on an older version)
Then I went on to get the latest changes prior to resolving conflicts
git pull origin master
Modified the files with conflicts. Done. Runs git status
to find out there are a whole lot of other files staged (which I didn't modify and possibly was a result of running git pull origin master
).
$ git status
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Changes to be committed:
File1.c // file I didn't modify
File2.c // file I didn't modify
..
...
....
X.c // file I modified
Y.c // file I modified
Z.c // file I modified
So my merge conflict commit would contain all those files that aren't relevant to the merge conflict itself.
Questions:
Upvotes: 0
Views: 1054
Reputation: 535766
Is it okay to commit with all these irrelevant files in addition to the files I modified for conflict?
Yes. In fact, it is necessary. That is what a merge is. You said git pull origin master
. A pull is a merge. A merge brings in the changes from the other branch. That is normal, and it is right — it's what you want to do.
Is there a way to get those staged files unstaged or perhaps something that allows me to add and commit only the files I modified?
No, and you shouldn't. And you should stop wanting to. All is well. Don't worry; when you make your pull request, the only changes that will appear as part of the pull request will be yours.
Upvotes: 2