Skip to content
Austin Belknap edited this page Nov 3, 2013 · 7 revisions

The Final State Analysis package is tracked using the Git version control system. Git is different than CVS in that it's distributed - each repository is local and can stand by itself. Git makes it easy to pass changes to other repositories. This means you can make commits offline, and without worrying about messing up the central version control system.

Links

Downloading Code

To get the code, you can clone from the master repository:

git clone https://github.com/uwcms/FinalStateAnalysis.git

Setting up your own online repo

Go to github.com and set up an account. Then "fork" the UWCMS repository. Now you have your own version at:

https://github.com/YOURNAME/FinalStateAnalysis

now get a local copy of your remote version:

git clone --recursive https://github.com/YOURNAME/FinalStateAnalysis.git

You can now edit the code, and commit it as often as you like (see below). You can't ever mess anyone else up with conflicts like in CVS so do it often. Although, it is generally considered to be good practice not to make commits directly to the master branch. This helps to keep the commit history under control. When you are ready to start writing code, start a topic branch:

git checkout -b branch_name

Then, begin writing code and making commits to your new branch. When you are ready to share your changes, push them to your GitHub repository:

git push origin branch_name

Now you can request that this topic branch gets "pulled" into the UWCMS master branch by going to your github.com site and clicking "Pull Request".

Updating Your Repository

As changes are made to the UWCMS repository, you will likely want to get those changes. Assuming you have already forked your own repository and cloned it in your work area, add the UWCMS repository as an "upstream" remote:

git remote add upstream https://github.com/uwcms/FinalStateAnalysis.git

You can do the following to update your master branch:

git checkout master
git pull upstream master

A safer way to perform the merge (to help ensure your master branch matches exactly the UWCMS master branch), do the following instead:

git checkout master
git fetch upstream
git merge --ff-only upstream/master

After updating your master branch with UWCMS, you generally push it to GitHub to keep your remote repository up-to-date as well:

git push origin master

If You've Cloned Someone Else's Repository

If you've started by cloning someone else's repository (that you don't own), you can upload to yours by setting up (just once) your repo as a "named remote," called mygithub:

git remote add mygithub https://github.com/YOURNAME/FinalStateAnalysis.git

and then push your "master" branch to the new remote "mygithub" by:

git push mygithub master

Committing Code

To commit a file, first add it to the "index" of changes to be commited:

git add file1 [file2]

Once you're ready to commit, run:

git commit -m "my informative commit message"