Skip to content

Using Github with ED2

Christy Rollinson edited this page Jul 23, 2015 · 8 revisions

Setting up (first time)

Before any work is done:

  1. First fork ED on github into your own github space (github help: "fork a repo")

  2. Introduce yourself to GIT

     git config --global user.name "FULLNAME"
     git config --global user.email you@yourdomain.example.com
    
  3. If you are working from a cluster, you may need to set up ssh keys

  4. Clone to your local machine

git clone git@github.com:<username>/ED2.git
  1. Define upstream
git remote add upstream git@github.com:EDmodel/ED2.git

or (avoiding SSH)

git remote add upstream https://github.com/EDmodel/ED2.git

Daily usage

1 - Get the latest code from the main repository

git pull upstream master

2 - Do some coding

3 - Commit after each chunk of code (multiple times a day)

git commit -m "<some descriptive information about what was done>"

4 - Push to YOUR Github (when a feature is working, a set of bugs are fixed, or you need to share progress with others)

git push origin <branchname>

5 - Before submitting code back to the main repository, make sure that code compiles

./scripts/build.sh -c

6 - submit pull request (see github documentation)

Pulling from someone else's repository

git pull git@github.com:<someone_else>/ED2.git master

Resolving Conflicts

If you attempt to do a pull that reports a merge conflict, or if you encounter a merge conflict when doing a pull request you'll need to do a fetch instead of doing a pull. Fetch grabs all the changes from another repository, but it doesn't commit those changes and thus you have a chance to reconcile differences among files

git fetch <source> master

where source may be upstream or the location of someone else's directory

Next, use git status to figure out which files have conflicts

Within file that have conflicts you will find one or more sections flagged as follows

<<<<<<<<  HEAD
Original version
=======
New version
>>>>>>>

You'll need to figure out whether you want to keep the original, the new version, or combine the code in some way. In doing so you'll definitely want to remove the '<<<<<<<', '=======', and '>>>>>>>' tags

Once these errors have been resolved you'll need to use git add to mark files as fixed

git add <fixed_file>

Finally, you can now commit these changes

git commit -m "fixed conflicts in merge"