0

I had master branch which had all my code commits.Few days back I've cut a new branch from master called dev.I made some commits in both the branches..Now I want to get all commits in master branch after dev is cut from it.. Is there any command for this .Can someone help me quickly

Thanks!

user7350714
  • 365
  • 1
  • 6
  • 20
  • If you have not merged dev to master yet, try `git log dev...master`. If you have, run `git reflog dev` to find out on which commit you created dev. It's expected to be in the bottom entry. Let's say the commit is xxx. Try `git log xxx..master`. – ElpieKay Jan 17 '17 at 19:27
  • @user7350714 , you need to be very clear about what you're asking. By "Get" you mean print out the relevant commits? or you need to bring these commits into dev? Also what exactly does "cut a new branch" really mean? – jbu Jan 18 '17 at 02:12
  • @jbu I just want to get the commit details in log file – user7350714 Jan 18 '17 at 05:03

2 Answers2

0

By "get all commits" do you want to simply view the commits, or incorporate them into your dev branch?

If you want to add them into your branch, you'll probably want to git pull or git fetch depending on your endgame. This thread covers the difference pretty well: What is the difference between 'git pull' and 'git fetch'?

Community
  • 1
  • 1
CJ Johnson
  • 1,081
  • 9
  • 13
-1

It's surprisingly simple:

git log dev..master

Just to elaborate and put an end to the confusion having resulted in 16 comments:

There is a huge difference between using two dots .. or three dots ... between the branch ids:

  • With two .. you get all new commits only on master since they have diverged.
  • With three ... you get all commits on both dev and master since they have diverged.
SzG
  • 12,333
  • 4
  • 28
  • 41
  • To understand what's going on there, see the [Git Book section on revision selection](https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection). `..` and `...` have a special meaning. – Schwern Jan 17 '17 at 19:32
  • @SzG.It is giving me the commits in dev branch.But I need all the commits in master branch after dev is cut from it..It means all those commits will not be in dev.How can I get that..How can we get the details like count of commits ahead behind? – user7350714 Jan 17 '17 at 19:41
  • I can't reproduce what you're describing. Git walks the commit graph from `dev` to `master` and prints the commit whenever it's going forwards in the graph, and skips it when it's going backwards. – SzG Jan 17 '17 at 19:46
  • @ScG Iam getting all commits in both dev and master using above..But I need only in master and its count after dev is cut – user7350714 Jan 17 '17 at 19:50
  • @SzG More simplified I have R1.1 branch..Recently I have cut R1.2 from it.Now I want the list of commits in R1.1 after R1.2 is cut from it – user7350714 Jan 17 '17 at 19:52
  • I tried it too and I only get the commits on `master`. – SzG Jan 17 '17 at 19:53
  • Can you post the output of `git log --decorate --graph --oneline --all` ? – SzG Jan 17 '17 at 19:55
  • @SzG If you dont mine can u join over here..I can show u. https://zoom.us/j/623527106 – user7350714 Jan 17 '17 at 19:57
  • I added the Zoom extension to Chrome, but it doesn't work. – SzG Jan 17 '17 at 20:09
  • https://zoom.us/join once try here and paste paste this number..give one last try – user7350714 Jan 17 '17 at 20:15
  • @SzG number 623527106 – user7350714 Jan 17 '17 at 20:16
  • @user7350714 "It is giving me the commits in dev branch" <-- his double dot command should not be giving you the commits in the dev branch. Reading the revision selection it specifically says it will exclude commits reachable by rev1 (dev in your case). Please, show us the exact commands you are using and the output. – jbu Jan 18 '17 at 02:24
  • @jbu >git log origin/release1.2...origin/release1.1 >log1.log I want only release1.1 logs but combinenly Im getting from both branches – user7350714 Jan 18 '17 at 05:00
  • that's because you're using triple dot notation, so yes, you would get commits from both branches minus the common ones – jbu Jan 18 '17 at 05:05