Fandom

Git Wiki

Branches

30pages on
this wiki
Add New Page
Talk0 Share

From http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html

it's usually a good idea to work with branches in git Edit

checkout a tag and create a local branch from it Edit

git checkout <tag> -b <new_branch_name>

e.g.

git checkout R180 -b local_R180

show local branches Edit

git branch

* local_R180
  master

switch to a specific branch Edit

git checkout master
 Switched to branch 'master'

git branch
  local_R180
* master

git checkout local_R180
 Switched to branch 'local_R180'

git branch
* local_R180
  master

edit a file on the local_R180 branch, commit and switch back to master Edit

vim MIPSSMP86XX_WEGENER_LINUX.sh
git commit -a
git checkout master
 Switched to branch 'master'

Try to merge local_R180 into master Edit

git merge local_R180

check what happened Edit

git status

it should show something like this:

src/ic_NativeImpl/NativeImpl_Fnt/NativeImpl_Fnt_md_AMINO_LINUX/SDL_ttf.c: needs merge
src/ic_NativeImpl/NativeImpl_Fnt/NativeImpl_Fnt_md_AMINO_SDK_110_LINUX/SDL_ttf.c: needs merge
src/ic_NativeImpl/NativeImpl_Fnt/NativeImpl_Fnt_md_MIPSSMP86XX_WEGENER_LINUX/SDL_ttf.c: needs merge
src/ic_NativeImpl/NativeImpl_Fnt/NativeImpl_Fnt_md_PPCSTB02500_LINUX/SDL_ttf.c: needs merge
src/ic_filePlayer/ic_filePlayer.c: needs merge
src/ic_filePlayer/ic_filePlayer_md.h: needs merge
src/ic_streamCli/ic_streamCli_md_MIPSSMP86XX_WEGENER_LINUX.c: needs merge
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   MIPSSMP86XX_WEGENER_LINUX.sh
#       modified:   include/NativeImpl_Player.h
#       modified:   include/ic_drv.h
#       modified:   include/ic_filePlayer.h
#       modified:   src/ic_common_ver/ic_common_ver.c
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       unmerged:   src/ic_NativeImpl/NativeImpl_Fnt/NativeImpl_Fnt_md_AMINO_LINUX/SDL_ttf.c
#       unmerged:   src/ic_NativeImpl/NativeImpl_Fnt/NativeImpl_Fnt_md_AMINO_SDK_110_LINUX/SDL_ttf.c
#       unmerged:   src/ic_NativeImpl/NativeImpl_Fnt/NativeImpl_Fnt_md_MIPSSMP86XX_WEGENER_LINUX/SDL_ttf.c
#       unmerged:   src/ic_NativeImpl/NativeImpl_Fnt/NativeImpl_Fnt_md_PPCSTB02500_LINUX/SDL_ttf.c
#       unmerged:   src/ic_filePlayer/ic_filePlayer.c
#       unmerged:   src/ic_filePlayer/ic_filePlayer_md.h
#       unmerged:   src/ic_streamCli/ic_streamCli_md_MIPSSMP86XX_WEGENER_LINUX.c
#

merge conflicts Edit

git diff

nice graphical representation of the resulting history.

gitk

At this point you could delete the experimental branch with

git branch -d experimental

This command ensures that the changes in the experimental branch are already in the current branch.

If you develop on a branch crazy-idea, then regret it, you can always delete the branch with

git branch -D crazy-idea

Branches are cheap and easy, so this is a good way to try something out.

create branch Edit

git branch <name of branch>

switch to branch Edit

git checkout <name of branch>

check on which branch you are Edit

git branch

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.