You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

咨询将本地Visual Studio Code项目上传至Azure DevOps新Git仓库的步骤

Push Local VS Code Git Project to a New Azure DevOps Repository

Got it, let's break down the step-by-step process to push your local project (already using Git in VS Code) to a brand new Azure DevOps repo—since most guides focus on pulling existing code, this reverse workflow is exactly what you need.

Step 1: Create an Empty Repository in Azure DevOps

First, set up your target repo in Azure DevOps:

  • Log into your Azure DevOps organization and navigate to the project where you want to host the repo (or create a new project if needed).
  • Go to the Repos section, then click New repository.
  • Name your repo, select Empty under "Initialize repository with a README or gitignore" (we'll use your local files instead), then click Create.
  • Copy the repo's URL (either HTTPS or SSH) from the "Clone" dropdown—you'll need this later.

Step 2: Push from Local Git (Command Line)

If you prefer using the terminal in VS Code:

  1. Open the terminal in VS Code (Ctrl+` or View > Terminal).
  2. If your local project isn't already initialized with Git (though you said you're using Git, just in case):
    git init
    
  3. Stage all your local files:
    git add .
    
  4. Make your initial commit:
    git commit -m "Initial commit: Push local project to Azure DevOps"
    
  5. Link your local repo to the Azure DevOps remote:
    git remote add origin <PASTE YOUR AZURE DEVOPS REPO URL HERE>
    
  6. Push your code to the remote repo (set the upstream branch so future pushes are simpler):
    git push -u origin main
    
    Note: If your local main branch is named master instead, replace main with master.

Step 3: Push Using VS Code's GUI (No Command Line Needed)

If you'd rather use VS Code's built-in Git tools:

  • Open your project in VS Code, then click the Source Control icon in the left sidebar (Ctrl+Shift+G).
  • If your project isn't initialized, click Initialize Repository at the top of the Source Control panel.
  • Stage all files by clicking the + icon next to "Changes".
  • Enter a commit message (e.g., "Initial commit") in the text box, then click the checkmark icon to commit.
  • Click the ellipsis (...) menu in the Source Control panel, select Remote > Add Remote.
  • Paste your Azure DevOps repo URL, name the remote origin, then click Add Remote.
  • Click the Push icon (arrow pointing up) in the Source Control panel. Select your branch (usually main or master) when prompted, and confirm the push.

Important Notes for Authentication

  • If you're using HTTPS, VS Code will prompt you for authentication. Use your Azure DevOps username and a Personal Access Token (PAT) (not your regular password). To create a PAT:
    1. In Azure DevOps, click your profile icon in the top right > Personal access tokens.
    2. Click New Token, give it a name, select the Code (Read & Write) scope, then click Create. Copy the token—you won't see it again.
  • For SSH, make sure your SSH public key is added to your Azure DevOps account settings.

Let me know if you run into any issues with branch naming, authentication, or anything else—I’m here to help!

内容的提问来源于stack exchange,提问作者Sam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 09:04:25