2015-10-22 10:31:52 +03:00
|
|
|
# git branch
|
2014-03-09 16:20:13 +04:00
|
|
|
|
2016-08-24 18:58:53 +03:00
|
|
|
> Main git command for working with branches.
|
2014-03-09 16:20:13 +04:00
|
|
|
|
2016-01-07 20:31:27 +03:00
|
|
|
- List local branches. The current branch is highlighted by `*`:
|
2014-03-09 16:20:13 +04:00
|
|
|
|
|
|
|
`git branch`
|
|
|
|
|
2016-08-24 18:58:53 +03:00
|
|
|
- List all branches (local and remote):
|
2015-12-28 21:00:06 +03:00
|
|
|
|
|
|
|
`git branch -a`
|
|
|
|
|
2016-08-24 18:58:53 +03:00
|
|
|
- Create new branch based on the current commit:
|
2014-03-09 16:20:13 +04:00
|
|
|
|
2016-08-24 18:58:53 +03:00
|
|
|
`git branch {{branch_name}}`
|
2014-03-09 16:20:13 +04:00
|
|
|
|
2016-08-24 18:58:53 +03:00
|
|
|
- Rename a branch (must not have it checked out to do this):
|
2014-03-09 16:20:13 +04:00
|
|
|
|
2016-08-24 18:58:53 +03:00
|
|
|
`git branch -m {{old_branch_name}} {{new_branch_name}}`
|
2014-03-09 16:20:13 +04:00
|
|
|
|
2016-08-24 18:58:53 +03:00
|
|
|
- Delete a local branch:
|
2014-03-09 16:20:13 +04:00
|
|
|
|
2016-08-24 18:58:53 +03:00
|
|
|
`git branch -d {{branch_name}}`
|