Git cheat sheet 2

Russell Bateman
April 2024
last update:

# clone a repository
git clone 

# stage changes for commit
git add 

# commit changes
git commit -m "Commit message"

# push changes to the remote repository
git push

# force push changes (use with caution)
git push --force

# reset working directory to last commit
git reset --hard

# create a new branch
git branch 

# switch to a different branch
git checkout 

# merge changes from another branch
git merge 

# rebase changes onto another branch (use with caution)
git rebase 

# view status of working directory
git status

# view commit history
git log

# undo last commit (use with caution)
git reset --soft HEAD^

# discard changes in working directory
git restore 

# retrieve lost commit references
git reflog

# interactive rebase to rearrange commits
git rebase --interactive HEAD~3