GIT Clone operation for Visual Studio Online(VSO) and Team Foundation Server(TFS) On Premise
Deepak Kumar Mishra, Support Engineer, brings to us the walkthrough below explaining the basic steps one has to perform for GIT Cloning operations for VSO as well as TFS-ON premise.
Following steps needs to be followed in order to perform the GIT clone operation successfully. Hope this would be helpful.
GIT clone Operation for VSO:
1. Create a Git team project in VSO
2. Create a folder (git workspace) in the client machine from git bash terminal (e.g. mkdir TestGIT)
3. cd to the TestGIT folder
4. Initialize git in to that folder by executing the command : git init
5.Then we need to add the remote repository to git by executing the command: git remote add origin <xyz.com/abc>
This will make sure that git identifies the remote vso repository when we start performing git operations, in a way it creates a mapping between the client and remote repository in VSO.
6. Then perform a git clone operation by using the following command:
git clone https://xxxx.visualstudio.com/DefaultCollection/_git/TestGIT
Note: This command will get all the latest files in VSO in to the folder on the client machine. We need to provide the correct URL here otherwise the operation will fail. You will get the correct URL from the git team project in VSO. Please find the following self-explanatory screenshot :
There is one more tricky part in the authentication specifically for VSO. We need to configure alternate credentials in this case which is mandatory here and will only result in successful authentication.
You need to enable Alternate Authentication Credentials if you want to use other Git clients outside of Visual Studio.
To set up alternate credentials iin VS Online, click on your name on the top right -> My Profile ->Credentials.
Edit: Add more details about this from VS Online (taken from the alternate credentials screen)...
ALTERNATE AUTHENTICATION CREDENTIALS
Some applications that work outside the browser (including Team Explorer Everywhere command line client and the git-tf utility) require basic authentication credentials. Other applications do not properly handle using an e-mail address for the user name during authentication.
To work with these applications, you need to enable alternate credentials, set a password, and optionally set a secondary user name not in the form of an e-mail address. Please note that alternate credentials cannot be used to sign in to the service from a web browser or outside of these applications.
7.Once git clone is successful, we can add files(optional) to git in client machine using the command: git add .
8.Then we can commit the files to git using the command : git commit –m “enter a meaningful message”
9.Finally we need to push all the changes in to the VSO repository from client machine by executing the command: git push -u origin —all
GIT clone Operation for TFS-On premise:
The Git clone operation for TFS-On premises also follows the same steps as mentioned above in a sequence. Steps are mentioned again below:
1.Create a Git team project in TFS.
2.create a folder in client machine and then cd to the folder in git bash terminal
3.Initialize git in to that folder
4.Add remote repository to git using git remote command
5.Then perform git clone operation
6.Then we can do a git add operation to add new files to git
7.Next is git Commit to commit all the changes in local client machine.
8.Finally we can do a git push to the remote tfs server.
Written by: Deepak Kumar Mishra, Support Engineer
Reviewed by: Nitish Nagpal, Support Escalation Engineer and Trevor Hancock, Senior Escalation Engineer