Skip to content

Instantly share code, notes, and snippets.

@droidlabel
Last active January 5, 2016 19:29
Show Gist options
  • Select an option

  • Save droidlabel/e9f04912bc2fde6e473c to your computer and use it in GitHub Desktop.

Select an option

Save droidlabel/e9f04912bc2fde6e473c to your computer and use it in GitHub Desktop.
Cheat-sheet for git usually for working in Android Studio

Markdown Formatting Language

Online Markdown Formatter

Tip: We can write git commands in "Terminal" of Android Studio

1. Revert Multiple Commits

git revert --no-commit HEAD~2.. 
// then to commit with message
git commit -m 'the commit message'  // or use commit from GUI

from Stackoverflow Comment

2. Get total number of commits

git rev-list HEAD --count  

3. Ammend previous Commit

//add desired file using GUI or add command then
git commit --amend --no-edit    //to commit with previous commit message
git commit --amend -m "Message" //to commit with new commit message

4. Closing Git Message or text Editor

http://stackoverflow.com/a/9171451

5. Get rid of untracked files (e.g. after Hard reset)

git clean -f -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment