We are moving our repositories from Bitbucket to our local environment in Stash. I am able to import the latest version of our repositories but not the details of previous commits and versions.
Can you please guide me what I should do to import our repositories with all branches, commits and version details?
This is how we are importing our repositories:
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
As I'm new to Git, these may not be the correct way to do it.
You need to:
That would means:
git clone -o bitbucket https://bitbucket.org/username/reponame
cd reponame
remote=bitbucket ; for brname in `git branch -r | grep $remote | grep -v master | grep -v HEAD | awk '{gsub(/[^\/]+\//,"",$1); print $1}'`; do git branch --set-upstream-to $brname $remote/$brname ; done
git remote add origin http://User@localhost:7990/scm/PROJECT/repo.git
git push --all
git push --tags
Couple of notes:
I have named the remote for the Bitbucket repo ' bitbucket
', instead of the default ' origin
'.
That is because you will end up working with your Stash repo by default .
That is why I reserved the remote name " origin
" for said Stash repo.
Making a local branch for every bitbucket branches is described here: " Track all remote git branches as local branches ".
I wouldn't recommend working in that local repo (which is tracking all Bitbucket branches).
I would rather cloned the newly filled Stash repo elsewhere, and work from there.
To import the project files, commit history etc, you can do something like:
git clone --bare git@bitbucket.org:/login/myrepo.git
cd myrepo.git
git push --mirror git@stash.acme.com:/project/myrepo.git
cd ..
rm -rf myrepo.git
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.