1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2026-08-16 05:54:53 +02:00
Files
cheatsheets/git-branch.md
2017-09-20 22:04:14 +08:00

825 B

title, category, layout, updated
title category layout updated
Git branches Git 2017/sheet 2017-09-20

Working with branches

{: .-three-column}

Creating

git checkout -b $branchname
git push origin $branchname --set-upstream

Creates a new branch locally then pushes it.

Getting from remote

git fetch origin
git checkout --track origin/$branchname

Gets a branch in a remote.

Delete local remote-tracking branches

git remote prune origin

Deletes origin/* branches in your local copy. Doesn't affect the remote.

List merged branches

git branch -a --merged

List outdated branches that have been merged into the current one.

Delete remote branch

git push origin :$branchname

Works for tags, too!

Get current sha1

git show-ref HEAD -s