Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I advance my local branch by 1 commit?

Tags:

git

In my git repository local branch, it is behind by 9 commits. Can you please tell me how can I advance it by 1 commit?

# Your branch is behind 'my-git/remote' by 9 commits, and can be fast-forwarded.

I have read How can I fast-forward a single git commit, programmatically? I don't understand the answer.

I don't need to do it programmically. Is there a command line way I can use?

like image 754
michael Avatar asked Aug 25 '12 11:08

michael


2 Answers

In this specific instance you could do

git merge my-git/remote~8 --ff-only

Explanation: you are saying you want all commits from the branch 'my-git/remote' merged into your current branch, except for the 8 latest commits. The except part is covered in the "~8". "--ff-only" is there for safety, but not strictly neccessary.

like image 63
Matthijs P Avatar answered Oct 01 '22 12:10

Matthijs P


Advance (or fast-forward) is the same as merge in case if history is not diverged. So, you could merge to a commit you need, e.g.

git merge my-git/remote~8
like image 44
kan Avatar answered Oct 01 '22 10:10

kan