Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Last active September 25, 2023 03:13
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 techthoughts2/ef5c48adcc57d7982bdd10d195168245 to your computer and use it in GitHub Desktop.
Save techthoughts2/ef5c48adcc57d7982bdd10d195168245 to your computer and use it in GitHub Desktop.
A set of useful git commands I often use
git config --global -e
git config --list --show-origin
git config --global user.name
git config --global user.email
git config --global core.editor "code --wait"
Windows creds
git config --global credential.helper wincred
git clone
git add .
git add --all
git commit -m "Initial commit"
git push origin master
git pull origin master
git branch
git branch NewWork
git checkout NewWork
git checkout -b pasta [new creation at same time]
git merge NewWork
git diff branchname..branchname
Git branch -d branchname
Git push origin --delete branchname
git init [new repo in dir you are currently in]
git --add file.txt [adds a file that you specify for commit]
git status
git show [info on last commit + diff]
git log [entire log]
git log -1 [specify how many commits back]
git log -1 --pretty=%B [JUST the commit info]
git reset HEAD newfile.txt [unstage a file]
git reset --hard HEAD [lost everything in the current change set]
git rm [careful, will remove (delete) file on next commit]
git rm --cached [remove file from commit but doesn't delete]
git tag -a MyTageName -m "This is my first tag"
Reset commits
git add --all
git fetch --all
git reset --hard origin/branchname
git stash
git remote -v [show remote location]
git fetch vs git pull
git config --global push.default simple
git config --global -l
git mergetool
git making a file executable in git commit
git update-index --add --chmod=+x build.sh
git commit -m 'Make build.sh executable'
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment