Using git with the Cluster Project
First we need to setup your git username and email address (for commits), run the following commands with your name and email address:
git config --global user.name "Your Name Comes Here" git config --global user.email you@yourdomain.example.com
Next you want to make sure that you have a copy of the repository local on your machine:
[cfeist@gold ~]$ git clone ssh://git.fedorahosted.org/git/cluster.git
or if you only want read only access use this command:
[cfeist@gold ~]$ git clone git://git.fedorahosted.org/git/cluster.git
Once you have the cluster repository local to your machine you can list the available branches:
[cfeist@gold ~]$ cd cluster [cfeist@gold cluster]$ git branch -a * master origin/FC4 origin/HEAD origin/RHEL4 origin/RHEL45 origin/RHEL46 origin/RHEL4U1 origin/RHEL4U2 origin/RHEL4U3 origin/RHEL4U4 origin/RHEL5 origin/RHEL50 origin/RHEL51 origin/STABLE origin/STABLE2 origin/master
So for this example we want to make a change to the RHEL46 branch, first we need to create a local branch that tracks the remote RHEL46 branch and then switch to that branch (ie. check it out).
[cfeist@gold cluster]$ git branch --track my46 origin/RHEL46 Branch my46 set up to track remote branch refs/remotes/origin/RHEL46. [cfeist@gold cluster]$ git checkout my46 Switched to branch "my46"
Now that we're on the RHEL46 branch, we make our changes to the file. Then you can see what changes you've made (git diff), if they look like what you want, then you can commit them locally two different ways:
If you want to commit every changed file use this command:
git commit -a
If you want to commit only certain changed files use these commands:
git add file1 file2 file3 git commit
Now you have all the changes committed locally, but they're not in the official upstream repository. Once you have all your commits working, then you can push them all at once to the upstream repository with the following command:
git push ssh://git.fedorahosted.org/git/cluster.git my46:RHEL46
If this command fails it is usually because newer changes have already been committed on the RHEL46 branch. To get these into your local repository you should run the following commands:
git fetch git rebase origin/RHEL46 git push ssh://git.fedorahosted.org/git/cluster.git my46:RHEL46
If you already have a local repository, but you just want to re-sync it to our main repository you just need to run this command (from within the cluster directory):
git pull
There's also all sorts of ways to pull patches from other branches, etc. But that's beyond the scope of this short wiki page.
DavidTeigland has done a write up about some good practices for using git here: https://www.redhat.com/archives/cluster-devel/2008-March/msg00029.html
A step-by-step workflow for working with cluster git trees can be found here: ClusterGit/ExampleWorkflow
You can find more in-depth tutorials, etc. here: http://git.or.cz/gitwiki/GitDocumentation