Genecats Git Quiz 1) Where can you go for git-related help and tips for UCSC Genome Browser development? 2) What development model are we using with git currently? 3) How have we secured access to the git shared repository? 4) What command is used to create a git repo for your personal development? 5) What command is used to fetch the latest updates by others? 6) What command is used to publish your changes to the group? 7) If you mess up really badly and push an entire messed up tree to the shared central git repository, what should you do? Hopefully this will never happen, but you need to understand the danger and how to handle this emergency. 8) CVS only tracks changes to single files. What does Git do? 9) Explain the relationship between the working directory, the index, the repository, and the shared-repository. 10) What is 3a525393f6a5c47fa08d91ef16c16927ed3cd33a? What are the benefits of this? 11) How can a Git merge fail? What do you do? 12) Where does Git keep track of what version you have checked out? 13) How does Git know when you copy in a new version over an old one? 14) How do you rename a file in Git? How do you remove a file? 15) What command is used to view the history of commits to a file or directory? 16) What command is used to see line-by-line who changed a file? 17) What command is used to show differences between commits or branches? 18) If you refactor, i.e. move a block of lines from one file to another, why must both the removal from one file and the addition to another file be committed in a single commit together? Does this apply for entire files renamed? 19) What git command is used to undo changes made to your local repo? What are the variations and how do they work? 20) Why is it very important not to modify the shared history in the git shared repository? 21) How can you temporarily save changes before pulling/merging or switching branches? 22) What happens to changes to a tracked file that are not committed, when you checkout another branch? 23) How can you examine a different version of a file that you haven't checked out? 24) How can you safely create a project with multiple git repo dependencies? ======================================================================= Genecats Git Quiz With Answers: 1) Where can you go for git-related help and tips for UCSC Genome Browser development? (genomewiki, search "git") 2) What development model are we using with git currently? (centralized repository) 3) How have we secured access to the git shared repository? (ssh login, group kentcommit) 4) What command is used to create a git repo for your personal development? (git clone) 5) What command is used to fetch the latest updates by others? (git pull or git fetch) 6) What command is used to publish your changes to the group? (git push) 7) If you mess up really badly and push an entire messed up tree to the shared central git repository, what should you do? Hopefully this will never happen, but you need to understand the danger and how to handle this emergency. (let the group browser-staff know right away so we can freeze further changes and get it fixed, typically build-meister creates an alternate history without the error.) 8) CVS only tracks changes to single files. What does Git do? (git tracks entire source trees with a global view) 9) Explain the relationship between the working directory, the index, the repository, and the shared-repository. (edit, git add, git commit, git push) 10) What is 3a525393f6a5c47fa08d91ef16c16927ed3cd33a? What are the benefits of this? (SHA1 hash of a git object, e.g. a commit. This is an example of direct-access content storage, and it also protects from and detects corruption) 11) How can a Git merge fail? What do you do? (edit conflicts, git add, git commit) 12) Where does Git keep track of what version you have checked out? (HEAD points to a branch which contains a SHA1 hash) 13) How does Git know when you copy in a new version over an old one? (Trick question - it doesn't!, thus be careful not to lose other peoples' changes) 14) How do you rename a file in Git? (git mv, possibly other related changes, git commit) How do you remove a file in Git? (git rm, possibly other related changes, git commit) 15) What command is used to view the history of commits to a file or directory? (git log) 16) What command is used to see line-by-line who changed a file? (git blame) 17) What command is used to show differences between commits or branches? (git diff) 18) If you refactor, i.e. move a block of lines from one file to another, why must both the removal from one file and the addition to another file be committed in a single commit together? Does this apply for entire files renamed? (the history, i.e. git blame, is preserved only when all parts of the change are commited together, i.e. in a single commit.) 19) What git command is used to undo changes made to your local repo? What are the variations and how do they work? (git reset, explain soft, mixed, hard; HEAD vs HEAD^) 20) Why is it very important not to modify the shared history in the git shared repository? (modifying shared history, i.e. the shared repo, creates all kinds of trouble; be careful with git reset and git rebase) 21) How can you temporarily save changes before pulling/merging or switching branches? (git stash) 22) What happens to changes to a tracked file that are not committed, when you checkout another branch? (git tries to merge the changes to the file into the version of the file on the other branch) 23) How can you examine a different version of a file that you haven't checked out? (git show tree-ish:src/fullpath/file) 24) How can you safely create a project with multiple git repo dependencies? Maybe this does NOT have an entirely satisfactory answer. Officially git provides submodule capability which allows you to have foreign repos hosted in special ways and relationships. But it seems to be awkward, requiring many commands to use, and is much more trouble than it is worth. The best safe alternative right now is to just create a new directory entirely outside of any existing git repo (such as kent), and then do git clone there. AVOID: creating a tempdir inside an existing git repo, and doing git clone there. git was not meant to be used this way and will be confused at best, and could do ugly things at worst. AVOID ENTIRELY: git pull inside your git repo. Git is so powerful that it will easily merge in an entirely foreign repo into your repo, making a new merge commit and producing no complaints or errors. If you then push that to the shared repo, the merged monstrosity will get into the shared history and soon everybody's repos will be fouled up too. This is extremembly difficult to recover from. If you do something disastrous, get help immediately. Do not push if you have not already. Do not run any more git commands, just go get assistance, and let somebody know about the problem right away.