Assuming you've
set up a working git repository
, the typical work flow is as follows:
- In your private repo, move to the branch you wish you branch off of,
-
git checkout parent_branch_name
- create a new branch off this parent, using one of the following sequences:
- if on the parent branch, create the branch then switch to it:
-
git branch new_branch_name
-
git checkout new_branch_name
- same as above, but done in a single command
-
git checkout -b new_branch_name
- same as above, but done on a non-parent branch
-
git checkout -b new_branch_name parent_branch_name
- on your new branch in your private repo, you can
- add, delete file that git should track
-
git add .
(to tell git to track all newly added files)
-
git add file_name
(to tell git to track a specific file)
-
git rm file_name
(to tell git to stop tracking a file, does NOT delete the file from the system, but may have to be called after a file has been deleted from the system, so git doesn't continue tracking a non-existant file)
- commit your file changes, creating a new local checkpoint
-
git commit
(brings you to an editor screen, where you need to type at least a title, and potentially a description separated by a linkbreak)
-
git commit -a
(same as above, but equivalent to calling git add .
before committing)
- undo file changes and return to previous checkpoints
-
git checkout -- file_name
(to replace with the copy last saved at a checkpoint)
- pushed to the public repo for backup and sharing
-
git push origin branch_name
(note that origin
is the name of your public repo)
- once the branch is stable, merge the branch with the main dev trunk
- make sure that your local copy of
dev
is up to date
- apply the changes present in
dev
(i.e. by others) to your own branch
-
git rebase dev
(call this while on your own branch)
-
git rebase dev your_branch
(or this while on another branch)
- move to the
dev
branch
- apply your _stable _changes to the
dev
branch
-
git merge your_branch
(due to the rebase above, you shouldn't run into any merging issues)
- sync the newly updated
dev
with the main repo
The main repository then, will have two main branches
-
dev
where contributors branch new features, and merge stable features
-
master
, controlled by Chris, has the main working copy
In addition, many branches off of
dev
will exist from
pushes
, which can serve as backup and also used when seeking help.
- Note that other developers should not branch off these non-=dev= branches
Topic revision: r3 - 2010-05-04
- jujubix