Skip to content

Instantly share code, notes, and snippets.

@vdw
Last active December 14, 2015 20:49
Show Gist options
  • Save vdw/5146681 to your computer and use it in GitHub Desktop.
Save vdw/5146681 to your computer and use it in GitHub Desktop.
Basic Git commands

Basic Git commands

git init Initiate git in an existing project.

git clone git@repository_ssh Clone a project (you do not have to create a folder).

git add . Add any new files under version control.

git commit -am 'This is a message.' Commit the changes.

git push -u origin master Push changes for the first time to repository.

git push Push changes.

git status Check the status of the project. See if there are any unstaged files, new files etc.

git reset --hard HEAD Reset local files to HEAD.

Remove last commit but keep changes:

git reset HEAD^

Restore "lost" changes after git rebase --skip

git log -g
git checkout -b recovery <SHA>

or

git log -g
git reset --hard <SHA>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment