如何将Visual Studio在研项目版本推为VSTS Git分支?
Hey there! You’re totally right to avoid copy-pasting files—that’s messy and error-prone. Here’s a clean, Git-native way to get your in-progress work into a dedicated VSTS branch:
Step 1: Set up Git in your in-progress project folder
First, open a command prompt (or Git Bash) and navigate to the network drive folder where your latest work lives:
cd "Z:/Path/To/Your/In-Progress/Project"
If this folder doesn’t already have a Git repo initialized, run:
git init
Step 2: Link to your VSTS repository
Connect this local repo to your existing VSTS repo (the same one where you pushed the MAIN branch):
git remote add origin https://your-vsts-account.visualstudio.com/YourProject/_git/YourRepo
(Replace the URL with the actual clone URL of your VSTS repo—you can grab this directly from the VSTS repo page.)
Step 3: Create and switch to a new branch
Make a dedicated branch for your in-progress work (name it something descriptive, like dev/latest-in-progress or feature/new-feature-wip):
git checkout -b dev/latest-in-progress
Step 4: Stage and commit your work
First, add a .gitignore file to exclude unnecessary files (like bin/, obj/, or local config files) so they don’t bloat your VSTS repo. Once that’s set up, stage all your project files:
git add .
Commit the changes with a clear, informative message:
git commit -m "Push latest in-progress version: Added X feature, updated Y module"
Step 5: Push the branch to VSTS
Finally, send the new branch up to your VSTS repo:
git push origin dev/latest-in-progress
Bonus: Alternative workflow (if you don’t want Git in the network folder)
If you’d prefer not to keep a Git repo directly on the network drive, you can:
- Clone your VSTS MAIN branch to a local folder on your machine:
git clone https://your-vsts-account.visualstudio.com/YourProject/_git/YourRepo - Create and switch to a new branch locally:
cd YourRepo git checkout -b dev/latest-in-progress - Copy all your in-progress files from the network drive into this local repo folder (overwriting existing files as needed).
- Stage, commit, and push the changes just like in steps 4-5 above.
Either way, you’ll end up with a clean branch in VSTS containing your latest work—no copy-pasting chaos required!
内容的提问来源于stack exchange,提问作者CyborgHobbit

