-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgit-update
executable file
·38 lines (23 loc) · 1.33 KB
/
git-update
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl
#-;-perl-;-
use strict;
use lib (split(/:/, $ENV{GITPERLLIB} || "/usr/local/git/lib/perl5/site_perl"));
use Git;
Git::command_noisy("pull", ("--rebase", "origin", @ARGV));
my @branches = Git::command("branch", "-r");
map s/[*\s]//g, @branches;
@branches = map { /^origin\/([^\s>]+)$/ ? $1 : () } @branches;
map { Git::command("update-ref", ("refs/remotes/$_", "refs/remotes/origin/$_")); } @branches;
__END__
=head1 TITLE
git-update - Pull updates from origin and update the remotes references
=head1 SYNOPSIS
git-update
=head1 DESCRIPTION
When using a central git repository which mirrors a subversion one, it isn't feasible to push back into the central git repository -- the commits get messed up because git svn dcommit writes svn metadata into the git commit message, changing the commit and its SHA1.
The solution is to use a circular commit, where each developer commits directly back to subversion using git svn dcommit. For that to work, though, a little behind-the-scenes magic is needed to update the remotes SHA1s that git svn uses to match the latest retrieval from the central git repository.
This script performs that magic.
=head1 AUTHOR
John Ralls, after the instruction fo Thomas Ferris Niclaisen at http://blog.tfnico.com/2010/11/git-svn-mirror-for-multiple-branches.html.
This file is in the public domain.
=cut