Hugonweb | Git for Fermilab Repositories

Merging Code into Develop

Starting from a version tag and some modified code, you should first create a feature branch:

git checkout -b feature/username_topicname

\"git checkout\" is counterintuitive for cvs/svn users. It means to switch branch. The -b option makes it create a new branch and switch to it. After running that command you should be on the new branch \"feature/username_topicname\" but it just points to the same code as the version tag you were on before. Now, you can add all of the files you want to commit to your branch:

git add <filename>

The \"git status\" command should tell you all of the files that you have changed or that aren\'t already in the repository. Make sure all of the files you want to commit have been added. Now you can commit:

git commit

At this point your branch now has your code in it. Now we want to merge that into the develop branch. First, switch to the develop branch:

git checkout develop

Then, make sure it is up to date with the server:

git pull

Now you can try to merge the code in your branch into the develop branch:

git merge feature/username_topicname

This may just work, but if there are conflicts you have to fix them and then run git commit. At this point, it would be good to check that you didn\'t mess up anything. You can diff your new version of develop with the server\'s version of develop like this:

git diff origin/develop

If everything looks in order, you can then push your version of develop to the server:

git push

Now everyone has your changes.

Setting up remotes for push

You need to have the correct server set up to run the push command. Git calls these \"remotes\"

git remote -v

should show this for lariat:

origin  ssh://p-lariatsoft@cdcvs.fnal.gov/cvs/projects/lariatsoft (fetch)
origin  ssh://p-lariatsoft@cdcvs.fnal.gov/cvs/projects/lariatsoft (push)

and this for dune:

origin  ssh://p-dunetpc@cdcvs.fnal.gov/cvs/projects/dunetpc (fetch)
origin  ssh://p-dunetpc@cdcvs.fnal.gov/cvs/projects/dunetpc (push)

If it doesn\'t, then run:

git remote set-url origin <the url>
git remote set-url --push origin <the url>

You have to have a valid kerberos ticket for this to work, and be on the developer list.

Deleting a remote branch

# first delete the local branch
git branch -d <branchname>
# then delete it remotely
git push origin :<branchname>