Difference between revisions of "Git"

From Net-SNMP Wiki
Jump to: navigation, search
(Pushing the changes upstream)
(we won't be switching in May)
Line 1: Line 1:
Git is a version control system (VCS) that is based on a distributed architecture.  In May, 2011 the Net-SNMP project will switch from [[SVN]] to '''Git'''.
+
Git is a version control system (VCS) that is based on a distributed architecture.  In June, 2011 the Net-SNMP project will switch from [[SVN]] to '''Git'''.
  
 
== Checking out the Net-SNMP Git Tree ==
 
== Checking out the Net-SNMP Git Tree ==

Revision as of 20:23, 17 June 2011

Git is a version control system (VCS) that is based on a distributed architecture. In June, 2011 the Net-SNMP project will switch from SVN to Git.

Checking out the Net-SNMP Git Tree

Select a git MODULE:

  • htdocs

Check it out anonymously (read-only access):

 git clone git://net-snmp.git.sourceforge.net/gitroot/net-snmp/MODULE

Checking it out if you're a developer:

 git clone ssh://USERNAME@net-snmp.git.sourceforge.net/gitroot/net-snmp/MODULE

Other critical initial setup

In order to make sure your email address and name are correct:

 git config user.email "YOURSFACCOUNTNAME@users.sourceforge.net"
 git config user.name "YOUR NAME"

Making changes

This is where you type vi or emacs or if you're a real developer who likes to get dirty perl -i -p -e ...

Committing the changes

 git commit -m "commit message" FILES

Or if you want to commit everything in a directory and down, use a directory name instead of FILES.

Or if you want to commit everything anywhere in the repo, use the -a switch.

NOTE: this only commits them to your local copy of the repository. This is different than SVN, if you're more familiar with SVN. Next you need to push them to the master repository:

Pulling the latest changes from the upstream

Whether or not you've modified files locally and checked in the changes to your local repository, you'll need to occasionally pull down any changes that others have made upstream. You do this with a pull:

 # git pull origin master

Assuming you followed the instructions above, and didn't cloning from somewhere else first, you should be able to shorten this to:

 # git pull

This will merge any changes you've made with any that others have made. If something goes wrong, git will complain about conflicts and you'll need to resolve those either manually or using git mergetool. That's a longer subject for another lesson: Git Merging.

Pushing the changes upstream

Once you're sure your commits are safe themselves and you've updated your repo with the latest upstream you can push your changes upstream to the master repository on sourceforge:

 # git push origin master

Assuming you followed the instructions above, and didn't cloning from somewhere else first, you should be able to shorten this to:

 # git push

And you're done!

Notes on the htdocs repository

The htdocs module, which contains the Net-SNMP website, is only synchronized from the git repository once an hour. It may take up to an hour before the changes take effect on the website.

Creating tags and branches

Tagging

Tags are simply a symbolic way of remembering "a point in time" that is easier than the sha1 hash that is more frequently seen.

 git tag my-really-super-feature-works

for example will create the above tag.

XXX: discuss annotated/signed/etc tags

Pushing tags

By default, git push doesn't push tags. IE, it *only* pushes code. If you've created a tag and you want it pushed upstream, you'll need to push it manually:

 git push origin TAGNAME

Or you can push all your tags:

 git push --tags

Note: Please don't push personal tags... Use the individual push instead if you're creating helpful personal tags.

Learning Git

If you're starting out learning Git, here are some useful resources:

Git work flows