Git commands

Important Git commands

  • git config

  • git init

  • git clone

  • git add

  • git commit

  • git diff

  • git reset

  • git status

  • git rm

  • git log

  • git show

  • git tag

  • git branch

  • git checkout

  • git merge

  • git remote

  • git push

  • git pull

  • git stash

 

How to delete git branch locally and remotely?

$ git push -d <remote_name> <branch_name>  #deletes remote branch
$ git branch -d <branch_name>              #deletes local branch

Note that in most cases the remote name is origin.

Delete Local Branch

To delete the local branch use one of the following:

$ git branch -d branch_name
$ git branch -D branch_name

Note: The -d option is an alias for --delete, which only deletes the branch if it has already been fully merged in its upstream branch. You could also use -D, which is an alias for --delete --force, which deletes the branch "irrespective of its merged status." [Source: man git-branch]

 

Rating: