| [ << Working with source code ] | [Top][Contents][Index][ ? ] | [ Compiling >> ] | ||
| [ < Reverting all local changes ] | [ Up : Advanced Git procedures ] | [ Git log > ] | ||
3.4.4 Working with remote branches
Fetching new branches from git.sv.gnu.org
To fetch and check out a new branch named branch on
git.sv.gnu.org, run from top of the Git repository
git config --add remote.origin.fetch \ +refs/heads/branch:refs/remotes/origin/branch git checkout --track -b branch origin/branch
After this, you can pull branch from git.sv.gnu.org
with:
git pull
Note that this command generally fetches all branches you added
with git remote add (when you initialized the
repository) or git config --add, i.e. it
updates all remote branches from remote origin, then it
merges the remote branch tracked by the current branch into the
current branch. For example, if your current branch is
master, origin/master will be merged into
master.
Local clones, or having several working trees
If you play with several Git branches, e.g. master,
lilypond/translation, stable/2.12), you may want to
have one source and build tree for each branch; this is possible
with subdirectories of your local Git repository, used as local
cloned subrepositories. To create a local clone for the branch
named branch, run
git checkout branch git clone -lsn . subdir cd subdir git reset --hard
Note that subdir must be a directory name which does
not already exist. In subdir, you can use all Git
commands to browse revisions history, commit and uncommit changes;
to update the cloned subrepository with changes made on the main
repository, cd into subdir and run
git pull; to send changes made on the subrepository
back to the main repository, run git push from
subdir. Note that only one branch (the currently
checked out branch) is created in the subrepository by default; it
is possible to have several branches in a subrepository and do
usual operations (checkout, merge, create, delete...) on these
branches, but this possibility is not detailed here.
When you push branch from subdir to the
main repository, and branch is checked out in the
main repository, you must save uncommitted changes (see
git stash) and do
git reset --hard in the main repository in
order to apply pushed changes in the working tree of the main
repository.
| [ << Working with source code ] | [Top][Contents][Index][ ? ] | [ Compiling >> ] | ||
| [ < Reverting all local changes ] | [ Up : Advanced Git procedures ] | [ Git log > ] | ||