Skip to content

Instantly share code, notes, and snippets.

@cactaceae21
Created June 24, 2022 13:45
Show Gist options
  • Save cactaceae21/ba2f543e9ba488c9cd0d38b9441df5a4 to your computer and use it in GitHub Desktop.
Save cactaceae21/ba2f543e9ba488c9cd0d38b9441df5a4 to your computer and use it in GitHub Desktop.
Git Notes

git config --global user.name= git config --global user.email= git config --global core.editor=vim

git init Initialize directory for git repo git add Add files to staging git add . Adds all files to staging git commit -m "message" Commit staged changes git commit --amend Amend last commit

git mv Move/rename a file git rm Removes file from disk future commits git rm --cached -r Removes from commit staging git checkout -- Reverts to last commit (preferred) git reset --hard Resets to last or specific commit

git show Shows diff for commit

git remote add Add a remote repo git remote add origin git remote remove Removes remote repo git remote rename Renames remote repo

git push Pushes repo to remote git push --all Pushes all local branches to server

git branch Shows which branches are available git branch Create new branch (does not change to it) git checkout Switches to branch git checkout -b Create local branch and track remote branch git branch -r Shows any remote branches that you don't have locally git branch -d Offers to merge etc git branch -D Forceful delete

git merge Merges on to current branch

git fetch Fetch remote branch git fetch git pull Fetch remote branch and merge with current local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment