git-branch: update

This commit is contained in:
Rico Sta. Cruz 2017-09-20 22:04:14 +08:00
parent 7d907dc836
commit 3e7a5554be
No known key found for this signature in database
GPG Key ID: CAAD38AE2962619A
1 changed files with 47 additions and 14 deletions

View File

@ -1,24 +1,57 @@
--- ---
title: Git branches title: Git branches
category: Git category: Git
layout: 2017/sheet
updated: 2017-09-20
--- ---
# create a new branch ## Working with branches
git checkout -b $branchname {: .-three-column}
git push origin $branchname --set-upstream
# get a remote branch ### Creating
git fetch origin
git checkout --track origin/$branchname
# delete local remote-tracking branches (lol) ```bash
git remote prune origin git checkout -b $branchname
git push origin $branchname --set-upstream
```
# list merged branches Creates a new branch locally then pushes it.
git branch -a --merged
# delete remote branch ### Getting from remote
git push origin :$branchname
# get current sha1 (?) ```bash
git show-ref HEAD -s git fetch origin
git checkout --track origin/$branchname
```
Gets a branch in a remote.
### Delete local remote-tracking branches
```bash
git remote prune origin
```
Deletes `origin/*` branches in your local copy. Doesn't affect the remote.
### List merged branches
```bash
git branch -a --merged
```
List outdated branches that have been merged into the current one.
### Delete remote branch
```bash
git push origin :$branchname
```
Works for tags, too!
### Get current sha1
```bash
git show-ref HEAD -s
```