Views
Git
From OpenFlow Wiki
Contents |
Git
You may have noticed by now that the OpenFlow team at Stanford uses Git extensively. Git is a distributed version control system designed to handle very large projects with speed and efficiency.
To install Git in a Debian system, run
apt-get install git-core
Making Changes to Projects (Starting a New Branch)
Being a distributed version control system, git allows you to make changes without have write access to the remote repository you cloned from. It is usually a good habit to start a new branch from an existing branch in this case, by executing
git branch <new branch name> <existing branch name> git checkout <new branch name>
To see all the branches available in your local and remote repositories, run
git branch -a
This new branch can now be pushed to a remote repositories and subsequently merged into the master branch if so desired.
Adding Remote Repository to Local
Instructions provided often assumed a clean copy of the code from our repositories, e.g.,
git clone <git repo>
This might not be true, and a remote repository can be added to an existing local one easily, using
git remote add <repo name> <git repo> git remote update
Now, you can see all the repository using
git branch -a
Gitosis
Gitosis allows us to provide write access to our Git repositories without having to provide shell accounts to our servers. This minimizes our management task while allowing others to push their improvements and bug fixes to our repositories. The latter is very much encouraged for most (if not all) our projects.
Getting Write Access to Git Repositories
If you have ready to be pushed into the repository and would like write access, you will first need to get write access to the repository. Email David Erickson the following in an email
- attach a public SSH key (with extension .pub), generated using ssh-keygen
- specify the repository you would like write access to, and why
- specify the person in Stanford that can validate the request (and cc the email to that person)
Allow Dave has added your public key to the system, you have to configure your local machine. In ~/.ssh/config, have a section like this
Host gitosis.stanford.edu
User git
Port 22
Hostname gitosis.stanford.edu
IdentityFile ~/.ssh/<key name>_rsa
TCPKeepAlive yes
IdentitiesOnly yes
Test the setup by running
ssh git@gitosis.stanford.edu
You should see reply
PTY allocation request failed on channel 0
ERROR:gitosis.serve.main:Need SSH_ORIGINAL_COMMAND in environment.
Connection to gitosis.stanford.edu closed.
Adding Write Access with Git through Shell Account
Unlike public Git access, Gitosis access to the repository clones the repository using
git clone git@gitosis.stanford.edu:<repo name>.git
instead of
git clone git://gitosis.stanford.edu/<repo name>.git
Note the different in the git url. See #Adding_Remote_Repository_to_Local for instructions in adding this as an additional remote repository.
