Reputation: 470
I did a git pull
and I got new files after that.
I saw those new files in "Changes to be committed:" list when I did a git status
. So I did git reset HEAD <new_file_from_pull>
for all new files that I got. I ensured with git status
that I have only my old
files are in "Changes to be committed:" list.
git push origin <my_branch>
and now both the new files which were not under that "Changes to be committed:" list and my old files which were under "Changes to be committed:" list got pushed. Why is that and how can I recover from it? I at least want to know if this is the correct way of doing it.Upvotes: 0
Views: 177
Reputation: 470
As suggested in comments, lesson learnt is to make sure for any command you execute there is a message and you read it. I observed that
git commit -m <your message>
will not give complete details on all the files that were/are going to be committed.
So, first do
git commit
then you will see the actual files that are going to be committed. Read and make sure you have exactly the files that you want to commit, no less, no more.
Then you can add comments and do wq
as in vi editor. If you don't want to commit then simply do :q
as in vi editor to cancel you commit process.
Upvotes: 1