Information Technology Reference
In-Depth Information
You are a member of a team. You pushed your work to the remote branch named
new-
web-interface
. This branch was integrated into the
master
branch and is no
longer used. You are asked by the leader to remove the remote branch
new-web-in-
terface
. You want to remove your local branch as well.
In this recipe we are using the scenario from Recipe 10-8. You act as a developer
working in
johns-repo
.
Solution
Copy the all the repositories from Recipe 10-8:
$ cd git-recipes
$ cp -R 10-08 10-11
$ cd 10-11
Now you are working as John. All the commands should be run in
10-11/
johns-repo
:
1. You update your project with
$ git fetch
.
2. Go to the
master
branch:
$ git checkout master
3. Update your
master
branch with
$ git rebase origin/mas-
ter
4. Check for branches that can safely be removed:
$ git branch --
merged
. The output should include—among others—
new-web-in-
terface
branch. This means that the
new-web-interface
branch
can be safely removed. The command
$ git branch --merged
is
a safety check: if the branch
new-web-interface
is not printed by
this then it is not safe to delete the branch.
5. Remove the remote branch
new-web-interface
in
shared-repo
as well as your local tracking branch
origin/new-web-interface
with
$ git push origin :new-web-interface
6. Finally remove your
new-web-interface
branch with:
$ git
branch -d new-web-interface