Tuesday, May 31, 2016

Cheeky Git Commands

Just storing the list of git commands I seem to always come back to trying to find. Will reference the original source when possible.

Update the remote branch list on your local (Detlus Knowldge)
$ git remote update origin --prune

Replace the local version with the remote version
$ # fetch the latest changes
$ git fetch origin
$
$ # reset the branch to fetched changes (assuming you're working on master)
$ git reset --hard origin/master

Rename a local branch (pre-push to origin)
$ # checkout the branch to rename
$ git checkout branch-name
$ 
$ # rename the branch
$ git branch -m new-branch-name

Push and track a local branch to origin
$ # switch the branch to push and track
$ git checkout branch-name
$ 
$ # push the branch to origin
$ git push -u origin branch-name

No comments:

Post a Comment