importing from Bitbucket to Stash with commits?

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

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

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.

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

2,007 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you