Git commands

list some commands often being used:

Delete branch

  • Deleting local branches
1
git branch -d feature/add-new-feature
  • Deleting remote branches in Git
1
 git push origin --delete feature/add-new-feature

Change branch name

  • change name of local branch
1
2
3
4
5
6
git checkout <branch>
git branch -m <new_branch_name>

##example
git checkout feature
git branch -m quickfix
  • change name of remote branch
    • you have to change branch name locally first
    • then do the following:
1
2
3
4
5
6
7
8
9
git push <remote> :<old_branch_name> <new_branch_name>

#you have to set the upstream branch for the newly created branch using the “git upstream” command.
git push <remote> -u <new_branch_name>

git push origin :feature quickfix
git push origin -u quickfix
## example