5

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?

Community
  • 1
  • 1
michael
  • 106,540
  • 116
  • 246
  • 346

3 Answers3

7

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.

Matthijs P
  • 1,144
  • 1
  • 9
  • 17
3

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
kan
  • 28,279
  • 7
  • 71
  • 101
1

You can also do the following:

git merge 12345678 --ff-only

where 12345678 stands for the commit id of the specific commit, to which you want to merge (if you don't want to count how much commits you have to skip).

dunni
  • 43,386
  • 10
  • 104
  • 99