-
Notifications
You must be signed in to change notification settings - Fork 3
Fast Forwarding a Local Branch
This page is part of the Plain English programming language's Git Cheat Sheet.
This page shows how to move a branch name forwards, to an later snapshot in the repository. It assumes that no alternate branches need to be merged in. You can also Push to GitHub, or Move a Branch Backwards.
Steps 1 - 6 make sure you can get back to where you started.
-
Use
git commit
to commit your work. -
Use
git status
to verify that your work area is clean. If not, repeat step 1. -
Use
git branch -v
and/orgitk
to confirm that your current work is on a named branch (possibly a topic branch.) -
If step 3 is not OK, use
gitk
to name a branch at your current work, and repeat step 3. -
Use
gitk
to find the branch name you want to move. For example,move_me
. -
Optionally, use
gitk
to create another branch name at the current location of the branch name you want to move. For example,before_move
. -
Use
gitk
to create a temporary branch name at the location you want to move to. For example,temp
. -
Use
git checkout <old_name>
to checkout the branch you want to move. For example,git checkout move_me
. -
Use
git merge <old_name> <new_name>
to fast-forward the branch. For example,git merge move_me temp
. -
Use
gitk
orgit branch -v
to confirm that the branch has been moved. -
Use
git checkout <branch>
to update your work area, to match whichever branch you want to continue working on. -
Repeat step 10.
To promote a topic
branch to be the local master
. This procedure assumes master
, proposed
, development
, and topic
have not diverged. It assumes that the starting branch is topic
. It also assumes that you do not expect to need to revert any of the branches to a previous snapshot.
git commit
git status
(and verify that the working directory is clean
.)
git branch -v
(and verify that topic
is the current branch.)
git checkout development
git merge topic
git checkout proposed
git merge development
git checkout master
git merge development
git branch -v
git checkout topic