Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Moving a repo from github to stash is not working exactly even followed the docs..

imranity April 4, 2015

Our company decided to move to Stash this week from github. We created all bare repos in stash for the ones in github. 

Everything was pushed fine to stash after following the procedure mentioned in the docs here: https://confluence.atlassian.com/display/STASH/Importing+code+from+an+existing+project#Importingcodefromanexistingproject-ImportanexistingGitprojectintoStash

Except for one repo- the release team accidentally created a 'Readme' file on master branch inside the bare repo in stash.

So we removed that 'Readme' file , made a commit to that master in stash remote.

When we tried `git push --all stash` where stash is the name of the remote of stash repo, added to github repo cloned locally. (just like mentioned in the docs above ), it obviously didnt push to master as expected. 

It says we need to update master with changes in remote. Use git pull.

Doing a git pull from github remote master branch, that has like 700 commits, it applies each patch, so there are conflicts after each patch. 

Solving each conflict and then rebase --continue is really tiresome.  

at this point im not sure what exactly to do now. 

The situation can be summed up : 

  • Github remote master has 700 commits.  
  • Stash remote master 2 commits ( init , and 'remove readme' )
  • when doing `git push --all stash` it fails for master branch saying master needs to be updated with changes from remote.
  • so did `git pull <github-remote-name> master`
  • it applies patch by patch
  • that leads to conflicts after each patch is applied .
  • so solving each patch by hand and doing `git rebase --continue` is going to take a long long time for 700 commits .

Any suggestions /help appreciated. ;((

2 answers

1 accepted

1 vote
Answer accepted
crf
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 4, 2015

I would do the merge manually to "throw away" the content of the README that you don't want.  I believe that would look like this:

 

Option 1: Preserve history
 

git fetch --all                  # Make sure you have up-to-date info 
git reset --hard origin/master   # Start from what was on github
git merge -s ours stash/master   # Create a merge that ignores stash's changes
git push stash master            # Pushes up that merge commit

 

The drawback is that this extra commit will be in your history forever, but the good news is that nobody gets hurt. smile  If you want to live a little bit more dangerously, you can simply overwrite the master using a forced push.  There are some nasty consequences to trying to rewrite history like this, but if nobody else has tried to use the repository from stash yet, then you should be okay:

Option 2: Rewrite history
 

git fetch --all                  # Make sure you have up-to-date info
git reset --hard origin/master   # Start from what was on github
git push -f stash master         # Force push the master branch to stash

 

You should then restrict forced pushes to administrators, if you haven't already done so.

 

 

imranity April 6, 2015

Thanks it worked :). First solution worked right away, though second would work too but we have read/write restrictions on rewriting history from admins.

1 vote
Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 6, 2015

If the repo on Stash contains nothing but those two commits, which you don't really want, couldn't you just delete the repo and recreate it empty?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events