Skip to content

Instantly share code, notes, and snippets.

@sakshamsaxena
Last active July 5, 2016 08:05
Show Gist options
  • Save sakshamsaxena/5c83df15bc2b17f3c72399860b31924b to your computer and use it in GitHub Desktop.
Save sakshamsaxena/5c83df15bc2b17f3c72399860b31924b to your computer and use it in GitHub Desktop.
A list of common git situations and solutions
  • You have no files staged yet, but you're sure that all of these you will commit right now. Quick way?

    • git commit -am "Thou art badass."
  • You have some files staged, and some not. What will happen if I commit "all" of them?

    • git commit -am "Thou art badass." would only commit the staged files.
  • How do I selectively add multiple files to stage using a single command?

    • git add file1 file2 file3 file4 should do it.
  • How do I add all the files to stage except only one, which I'm not yet sure about?

    • git add * followed by git reset HEAD file_i_dont_wanna_add. This would unstage file_i_dont_wanna_add.
  • How do I shift to a new branch when I've already started editing on the current one?

    • git checkout -b new_branch will maintain your unstaged changes and shift to the new_branch. Smooth.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment