Skip to content

Latest commit

 

History

History
53 lines (40 loc) · 1.8 KB

Git.md

File metadata and controls

53 lines (40 loc) · 1.8 KB

Git Cheatsheet

Git style guide
Clone a Private Repo

Common commands

git workflow: clone repo, make changes, stage changes (using add), commit changes then push
clone repo using an access token:

git clone https://@github.com//.git

status (you want all green):

git status
look at logs:

git log --oneline
current remote connections (PATs being used):

git remote -v
add everything but untracked files to be staged:

git add -u
commit changes to a repo with an update message:

git commit -m "moved all images to a different folder"

push to main branch:

git push origin main

Add a file, commit and push to main:

git add /path/to/file
git commit -m "added script to do something"
git push origin main

Fixing Mistakes

Reset commit if not pushed (discard your changes):

git reset HEAD~1
git status #check status for a clean copy
If pushed to remote:

git revert HEAD #reset commit

Branches

git checkout -b branch_name #create a new branch and switch to it
git checkout branch_name #switch to a branch, then commit some changes
git checkout main #switch to the main branch
git merge branch_name #merge the branch into main
git branch -d branch_name #delete branch post merge
Merge conflicts:
git status #check for unmerged changes, manually resolves the conflicts.
Get out of detached head mode:
git checkout master
git checkout -