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

importing from Bitbucket to Stash with commits?

Tamoj Bajracharya October 3, 2013

We are moving our repositories from Bitbucket to our local environment in Stash. I am able to import latest version of repositories but not details of previous commits and versions. I am describing steps I am doing to bring repositories into Stash. Can you please guide me what I should do to bring repositories with all branches, commits and version details, so we can stop using Bitbucket after having Stash.

Thanks.

Steps:

  1. Create a folder on local, using Tortise Git, clone it.
  2. Open Git Bash, go to this folder(directoary) by changing path using CD command
  3. Run the following commands:

    git init git add --all git commit -m "Initial Commit" git remote add origin http://User@localhost:7990/scm/PROJECT/repo.git git push -u origin master 

Sorry guys, new to Git, my command and way may be dirtiest :)

Appreciate your help and time.

Thanks

1 answer

1 accepted

2 votes
Answer accepted
cofarrell
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.
October 3, 2013

Hi Tamoj,

So you don't want to be running 'git init' - that's not going to do anything. (And you don't need to create a commit either).

Secondly - can I assume you're only seeing the 'master' branch in Stash? Does that contain all your commits (plus 'Initial commit') or does it just have "Intial commit"?

In any case if you want to get an exact copy of the bitbucket repository I would do something like:

> git clone --mirror http://bitbucket.org/user/repo.git

> cd repo

> git remote set-url origin http://User@localhost:7990/scm/PROJECT/repo.git

> git push

That should get you an exact mirror of the repository. Be a _little_ careful with mirror - when you push to a remote it will ensure everything is idential - which if you push to a repository that has new changes you're going to lose them (well sort of - you can always get things back in Git).

Alternatively you could use this plugin (Warning - I've not tried it)

https://marketplace.atlassian.com/plugins/com.englishtown.stash-hook-mirror

How many repositories are you migrating by the way?

Good luck,

Charles

Tamoj Bajracharya October 3, 2013

Thanks Charles, I appriciate your help and time, I acted as per suggest and need cleaerity a little more please.

Running Git Bash I was in default direcotry path was ~ <master> I run the following command there and it was ok and after asking password it cloned successfully.

> git clone --mirror http://bitbucket.org/user/repo.git

> cd repo What repo it should be ? A new folder and make it a repository by running git init or give path of my Stash repository ?

I could not run 3rd command (> git remote set-url origin http://User@localhost:7990/scm/PROJECT/repo.git) successfully. I have attempted 2 things here.

  1. I did cd C:\Temp4 which is a newly created directry and got the error in Git bash "fatal: Not a git repository<or any of the parent directories>: .git"
  2. I tried setting my physical path of destination repository by cd C:\StashData\data\repositories\21 and error messgae was "No such file or directory"


Can you please guide further.

Really appriciate you help.

cofarrell
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.
October 3, 2013

Hi Tamoj,

When you run the git clone on your repository it should have created a directory called 'repo' (actually now that I think about it - it was probably 'repo.git'). What do you see in the folder where you cloned?

You definitely don't need to run 'git init'.

Cheers,

Charles

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events