When do I need to do “git pull”, before or after “git add, git commit”?

Question:

What is the right way?

Or

Or

UPD:

I forgot to mention that in this case I use git add to stage a tracked and modified file. Not to include a brand new file to repository. Does this changes an order of commands?

Answer:

I think that the best way to do this is:

Stash your local changes:

Update the branch to the latest code

Merge your local changes into the latest code:

Add, commit and push your changes

In my experience this is the path to least resistance with Git (on the command line anyway).

Leave a Reply