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

Git新手求助:如何将修改代码从原分支迁移至指定新分支

Fixing Git Push Issues for Your Personal Branch

Hey there! Let's get your code pushed to the right branch without any hassle. Since you're new to Git, I'll walk you through two reliable approaches—command line (great for troubleshooting) and fixing the GitHub Desktop workflow you tried earlier.

Command Line Steps (Quick & Reliable)

If you're comfortable with a terminal, this method gets the job done fast:

  • First, make sure all your local changes are committed. Run git status to check—if you see uncommitted files, run:
    git add .
    git commit -m "Describe your changes here (e.g., 'Add user profile UI updates')"
    
  • Next, add your personal repository as a new remote. Use this command with your actual repo address:
    git remote add personal https://my.company.com/13179069/WebApp.git
    
  • Finally, push your local DEV branch to your personal repository's DEV branch:
    git push personal DEV
    
    If you get a "non-fast-forward" error, it means the remote branch has changes you don't have—run git pull personal DEV to merge them first, then push again.

Fixing GitHub Desktop Issues

If you prefer the GUI, here's how to configure it to push to your personal branch:

  • Open GitHub Desktop and select your WebApp repository.
  • Go to the Repository menu > Repository Settings.
  • In the Remotes section, click Add. Name the remote something like personal, paste your repo URL (https://my.company.com/13179069/WebApp.git), then click Add Remote.
  • Back on the main screen, confirm you're on the DEV branch (check the top-left corner—if not, use the branch dropdown to switch to it).
  • Click the dropdown arrow next to the Push button (it might say "Push to origin" right now). Select your new personal remote, then choose to push to the DEV branch.
  • If you see a prompt about needing to pull changes first, follow the on-screen steps to merge any remote updates into your local code before pushing.

Pro Tip for Future Work

When you need to get the latest changes from the main DEV branch later, just run:

git pull origin DEV

(Assuming origin is the name of the main repository remote—this is the default when you first clone it.)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 06:32:14