Menu

Git

Kor de Jong

TODO

Branching model

A branching model is a convention for organizing code in Git branches. It is useful for managing the code that belongs to a certain new feature, a bug fix, or a release. We use a simple branching model.

Some Git commands

  1. Create, push and checkout a new branch.
  2. Update sources, commit updates, push commits.
  3. Rebase branch, commit updates, push merge commits.
  4. Merge branch, commit updates, push merge commits.

Create, push and checkout a new branch.

# Make sure the root branch is checked out. Create a new branch:
git branch bug/sf12345

# Push the branch to the server and set up branch tracking:
git push -u origin bug/sf12345

# Check out the new branch:
git checkout bug/sf12345

# Make brilliant edits to the code and commit them to the branch.
# ...

Rebase branch.

# Visualize commit, merge, branch history of current branch. Make sure all edits are
# committed and pushed to the server.
git log --oneline --decorate --graph

# Rebase the branch with the root branch. This will merge all updates of this branch's
# root branch into this branch.
git rebase <root_branch_name>

# Push merge commits to the server. Branch is ready to be merged now.
git push

Merge branch.

# Checkout the root branch.
git checkout <root_branch_name>

# Merge the branch in and delete it (locally). Push the merge commits to the server.
git merge --no-ff bug/sf12345
git branch -d bug/sf12345
git push

Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.