Milan Tarami
Posted on September 26, 2020
Creating a new branch
$ git checkout -b YOUR_NEW_BRANCH_NAME
View all local branch
$ git branch
View all local and remote branch
$ git branch -a
Pushing a local branch to a remote server
$ git push origin YOUR_BRANCH_NAME
Set upstream branch
upsteam allows to use "git push" command
$ git push -u origin BRANCH_NAME
Switching between branch
$ git checkout BRANCH_NAME
Merging branch
make sure you have committed all changes before merging
// first switch to destination branch, where branch needs to be merged
$ git checkout DESTINATION_BRANCH_NAME
// and run below command to merge
$ git merge BRANCH_NAME_TO_BE_MERGED
Deleting a local branch without merging
// switch to any other branch
$ git branch -D BRANCH_NAME
Deleting a local branch after merging
make sure you need to be in the destination branch to delete merged branch
$ git branch -d BRANCH_NAME
Deleting a branch from a remote server
$ git push origin -d BRANCH_NAME
Pulling remote branch
$ git pull origin BRANCH_NAME
Getting changes from master branch to other branch
// switch to branch
$ git checkout DESTINATION_BRANCH_NAME
$ git rebase master
NOTE: I will be updating this post if I became more familiar with other git commands while working on git branch
comment down if I made mistake
Posted on September 26, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
November 30, 2024