I worked on the master branch of a repository and I didn't commit the files for a while. By this time, most of the files have been modified. How can I compare and merge the files in git?
Asked
Active
Viewed 113 times
1 Answers
1
You need to commit your files first, in order to diff them to origin/master
.
If you don't want to commit them on master
(because you might want to update master
by rebasing it on top of origin/master
), you can create a tmp
branch a commit there first.
git checkout tmp
git add -A
git commit -m "intermediate commit"
Then you need to git fetch origin/master
, supposing origin points to your GitHub repo
Finally, you can:
- Check all commits done on remote branch since when local branch was created:
git diff HEAD...origin/master
- ee the differences of what you have on your local branch but that does not exist on remote branch run:
git diff origin/master...HEAD
See Mark Longair's excellent answer on git diff
for more.