views:

46

answers:

3
  1. How can I differentiate between two local branches in git ?
  2. How can I copy one local branch to another local branch ?

In general how can I perform difference operation between two local branches on my server using git. I tried looking it up online but there is not enough documentation on that or there is not clear documentation on that.

Any suggestions or links to useful material would be highly appreciated.

Thanks.

+2  A: 

git diff and git merge

Say you have two branches: master and dev

o-o-o-o-o-o-o-o-o   master
           \
            o-o-o   dev

and you're on dev

git diff master

will show you the difference between the content of dev and the content of master

git merge master

will merge the changes from master into dev, and your history will look like this:

o-o-o-o-o-o-o-o-o   master
           \     \
            o-o-o-o   dev
hasen j
A: 

1) From your "source branch" use git diff

2) If you use git checkout all your modifications which were not committed will go to your destiny branch. If you already commit, you can use git rebase <branch> to get your modifications

Diego Dias
+2  A: 

1) Easy, say you want to diff your local master and a topic branch

Comparing branches
$ git diff topic master    (1)
$ git diff topic..master   (2)
$ git diff topic...master  (3)
1.Changes between the tips of the topic and the master branches.
2.Same as above.
3.Changes that occurred on the master branch since when the topic
branch was started off it.

2) It's just normal merging:

git checkout master
git merge topic

And resolve any conflicts via git mergetool -t xxx

Johannes Rudolph