git clone ssh://git@cosmologist.repositoryhosting.com/cosmologist/cosmomc.git(similarly for others). The code will then be in the cosmomc folder.
git checkout --track origin/branch_name
git commit -a -m "my change description"Use "git log" to see recent changes. Changes are stored locally, if they are for public consumption do
git pull origin masterThe first line downloads any changes from other people. If there are conflicts search for ">>>" in in the source files and edit by hand to resolve, and commit. The second line pushes changes to the shared repository.
git push origin master
"git add --all" will add all files (you may well not want this - don't add lots of junk by mistake!), or use "git add xx" to add individual files or folders.
The camb repository has CAMB and CAMB sources (CAMB_sources branch). Plain CAMB is also in the CosmoMC repository but may not be as up to date
Make a tag e.g.
git tag May2010 c24bda0cfac567a1a5bb7844e25631aed53f756e(use "git log" to get the commit you want to tag). Must use "git push --tags" to push to public server, not included in normal pushes.
Use "git fetch" to check your list of branches is up to date. List available branches using:
git branch -rFor details see e.g. Branch Wizardry.
git branch NewBranchto make NewBranch which also contains the current state, and then switch to it. You can make changes to your new branch independently of the original branch. To use an old version you can can also do, eg.
checkout NewBranch
git branch NewBranch Jan2010If you have already modified code in the current branch which you have not committed, and want to put it in a new branch instead, do
git checkout -b new_branch_name
git checkout branch_name
git branch NewBranch Jan2010Now make your changes. If you have old modified source code you can replace files with your modified versions.
git checkout NewBranch
Use "git add xx" to add new files. Then save changes using
git commit -m "my first custom version"
If you started from an old branch, or there have been subsequent updates to the main code, try to update to be consistent:
git pull origin master
Branches are stored locally when you make them, no one else can see them. Push your modified branch to the git repository to share (use push -u to make it track by default, so pull and push is then easier):
git push origin NewBranchThis makes a new branch NewBranch on the remote repository, and will not mess up the master branch. If other people also push changes, you pull them using
git pull origin NewBranch(make sure current branch is branch you want to update). You can also pull changes to the master branch into your custom branch, e.g. with your local NewBranch checked out "git pull origin master" will update local NewBranch with changes from the latest remote master branch. If someone has messed up your beautiful code, use "git log" to view the history, checkout the last version that was OK, or use git diff" to see actual changes and make a new commit correcting them if need be. Viewing changes is easier with a GUI, TortoiseGit, XCode, Visual Studio and others all have nice ways of displaying changes.
You always need to commit changes before switching branches, or pushing your changes.
If you have multiple branches, and want to update the current branch with changes from another, you can use
git merge OtherBranchIf there are whitespace changes you can ignore them with
git merge -Xignore-all-space test_update_branchYou may want to add --no-commit --no-ff to allow fixing the whitespace consistently before committing the merge. CosmoMC source files have standardized whitespace and indenting from Visual Studio's Format Document, but older versions do not.
If a branch you are merging contains lots of commits, you can combine into one new commit by using
git merge --squash MergeBranch(and then using commit -m "new commit message").
git reset --hard <commit>You can also revert a local branch to a remote branch
git reset --hard origin/NewBranchNote these will delete all your local changes. If you've already pushed you bad changes, and hence messed up the public branch, you can force replacement of remote branch with local branch
git push --force origin NewBranchDon't do this if anyone is likely to have used the remote copy though. If mistakes have been shared, better to have a new commit which is a correction (see "reset").
Delete remote branch with
git push --delete origin NewBranchor
git push origin :NewBranchTo stop the branch still showing up in "branch -r" do git remote prune origin
If you merged the wrong branch, or did the wrong pull, you can undo a (fast forward) merge or pull reverting to previous state with
git reset --keep NewBranch@{1}
Reset single uncommitted file to the last committed version with
git checkout file
Make new branch using un-committed changes
git checkout -b new_branch_name(does not change your local modified files; after new branch is made, commit)