git-usage/README.md

54 lines
1.3 KiB
Markdown
Raw Normal View History

2017-08-03 23:43:50 +01:00
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
2017-08-03 23:43:50 +01:00
Branching
-----------
# create a new branch and switch to it
git checkout -b your-branch-name
2017-08-03 23:47:12 +01:00
# switch to a branch by name
git checkout your-branch-name
2017-08-03 23:43:50 +01:00
# 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