====== Collaborating with GitHub ======
===== Creating a GitHub account =====
- Create a GitHub account: [[https://github.com/join]]
- Apply for a student discount: [[https://education.github.com/pack]]
- Join CardiffUniversityGravitationalPhysics: [[https://github.com/CardiffUniversityGravitationalPhysics]]
===== Creating a new Repository =====
* Create a new repository: [[https://github.com/new]]
* Decide whether it is public or private, and whether GitHub should add README, .gitignore and license
* The repository home page shows the URL for this project under "Clone or download".
* To clone it to your laptop run, e.g.:
git clone https://github.com/alberteinstein/MyProject.git
* Make changes to your project using ''git add'', ''git commit'' as before.
* Then you can push these changes up to GitHub:
git push -u origin master
* Note the ''-u'' flag is short for ''--set-upstream'' and you only need to do it once. This allows you to run ''git pull'' without specifying the branch name each time.
===== Pushing an existing Repository =====
* Create a GitHub repository as above, but do not create README, .gitignore etc.
* Copy and paste the URL.
* On your laptop go to the existing repository and add it as a new remote:
git remote add origin https://github.com/alberteinstein/MyProject.git
* Push your repository up to GitHub using:
git push origin master
===== Forking an Existing Project =====
* On the project GitHub page click the fork button.
* The repository home page shows the URL for this project under "Clone or download".
* To clone it to your laptop run, e.g.:
git clone https://github.com/alberteinstein/TheProject.git
* Make changes to your project using ''git add'', ''git commit'' as before.
* Then you can push these changes up to your GitHub:
git push -u origin master
* To keep up-to-date with the original project first add it as a remote
git remote add upstream https://github.com/theteam/TheProject.git
* Then fetch the new data and sync it with your changes:
git fetch upstream
git checkout master
git merge upstream/master
* Push your repository up to GitHub using:
git push origin master