Git Branch Command
From InfoTechPedia
Revision as of 10:34, 1 March 2018 by TomHutchison (talk | contribs) (TomHutchison moved page Git Branch Commands to Git Branch Command without leaving a redirect: not commands but command)
List all the branches in your repo, and indicate what branch you're currently checked out ( denoted with a * ):
git branch
$ git branch develop fix-js * master v1.x.x
Create a new branch and switch to it:
git checkout -b <branchname>
$ git checkout -b develop Switched to a new branch 'develop'
Switch from one branch to another:
git checkout <branchname>
$ git checkout develop Switched to branch 'develop' Your branch is up-to-date with 'origin/develop'.
Delete the feature branch:
git branch -d <branchname>
$ git branch -d develop Deleted branch develop (was f1aa257).
Push the branch to your remote repository, so others can use it:
git push origin <branchname>
$ git push origin master Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 318 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To https://github.com/icarus/Hello-world f1aa257..26600b8 master -> master
Push all branches to your remote repository:
git push --all origin
$ git push --all origin Everything up-to-date
Delete a branch on your remote repository:
git push origin :<branchname>
$ git push origin :develop To https://github.com/icarus/Hello-world - [deleted] develop