How to migrate Projects (Source Codes) from GIT TFS REPO (NOT TFVC) to GitHub along with history

I have a GIT TFS repo (NOT TFVC) as seen in the below screenshot with branches and trying to migrating the projects (source code) from GIT TFS Repo to GITHUB with History. Kindly let me know what options are available.

The GitHub’s Import Repository is not working as it is expecting https connections and the link to our GIT TFS is “http://server:8000/tfs/SomeTestName” and getting below error -

We can’t import from http://server:8000/tfs/SomeTestName. Please check the URL and try again.

Also the git-tf works only for TFVC and not for GIT TFS.

Do we have any better option rather than downloading each history in GIT TFS and pushing it to GitHub Repo as releases.

  1. Clone the repository locally
  2. Create an empty repository in GitHub
  3. Push to the GitHub repository from your local repository

You can automate this.
The gh tool:

will let you create repositories:

Thank you for the reply, I still have few queries though -

  1. From the GIT TFS Repo, how will I get the history of changes i,e from the initial commit until today. How do we get all the commit history?

  2. While setting up the repo, I get the error → fatal: not a git repository (or any of the parent directories): .git.

I don’t want to run “git init” as this destroys cloned files and turns it into a fresh sandbox, with a bunch of dirty files.

Can you please suggest a way to avoid this error?

Afaiu, git-tfs gives you a complete git history.

So you should be able to do:

  1. git tfs clone local --branches=all to get your history (the precise syntax for this is beyond me, I don’t use TFS, and I can’t find any public TFS servers…) as a git repo.
  2. cd local (to perform the next steps)
  3. gh repo create --private --remote github org/repo-name (to create the github repo repo-name in the org organization to host the code) – I’m using --private in the example, but in testing I used --public, there’s also --internal, you’d pick the one you want to use…
  4. git push github to push your source code

Can you please check this link (more so on the Answer section)

What I am trying to say here is I do not need to use git tfs command as my current source code where it is hosted is already a git repository.

And just using git clone downloads only latest commit and not entire history. How should I proceed with this part?

Ok, so the first command would be closer to:
git clone http://servername:8080/tfs/DCM/Python.git local

And you can get the URL for the clone from the web UI according to the instructions.

That’s wrong, git clone gets the full history unless you explicitly tell it not to (creating a “shallow clone”). Check git log after cloning, if you see the full history you have it. :slightly_smiling_face:

Yes Fantastic. !!, I am able to find all the commits :grinning: :smiley:

Also I was able to push the source code to GitHub and I can view all the commits. Thanks a ton for this :grinning: