Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are no commits “on a branch” in git. There are only commits <em>reachable</em> from a branch. And that information is not a very good indicator of what branch that commit originally belonged to. So I see two ways to interpret your question:</p> <ul> <li>I want to find the first commit after the merge-base of <code>branch</code> and <code>master</code> that is on the side of branch.</li> <li>I want to find the first commit that is reachable from <code>branch</code>, but not from <code>master</code>.</li> </ul> <p>I am gonna assume you meant the second one. The answer to that is returned by this command:</p> <pre><code> git rev-list ^master mybranch | tail -n 1 </code></pre> <p><strong>Note:</strong> This is all gonna fail horribly if you branch off topic branches.</p> <hr> <p>I am a little bit confused as to what you want to achieve. If you want a whole branch to be represented by one commit, but still get a merge, You should do this:</p> <pre><code>git checkout mybranch git reset --soft `git merge-base mybranch master` git commit -m 'All of Mybranch' git checkout master git merge --no-ff mybranch </code></pre> <p>Note that this will start the squash at the first merge-base. This might not be what you want if you merged <code>master</code> into <code>mybranch</code> before. You can modify this to start at the first commit on mybranch, but not on master (might have wierd and unexpected results in complex histories) by replacing the second command with this:</p> <pre><code> git reset --soft `git rev-list ^master mybranch | tail -n 1`^ </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload