Skip to content

Instantly share code, notes, and snippets.

@Ingelheim
Last active July 12, 2016 11:54
Show Gist options
  • Save Ingelheim/ca30244680569cc125d03d62ef259b24 to your computer and use it in GitHub Desktop.
Save Ingelheim/ca30244680569cc125d03d62ef259b24 to your computer and use it in GitHub Desktop.
  1. What command would you run, along with any arguments, to set your name so it shows up in git commits?
git config --global user.name [your full name]

​ 2. What command would you run, along with any arguments, to show the differences in files that are staged from files that are already committed to the repository?

git diff staged

​ 3. What command, along with any arguments, is the shortcut to create a branch and checkout that branch at the same time?

git checkout -b [branch-name]

​ 4. What command would you run, along with any arguments, to get code from the remote repository in order to retrieve and merge it in one step?

git pull

​ 5. What command would you run, along with any arguments, to show all the information available about the remote repository?

git remote show origin

​ 6. While currently in your local master branch, what command would you run, along with any arguments, to place the changes you've made to your local master branch on top of the changes in the remote master branch?

git rebase origin/master

​ 7. What command would you run, along with any arguments, to show the differences between 2 branches?

git diff [branch1] [branch2]

​ 8. What do you think happens if you run git init in your user directory?

DESTRUCTION!

​ 9. What's the difference between staged code and committed code?

Staged changes are not yet part of the version control history.

​ 10. How do you add all files with the same extension to the staging area?

git add *.rb

​ 11. What command do you need to use to undo the last commit and all changes it made?

git reset --hard HEAD^

​ 12. How would you clone a repo down and give the folder a name instead of using the repo's name?

git clone URL folder-name

​ 13. If you receive an error stating that your branch is behind origin, what would you need to do to sucessfully push your changes? (assuming no conflicts)

git pull
git push

​ 14. What command do you use to get the branches in a remote branch?

git branch -r

​ 15. If you get a conflict in the middle of a rebase and decide you want to cancel the rebase, what command would you run?

git rebase --abort

​ 16. To improve log readability, what command would you enter to get your log to show commit info on one line?

git log --pretty=oneline

​ 17. You are about to start a new feature, what should you do in the git context?

Make sure you're synced with master and make a new branch.

​ 18. What should you think about when you are resolving merge conflicts?

You should probably talk to whoever wrote the other code and make sure that you don't break their code.

​ 19. When might you use a tag?

To mark a place in your commit history that you need a shortcut to retrieve.

​ 20. How do you alias a git command

git config alias.new_alias command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment