Created
April 11, 2015 19:10
-
-
Save cyan-at/4c396cd3322e860913ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python catchup.py log.txt <commit#> | |
#get log.txt by doing git log > log.txt | |
#get commit# by cat .git/refs/remotes/origin/master | |
import sys | |
import os | |
logFileName = sys.argv[1] #log.txt | |
startCommit = sys.argv[2] #407fadabe28828e78cd84642eed6edc2ecca0e54 | |
print logFileName | |
fo = open(logFileName,'r') | |
lines = [line.strip() for line in fo] | |
commitLines = [] | |
for idx in xrange(0, len(lines)): | |
l = lines[idx] | |
if ('commit' in l): | |
commitNum = l.split(" ")[1].strip() | |
if (commitNum == startCommit): | |
print 'Found it!' | |
print idx | |
print l | |
break | |
commitLines.append(commitNum) | |
print len(commitLines) | |
for idx in xrange(0, len(commitLines)): | |
i = len(commitLines) - idx - 1 | |
c = commitLines[i] | |
cmd = "git push origin "+c+":master" | |
os.system(cmd) | |
fo.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
let's say you have a repo tracked on two different systems (i.e. app engine and bitbucket)
let's say you do a ton of work in one system (bitbucket) which leaves the other one ignored for a while
then you try to push to the ignored system but master there is behind by 35 some commits
and pushing all at once times out on remote
use this script to help you out 😃 by pushing one at a time