Azure Dev Ops: Undo Another User's Check-Out - azure-devops

I have Azure Dev Ops on premise which has a bunch of files that are checked out to a user on a machine that no longer exists. How can I undo the check-out of those files? I used to be able to do this through TFS Power Tools; but, there does not seem to be a tool that does the same thing for Azure Dev Ops. Is there a GIT command that will do this instead? How do I clean up Azure Dev Ops file check-outs?
Thank you in advance.

Git is a distributed version control system. Each developer has a copy of the source repository on their dev machine. So it's supposed you are using TFVC version control, there is no GIT commands to work with TFVC version control. Check Git & TFVC.
TFS Power Tools is a client extension which needs to be installed by each user locally for their own version of VS. If you want to use Power Tools, you can use VS/Team Explorer 2015 and earlier versions.
You could use tf undo command to delete Team Foundation version control pending changes in another user's workspace:
tf undo /workspace:OtherUserWorkspace;OtherUser $/TeamProject /recursive /collection:http://YourTFSServer:8080/tfs/YourCollection
Check following link for more details:
https://learn.microsoft.com/en-us/azure/devops/repos/tfvc/undo-changes-another-user-workspace?view=azure-devops

Related

Versioncontrol Repository in LAN Working copy in Web

I'm a newbie to version control systems, so please pardon my naiveté.
I want the repository to be on a networked path within our local area network (LAN) so that only local PC's can access it. The files that are edited should be on a server which is accessible via the internet.
Here is a diagram of what I mean:
The Internet server is an ordinary web server, but it offers WebDAV. Is there a version control system with which I can implement this setup?
Sure. What you are trying to achieve is called continuous deployment. You can set up a git server locally and then deploy the build artifacts to the WebDAV server (and/or another server) online.
⚠️ Note
I strongly recommend not running your version control software (VCS) locally, but rather, having a private repo on GitHub, GitLab, AWS CodeCommit, Azure DevOps, or BitBucket that you clone locally for work.
If you're committed (no pun intended) to local VCS, then you can use the set up below.
Continuous Deployment
You can create a local scheduled script to check for critical events (like approved merges on the main branch) of a target local repo. The script will then build the entire project and copy the build artifacts to the WebDAV.
There are almost an infinite number of ways to achieving this, so I will just link to some high level guides:
What is a Deployment pipeline?
Continuous Integration, Delivery, and Deployment
Windows Scheduled Tasks Azure DevOps Extension
scheduling continuous integration pipelines
The script can be as simple as copying files from the repo to the WebDAV; or, as complex as integrating, testing, building, and pushing build artifacts. The specifics (which scripting language[s] and how to schedule) depend on your OS more than anything. Here are instructions for Windows: https://blog.netwrix.com/2018/07/03/how-to-automate-powershell-scripts-with-task-scheduler/
git Server on LAN
Before you can deploy, you need a repo. The following are steps (using Windows 10) to get your local git server going. If you are using a Linux flavour, please adjust the instructions accordingly.
Create a folder where you want to create the Git Server.
Move into that folder, right click and select
 Git Bash Here
 option. This will open a bash command window in the current
folder.
Run the command
 git init anyname.git --bare
 to initialize Git bare repo without the working directory.
That’s it. You have successfully set up your Git server.
Connecting to Local Git Server
On your Git server, Go to control panel → Network And Sharing
Center > Change advanced sharing settings. Select
 
Turn on network discovery option
 and
 
Turn on file and printer sharing
 option.
On your Git server, Go to control panel → Windows Defender
Firewall → Advanced Settings → Inbound Rules. Enable
 
File and Printer Sharing (NB-Name-In) on private,public
profile and
 File and Printer Sharing (SMB-In)
 on private, public profile
 as shown below.
Go to the folder you have created Git Server, right click and select
 properties. Under
 sharing
 tab, click
 Share
 and add
 Everyone. Set the
 permission level
 as
 Read/Write.
Once the permissions are set, you will find a share path.
Go to second Windows PC and open Git terminal and type
 *git clone //GitServerName/PathToGitServerFolder.git *
 command.
