2. Git is Version Control for code
management. It allows us to
collaborate, track changes or
updates, and facilitates an
efficient and thoroughly
reviewed workflow.
3. Github Introduction
What is Github?
Github is an online repository for storing collaborative code that is version-controlled
How does Github work?
Version control is achieved using the UNIX program git (more info later)
What should be stored on Github?
All code and documentation required for each project
What SHOULD NOT be stored on Github?
Sensitive information (passwords, client’s data)
Trained models, output files (use S3 if necessary)
Large files - Github has a file-size limit of 100MB
4. git: Like a Multiplayer Notepad...
1. Keeping up to date (git pull)
2. Leaving breadcrumbs (or checkpoints)
3. Review, Approve, Merge
4. Branches!
5. Getting out of a pickle
8. commit, commit, commit, push!
Think functionality over time. Added a new function? Commit.
Fixed the syntax of that erroneous line? Commit.
You can commit as much as you like before actually pushing.
11. You can create feature branches. These should be
used to work on specific, module chunks of code.
Remember they should all get merged into one
‘master’ file later.
branching
13. To produce high quality work we should review and
understand each others work.
We should be responsible for our work
To collaborate together we need to be reading from the
same page.
PRs, Reviews,
Merging
20. Going back to square one: Common Issues
Undo local commits
git reset HEAD~2 # undo last two commits, keep changes
git reset --hard HEAD~2 # undo last two commits, discard changes
Remove a file from git, but keep it locally
git reset filename # or git remove --cached filename
echo filename >> .gitignore # add it to .gitignore to avoid re-adding it
Edit the last commit
git commit --amend # start $EDITOR to edit the message
git commit --amend -m "New message" # set the new message directly
git add forgotten_file
git commit --amend
View log of commits (with commit Ids)
git log
Reset to previous commit (Run git log to see Ids!)
git reset --hard <some-commit>
Reset changes to a particular file
git checkout -- ignoreChangesToThisFile.txt
Turn it off and on again!
rm -fr ~/myrepo/ && git clone myrepo