0 votes
1 view
in Devops and Agile by (20k points)

To move the branch pointer of a checked-out branch, one can use the git reset --hard command. But how to move the branch pointer of a not-checked out branch to point at a different commit (keeping all other stuff like a tracked remote branch)?

1 Answer

0 votes
by (28.4k points)

In case if you just want to move a branch to another commit:

$ git branch -f branch-name new-tip-commit

In order to move a branch pointer:

$ git update-ref -m "reset: Reset <branch> to <new commit>" refs/heads/<branch> <commit>

The general form:

$ git update-ref -m "reset: Reset <branch> to <new commit>" <ref> <commit>

For more git commands, you can visit the git tutorial.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...