Skip to content

Instantly share code, notes, and snippets.

@creativeworkx
Last active July 13, 2021 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creativeworkx/bacb73f1172cd2959fde11049c8c46a7 to your computer and use it in GitHub Desktop.
Save creativeworkx/bacb73f1172cd2959fde11049c8c46a7 to your computer and use it in GitHub Desktop.
git commands
#
# git commands
#
Update on Windows
------------------
git update-git-for-windows
Push branch to remote repository
--------------------------------
git push origin branchname
Push all branches to remote repository
--------------------------------------
git push origin --all
Push tag to remote repository
------------------------------
git push origin tagname
List branches
-------------
git branch -a
Delete branch local
--------------------
git branch -d branchname
Delete branch remote
---------------------
git push origin :branchname
Rename branch local
--------------------
git branch -m oldbranchname newbranchname
Delete tag local
------------------
git tag -d tagname
Delete tag remote
------------------
git push --delete origin tagname
Switch to branch
------------------
git checkout branchname
Merge branch into current branch
--------------------------
git merge branchname
Diff two branches
------------------
git diff branchnameone branchnametwo
Remove folder from git, but leave filesystem folder untouched
-------------------------------------------------------------
git rm -r --cached foldername
delete all branches on origin that are already merged
-----------------------------------------------------
$ git branch -r --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment