Gitworkflowalt
Alternate version suggested by Kevin showing only the sections that changed, mostly untested. Use GitWorkflow for now
To see changes based on original use Page History and compare to version 1. Major changes are also noted below.
Getting Started
Added extra step to part 3
- Create your initial public clone of the
main repository by logging into git-public.flux.utah.edu and
issuing the following command (replace '<username>' with your
account name on git-public):
git clone --mirror /flux/git/emulab-devel.git /flux/git/users/<username>/emulab-devel.git
Note: Git will say "Initialized empty Git repository in ..." Do not worry; your new repository is not really empty. - Create your private repository by cloning your public clone on your work
machine. You may create as many private repositories in different
places as you like, but for this discussion we'll just work with one.
git clone git-public.flux.utah.edu:/flux/git/users/<username>/emulab-devel.git
- Add the main repository as a "remote" of your private repository so that you
can publish your work with a 'git push' command.
Commits to the main repository will flow through your private
clone to your public clone; you will not need to log into
git-public to manage your public clone.
git remote add central git-public.flux.utah.edu:/flux/git/emulab-devel.git
and add the following to .git/config [XXX: can also use git config][remote "central"] ... pushurl = git-public.flux.utah.edu:/flux/git/emulab-devel.git pushurl = git-public.flux.utah.edu:/flux/git/users/<username>/emulab-devel.git
This will cause any pushes to central to also get pushed to your private clone and thus help keep them in sync. - Initialize a couple of git configuration directives so that git
will use your full name and email in commit messages. If you do
not do this, it is difficult for others to figure out who has
made the commits:
git config --global user.name "Ryan Jackson" git config --global user.email "rdjackso@cs.utah.edu"
This will put these settings in ~/.gitconfig, and they'll apply to all future commits from all repositories on that machine. Be sure to do this on any machine you are committing from. - (Optional) Set up your public repository to send mail when you push to it. ... [Not changes from main version]
Normal Work
Simplified most steps
- Now, lets do some development work. First, create a branch in
your private repository, and push that new branch to your public
repository. (You will not push your work to the main repository
until your branch is finished.)
git checkout -b mybranch git push origin mybranch
- As you work in the new branch, you should regularly commit your
work to the new branch in your private repository.
git commit -a -m 'Made an important change to foo'
- On a regular basis you should also push your changes to your
public repository.
git push
- Along the way, you may want to sync up with the main repository to pick up
(unrelated) changes by other people.
git fetch central
which will grab all changes from central. If you want to merge these changes into your branch, so that your branch has the latest stuff:git merge central/master git push
The git push will also push any unrelated changed fetched from central, thus keeping you public clone in sync. [XXX: Make sure this is right]
If you see a warning message like this:CONFLICT (content): Merge conflict in xxx/yyy/zzz
you will need to resolve those conflicts by hand and mark the conflicts as resolved by re-adding the changed files.git add xxx/yyy/zzz
- When you are ready to commit your branch to the main repository:
git checkout master git pull central master git merge mybranch git push central master
- Finally, you can delete the branch from your private repository and your
public repository.
git branch -d mybranch git push origin :mybranch
Hot Fixes
Removed push to origin as that will happen automatically now
If you want to make a quick change to the central (emulab-devel) repository, without creating a branch in your local clone, first switch back to the master (stashing any local changes on your branch).
git stash git checkout master git pull central master
You are now in sync with the emulab-devel repository. Make your change, and then commit locally:
git commit -a -m "This is a hot fix"
You now need to push this commit to the emulab-devel repository:
git push central master
Note that this method of making changes is encouraged for small quick fixes only; eg: edit file and commit.