Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
210 views
in Technique[技术] by (71.8m points)

git - Migrating from On Premisis Source Control to Cloud

I have a Visual Studio 2017 project which is under source control in an on premises TFS server. I would now like to move this to Azure DevOps environment. I know I can simply copy all the code except the git files and folder to a new location and add to Source Control from scratch. But with this solution all the history is lost.

Azure DevOps does has a feature to import project from another source control project but as my current TFS server is on premises it is not exposed to the outside world so this is not an option for me.

So my question is: Is it possible to detach from one repository and add to a new one?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To move all your branches and history from 1 repository to another:

  1. Create an empty repository in your Azure DevOps project
  2. Clone your current repository (from TFS) using git clone --mirror $URL
  3. Add a new remote pointing to your Azure DevOps repository
  4. Push to the new remote

How the current man-page explains --mirror:

Compared to --bare, --mirror not only maps local branches of the source to local branches of the target, it maps all refs (including remote-tracking branches, notes etc.) and sets up a refspec configuration such that all these refs are overwritten by a git remote update in the target repository.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...