Skip to content

Instantly share code, notes, and snippets.

@Igor-Lopes
Last active May 1, 2017 04:33
Show Gist options
  • Save Igor-Lopes/3f77bfd07f4ccb1af4075681921cd5fa to your computer and use it in GitHub Desktop.
Save Igor-Lopes/3f77bfd07f4ccb1af4075681921cd5fa to your computer and use it in GitHub Desktop.
Git cheat sheet

Initializing Repositories

  1. Initialize repository git init

  2. Add content git add *

  3. Commit git commit -m "commit message"

  4. Add Remote git remote add origin [https://github.com/User/YourRepo.git]

  5. Push to master git push --set-upstream origin master

Branching

Create branch

git checkout -b [name_of_your_new_branch]

Push branch

git push origin [name_of_your_branch]

Pull branch

git pull origin [name_of_your_branch]

Delete remote branch

git push origin --delete [name_of_your_branch]

##Rollback Commits

Rollback local repository to last commit

git reset --hard HEAD

Rollback local and remote repository to specific commit

  1. git reset --hard [commit_hash]

  2. git push -f origin [name_of_your_breanch]

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