You can create new files and folders as if you do on a normal Git
account.
That’s it. You have successfully created your own Git Server
and published on the network.
The simplest way that I can think of, though it take a little getting used to is GIT.
You can do this with local repo C:/some/path/to/repo and the upstream as E:/webdav/location or //link/to/webdav, and just push to upstream to update on the server.

How pull and push code in tfvc repo in Azure DevOps Organization?

I want to pull and push code from my local ubuntu machine to Azure Repo. I have used repo type tfvc. How can we perform this option from Linux machine?
How pull and push code in tfvc repo in Azure DevOps Organization?
First we need install the Visual Studio code on Linux.
Then, we could use the official Azure Repos which released by Microsoft.
It supports both TFVC and GIT version control type.
Create your TFVC workspace
With TFVC, the extension uses information about the current workspace
to determine how to connect to Team Services (or your Team Foundation
Server). Workspaces can be created using the Visual Studio IDE,
Eclipse or with the JetBrains IDEs (e.g, Android Studio, IntelliJ).
Note: At this time, you will need to have a local TFVC workspace already available on your local machine. More information about the
difference between the two types (and how to determine which one
you're using) can be found here.
You could also take a look at below videos to help get you started using the extension quickly:
TFVC Source Code Control for Visual Studio Code - This video shows
you how to set up the TFVC support on Windows and demonstrates much
of the functionality available for Team Foundation Version Control.
Above is for windows machine, if you are working on Linux, please take a look at this similar answer.
Hope this helps.
First Download Team Explorer Everywhere client - https://github.com/Microsoft/team-explorer-everywhere/releases
Then on Download Azure DevOps Services Plugin for IntelliJ IDEA --https://learn.microsoft.com/en-us/previous-versions/azure/devops/java/download-intellij-plug-in?view=azure-devops
Select get from Version Control
Then select your Azure TFVC DevOps Repo and then clone.select AzureDevops TFVC

Transfering the data from TFS to GitHUb

Our client is using TFS, and we are using GitHub
I would like to sync the projects from TFS to Github and from GItHub to TFS as batch process whenever the changes are made in either of them.
Can someone suggest easiest way of doing the same?
Thanks in advance
git-tfs which is a two-way bridge between TFS (Team Foundation Server) and git. However if you are using TFS2013 and later, you could use Git as the source control option. You could directly use normal git command such as git pull, git push.
For the command to the get from github, just use the normal git command such as: git-scm.com/docs/git-pull –
In Azure Devops or Github, both of them use git as their Version Control, so you can have both as separate git remotes.
You could just use some git commands to handle this. Which command please take a look at this blog.
For automated process, then you could use one CI build definition to achieve it. Detail steps as below:
Create a CI build with a PowerShell or cmd Task;
Select the VSTS git repo in Get sources step;
Enable continuous integration andspecify include all branches for
Branch filters:
Two samples for your reference:
How to synchronize VSTS and Github respositories when commits are made
Syncing my Github repo to MS Visual Studio Team Services
Besides, you could also use some 3-rd party extension to handle this, such as this one--Git Tools for Azure DevOps
Azure Pipelines Build and Release extension that helps you synchronise one Git Repository with another.
You can use this extension with any Git repository: TFS, GitHub, Azure DevOps, Git, etc.

How do I move an Azure DevOps project to a different organization?

I have got a project in an old org (from VSTS), that I want to move to my new one.
I can't see any options in Azure DevOps on migrating projects, or any information on the interwebs.
Anyone know how to do it?
If you just need to move repos, you can use the built in clone functions:
Go to the Azure Devops source repo -> Files
Click "Clone"
Choose "Generate Git Credentials"
Create the target repo in the target Azure DevOps
Choose "Import a repository"
Use the URL and credentials from Step 3
Done
This is not supported today. But this feature was planned to develop: make it possible to move a Team Project between Team Project Collections
If your Azure Devops project only tracks code versions using a single Git repo, hence no boards, user stories, tasks, pipelines, etc. then you can do the following:
Clone your project repo.
For example with Visual Studio.
You don't need to clone if you already have a local repo.
Destroy the association with the remote.
For this typically, you need to open a command line prompt in the folder that contains the .git database folder, most likely the solution folder of Visual Studio and type git remote rm origin.
Here is an example using git bash showing the content of the solution folder, including the .git database and the *.sln Visual Studio solution file:
Open the solution with Visual Studio if not already done.
It should now show that you have many commits waiting to be pushed to a remote. For illustration purpose, my toy project only have 8 commits in total.
Click the up arrow and choose your new remote, say a brand new Azure DevOps project, in the organization of your choice, then push.
You are now done cloning the project in another organization. If needed, then destroy the project in the old organization to complete the "move" operation.
There are 3 projects that I know of to achieve this.
A paid for option by Ops Hub -
OpsHub Visual Studio Migration Utility
An open source tool that requires making changes to the work item process template - Azure DevOps Migration tools
An lastly an Unofficial but still written by Microsoft tool to create Azure DevOps project templates - Azure DevOps Demo Generator & extractor tool
With the last one (the Demo Generator) you extract the project as a template, then apply it to the new organisation. As it is a tool for demo's there is no support provided and in my experience it works for simple projects but falls over on anything complex.
Expanding on others' answers, this post regards Pipelines.
Azure DevOps API
Migrating nearly all aspects of a project across organizations is doable, but it is a lot of manual work using the Azure DevOps API. The link below shows you all the end points, variables, etc. From there you'll probably want to write a Power Shell script and do a couple test runs to a dummy Organization.
https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-6.1&viewFallbackFrom=azure-devops-rest-6.0
In App options
If you avoid the API, there is no way to migrate pipelines that preserve build or release history, but you can preserve your configurations and processes by going into your Pipelines and selecting View YAML. From here you can either take this away as notes to recreate the GUI steps in your new org/project location, or actually adopt the YAML standard in your git repository.
I do not believe there is a way to migrate pipeline variables outside of the API. However, you can move the variables to Azure Key Vault and change your pipeline settings (YAML) to reference values from key vault. This is not a large amount of effort and is a nice process improvement.
Lastly, if you have any locally installed pipeline agents for releases, you will need to run the Power Shell script for your new organization on the boxes. Very simple 5m step, but right now the Agent Pools are not sharable across organization.
As #Frederic mentioned in his answer, we can actually easily do it with Visual Studio. I have done this without Visual Studio. The steps involved are below.
Add a User to Both Organization
Configure SSH Key
Update the SSH Key in Source DevOps and Clone the Repository
Check out all the Branches and Tags
Update the SSH Key in the Destination DevOps
Remove Old and Add New Origin
Push all the branches
The commands and detailed explanations can be found here.
BTW, if you need to change the entire Devops Organization tied to your personal Tenant (E.g. VS Enterprise Subscription) and move it to new Tenant, you can change the AAD and point it to the new one e.g. your EA Tenant on Azure commercial cloud.
Before you switch your organization directory, make sure the following statements are true:
You're in the Project Collection Administrator group for the
organization.
You're a member or a guest in the source Azure AD and a
member in the destination Azure AD
You have 100 or fewer users in
your source organization. Otherwise you will have to open a support ticket.
You may have to add the users back in destination org if they do not exist becuase they will loose access the moment you switch the AAD.
you could just download as a zip file and then download it to the destination repo

Migrate TFVC repository from one VSTS instance to another VSTS instance

I need to move, or copy, a TFVC (Team Foundation Version Control) repository from one instance of VSTS (e.g.: source.visualstudio.com) to another instance of VSTS (e.g.: destination.visualstudio.com).
I thought this would fairly straightforward, but I can only find information in regards to TFS (Team Foundation Server), not VSTS (Visual Studio Team Services). Or samples that convert to a Git repository, while I need to go from TFVC to TFVC.
I am not interested in migrating Work Items at this time, just the source code and its history.
No built-in tool to do it, there is a similar user voice: make it possible to move a Team Project between Team Project Collections
Regarding 3rd tool, you can try it with OpsHub Visual Studio Online Migration Utility.
On the other hand, you may change account owner of VSTS if just need to change owner.