54 lines
1.3 KiB
Markdown
54 lines
1.3 KiB
Markdown
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
|
|
|
|
Pushing/Pulling Changes
|
|
-------------------------
|
|
|
|
# fetch changes from remote for current branch AND merge them in
|
|
git pull
|
|
|
|
# only fetch changes, do not merge (probably wont be used, but useful to know that git pull = git fetch + git merge in one)
|
|
git fetch
|
|
|
|
# push your changes to remote
|
|
git push
|
|
|
|
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
|