git-usage/README.md

1.0 KiB

General Usage

# check status, see files changed etc
git status

# add a file to next commit
git add <file>

# commit with given message
git commit -m 'tweaked turn velocity for green grunts'

# push your stuff
git push

# undo all local changes in your working directory (reset state to last commit basically)
git reset --hard HEAD

# reset to last commit (only git wise, changed files will remain changed and will be reflected with git status/git diff)
git reset --soft HEAD^

# safe revert, if you want to undo your last made commit, this will produce a new commit for this exact thing
git undo HEAD

# show changes since last commit
git diff HEAD

Branching

# create a new branch and switch to it
git checkout -b your-branch-name

# switch to a branch by name
git checkout your-branch-name

# merge changes from another branch into your current branch
git merge other-branch-name

# push your current branch to "your-branch-name" on remote
git push -u origin your-branch-name