Memo #2: Useful Git tricks with remote branches

Posted by Dmytro Shteflyuk on under Development

Git Here in Scribd we are using Git as primary version control system. We have tons of branches created, merged and destroyed every day. Someday I hope to describe our workflow with Git, but today I want to write about some useful techniques of working with this incredible tool.

It’s implied that you know what is Git itself and how to work with it. Below you can find some advanced tricks, that should be helpful for you (at least they were helpful for me).

As you may know, to remove local branch git branch -d branch_name command is used. But if this branch was pushed to the origin repo, it will never be deleted there. To remove a remote branch use the following command:

1
git push origin :branch_name

where branch_name — the name of your branch.

When you are working in a team, everybody can create and push their own branches, which will be retrieved from the Git server during git pull or git fetch. If a branch being removed from the server, it will remain in your local repo forever. To clean these stale branches up, use this:

1
git remote prune origin

Also don’t forget to take a look at the git_remote_branch command-line tool, which makes work with remote branches as easy as it is possible.

Have any questions? Ask me and I will answer you in following Memo– posts.

3 Responses to this entry

Subscribe to comments with RSS

said on December 24th, 2008 at 04:43 · Permalink

Лучше расскажи, как работается. :)

said on December 25th, 2008 at 08:35 · Permalink

А еще таким же способом можно удалять на сервере теги:

1
git push origin :refs/tags/[tagname]
ror
said on January 9th, 2009 at 12:11 · Permalink

git превосходен, при условии наработки опыта

Comments are closed

Comments for this entry are closed for a while. If you have anything to say – use a contact form. Thank you for your patience.