git-branch: update
This commit is contained in:
parent
7d907dc836
commit
3e7a5554be
|
@ -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
|
||||||
|
{: .-three-column}
|
||||||
|
|
||||||
|
### Creating
|
||||||
|
|
||||||
|
```bash
|
||||||
git checkout -b $branchname
|
git checkout -b $branchname
|
||||||
git push origin $branchname --set-upstream
|
git push origin $branchname --set-upstream
|
||||||
|
```
|
||||||
|
|
||||||
# get a remote branch
|
Creates a new branch locally then pushes it.
|
||||||
|
|
||||||
|
### Getting from remote
|
||||||
|
|
||||||
|
```bash
|
||||||
git fetch origin
|
git fetch origin
|
||||||
git checkout --track origin/$branchname
|
git checkout --track origin/$branchname
|
||||||
|
```
|
||||||
|
|
||||||
# delete local remote-tracking branches (lol)
|
Gets a branch in a remote.
|
||||||
|
|
||||||
|
### Delete local remote-tracking branches
|
||||||
|
|
||||||
|
```bash
|
||||||
git remote prune origin
|
git remote prune origin
|
||||||
|
```
|
||||||
|
|
||||||
# list merged branches
|
Deletes `origin/*` branches in your local copy. Doesn't affect the remote.
|
||||||
|
|
||||||
|
### List merged branches
|
||||||
|
|
||||||
|
```bash
|
||||||
git branch -a --merged
|
git branch -a --merged
|
||||||
|
```
|
||||||
|
|
||||||
# delete remote branch
|
List outdated branches that have been merged into the current one.
|
||||||
|
|
||||||
|
### Delete remote branch
|
||||||
|
|
||||||
|
```bash
|
||||||
git push origin :$branchname
|
git push origin :$branchname
|
||||||
|
```
|
||||||
|
|
||||||
# get current sha1 (?)
|
Works for tags, too!
|
||||||
|
|
||||||
|
### Get current sha1
|
||||||
|
|
||||||
|
```bash
|
||||||
git show-ref HEAD -s
|
git show-ref HEAD -s
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue