Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

(Please note If you have Chocolatey already installed, you can jump to step 4)

1. Open CMD Windows PowerShell as administrator 
2. run following in cmd shell to install Chocolatey package manager


Code Block
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"


3. run following in cmd shell to test Chocolatey installation

Code Block
choco


(Please note If you have Git-TFS already installed, you can jump to step 7)

4. run following in cmd shell to install gittfs git-tfs through Chocolatey

Code Block
choco install gittfs


5. Type "Y" when prompt to install any additional toolset.

6. run following in cmd shell to verify git-tfs installation.

Code Block
git tfs help


Warning

If you don't have any installation from Visual Studio, you might get an error when running the above command

Image Added

I downloaded Team Explorer based on this website: https://devblogs.microsoft.com/devops/reintroducing-the-team-explorer-standalone-installer/ and I installed it.

Image Added 

After that, I choose the option "Not now, maybe later." and "Start Visual Studio"

Image Added Image Added

NOTE: You don't need to leave the visual studio open.

7. run following command if want to list all TFS branches that could be cloned (Please be careful to use this command as it might take long time.  Also be sure to replace appropriately with your TFS collection information)

Code Block
git tfs list-remote-branches http://tfsprod:8080/tfs/Marine%20Safety/
Note: %20,in the path string "Marine%20Safety" represents the empty space " " in the path string "Marine Safety"
Tip

If you don't see the branch you want to clone, then it probably hasn't been configured as a branch in TFS.  You can do this through Visual Studio by right-clicking on the "project" in Source Control Explorer and converting it to a branch:

Warning

If your codebase in TFS has sensitive information (eg. passwords), do not include them in your Azure Devops repository.  Remove them from the codebase, check the changed files back into TFS and then be sure to clone the latest only (step #8).  If you clone all history (as in step #9), the passwords will still be available in the repo history.  If you really need to keep the history then you'll have to do something like:  How-to Remove Sensitive Info from a GIT \ Azure DevOps respository.


8.run Run following command to clone only latest code. For example: MPDIS-SDDPM (You might need to set up userName and Email for git before clone: git config – global user.name "YourName" ; git config --global user.email "xx.xx@tc.gc.ca").  Go to the next step if you want to keep the full history!

Code Block
git tfs clone http://tfsprod:8080/tfs/Marine%20Safety/ $/MPDIS-SDDPM_Scrum/DEVELOPMENT/MPDIS-SDDPM c:\tmp\migration\mpdis

Above command clones the tfs repository      http://tfsprod:8080/tfs/Marine%20Safety/ $/MPDIS-SDDPM_Scrum/DEVELOPMENT/MPDIS-SDDPM
to a temporary git repository at the given local path    c:\tmp\migration\mpdis      A temporary git repositoiry gets created at this location.


9. or Run following command to clone all history from TFS for all branches. For example: MPDIS-SDDPM

Code Block
git tfs clone http://tfsprod:8080/tfs/Marine%20Safety/ $/MPDIS-SDDPM_Scrum/DEVELOPMENT/MPDIS-SDDPM c:\tmp\migration\mpdis --branches=all


Tip

If your branch happens to have spaces in the name, put quotes ("") around it.  Eg. git tfs clone http://tfsprod:8080/tfs/Marine%20Safety/ "$/Some branch name with spaces in it/DEVELOPMENT/MPDIS-SDDPM" c:\tmp\migration\mpdis --branches=all


Warning

If your codebase in TFS has sensitive information (eg. passwords), do not include them in your Azure Devops repository.  You can do one of two things:

  1. Remove them from the codebase, check the changed files back into TFS and then be sure to clone the latest code only (step #8).  You will lose all history in this case.
  2. If you clone all history (as in step #9), the passwords will still be available in the repo history.  Remove the culprit files from history as follows:
    1. In the cmd shell, navigate to your repo's folder (in the above example it was c:\tmp\migration\mpdis).
    2. (See this page for more detail regarding this step).   Run the following making sure to change the path-to-the-file to the actual path to the file (eg. src/web.config):  git filter-branch --force --index-filter "git rm --cached --ignore-unmatch path-to-the-file" --prune-empty --tag-name-filter cat -- --all
    3. You've now removed the culprit files from history.  You can re-create and add them to the repository later with sensitive information removed if you'd like.

NOTE: If there is a space in a folder name in path-to-the-file, place a slash"\" before the space. E.g. if the path is  My Project/Settings.settings, change it to My\ Project/Settings.settings. Otherwise, the above command does not remove specified file.

10. Check history: git log. Now navigate to the location where you cloned your repository (eg. c:\tmp\migration\mpdis).  Then you can check history:

Code Block
git log

git log  command can produce very long message with every following key stroke. To exit viewing the log history, hit "q" key from your keyboard

11. check origin:

Code Block
git remote -v

12. If has already attached a remote origin, we need to remove origin:

Code Block
git remote rm origin

13. Add devops origin (replacing below with appropriate repo information):

Code Block
git remote add origin https://tcnarwhals@dev.azure.com/tcnarwhals/MPDIS-SDDPM_Scrum/_git/MPDIS-SDDPM_Scrum


Tip

If the DevOps Master branch has ReadMe.md file created and committed, we need to run the following commands to merge remote and local together.

git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks pull --no-commit origin master --allow-unrelated-histories

git commit -m "Merge branch 'master' of https://dev.azure.com/DSD-Marine/MSS-Portfolio/_git/MPDIS-SDDPM_Scrum"

14.

Code Block
git push -u origin --all

...

info


Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@1293e
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ( "git" , "git-tfs" , "tfs" ) and type = "page" and space = "MAR"
labelsGit TFS Git-Tfs

...