Version control
- version control: tracking changes. Solution to ``i didn't change anything, but it doesn't work anymore!"
- also useful for sharing files with other people, or for yourself between machines
- critical when working in large/public projects
- critical in industry
Some version control systems:
Using Git and GitHub
Nice online reference at https://www.atlassian.com/git/
PDF presentation
from Meredith/Demitri Muna
git locally
To start a project:
- Create a directory for your project and some files in it
- Start a git repository: git init
- Add the files: git add
- Commit the files: git commit
github (remote) repository
- Create github account (https://github.com)
- Create new github repository
- In your project, associate remote origin with your project:
git remote add origin {repository-address}/{project}.git
- Push the current committed version of your project: git push origin master
Note: an alternate way to set up a new project with remote association is
to create the repository on github, then clone it locally, at which point a
new local repository will be set up with the remote already associated.
Forking someone elses repository
- Forking is different from cloning, in that your copy is not totally decoupled from the original source; you can make changes
to your local copy and then send a request to the owner to see if they want to accept your changes back into the original
project. You can't do this if you just clone someone else's project
- Log into your github account
- On the desired project page on github, use the Fork button. This
will create a version of the project in your repository
- Clone this version to your computer to work on it: git clone {yourrepository-address}/{project}.git
- Declare a remote that will be synced with the fork: git remote add upstream https://github.com/{original_owner}/{project}.git
- Periodically update with:
- git fetch upstream
- git checkout master
- git merge upstream/master
Submitting pull request to forked repository
- In the cloned/forked repository, work in a new branch: git branch {branchname}
- Add, commit and push your modifications
- On your github page, select the branch that you have been working in, and submit a Pull Request
Force sync to remote repository
Beware this will lose local changes
git fetch origin master
git reset --hard origin/master