Project

General

Profile

Git Help

Initial clone

Authenticated clone (allows push):

$ git clone ssh://p-lbne-beamsim@cdcvs.fnal.gov/cvs/projects/lbne-beamsim/g4lbne.git

Anonymous clone (no push):

$ git clone http://cdcvs.fnal.gov/projects/lbne-beamsim/g4lbne.git

Making changes and committing them.

In git commits are always local and do not change the git repository in redmine. After modifying existing files or adding new ones you can do the following:

$ emacs src/existing.cc src/newfile.cc
$ git add newfile.cc
$ git commit -a -m "Modify existing file and add newfile" 
$ git status
# On branch v3
nothing to commit (working directory clean)

Sharing your commits with others

To let others access your commits you push them to the Redmine repository

$ git push

Note, if someone has pushed their own commits since you first created or updated your repository you will first need to incorporate their changes. See the next section.

Incorporating commits from others

In order to incorporate any commits that others have pushed you pull them

$ git pull

Handling conflicts

Normally git is very good at merging the work of multiple people. However, if more than one person changes the same line it can be impossible for git to know which change should be kept. This will cause a conflict. If this occurs, git will tell you about it and you will need to edit the file or files and delete the lines that should not be kept. Then you can add the file and commit as if it was a normal edit.

Picking a branch

More than one branch may exist. Check on the Mailing List which branch is right for you.

Listing available branches:

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/muonFlux
  remotes/origin/v2

The "*" indicates which branch is active. To create a new branch associated with a remote branch do:

$ git checkout -t -b v2 origin/v2
Branch v2 set up to track remote branch v2 from origin.
Switched to a new branch 'v2'
$ git branch -a
  master
* v2
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/muonFlux
  remotes/origin/v2

Visualizing the commits

To visualize the commits and branches in your cloned repository rung:

$ gitk --all