简体   繁体   English

从Bitbucket导入到具有历史记录的Stash?

[英]Importing from Bitbucket to Stash with history?

We are moving our repositories from Bitbucket to our local environment in Stash. 我们正在将存储库从Bitbucket迁移到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: 这是我们导入存储库的方式:

  1. Create a folder on local, using Tortise Git, clone it. 使用Tortise Git在本地上创建一个文件夹,将其克隆。
  2. Open Git Bash, go to this folder(directoary) by changing path using CD command 打开Git Bash,使用CD命令更改路径转到此文件夹(目录)
  3. Run the following commands: git init 运行以下命令: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. 由于我是Git的新手,所以这些可能不是正确的方法。

You need to: 你需要:

  • clone the Bitbucket repo 克隆Bitbucket回购
  • create a local branch for all Bitbucket branches 为所有Bitbucket分支创建本地分支
  • push everything to Stash. 将所有东西都推到藏匿处。

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 '. 我为Bitbucket存储库“ bitbucket ”(而不是默认的“ origin ”)命名为遥控器。
    That is because you will end up working with your Stash repo by default . 这是因为默认情况下 ,您最终将使用Stash回购。
    That is why I reserved the remote name " origin " for said Stash repo. 这就是为什么我为Stash repo保留了远程名称“ origin ”的原因。

  • Making a local branch for every bitbucket branches is described here: " Track all remote git branches as local branches ". 在这里描述为每个bitbucket分支创建一个本地分支:“将所有远程git分支作为本地分支进行跟踪 ”。

  • I wouldn't recommend working in that local repo (which is tracking all Bitbucket branches). 我不建议在该本地仓库中工作(该仓库正在跟踪所有Bitbucket分支)。
    I would rather cloned the newly filled Stash repo elsewhere, and work from there. 我宁愿将新填充的Stash存储库克隆到其他地方,然后从那里工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM