自己的代码提交到自己的原主分支
克隆下来以后进入文件夹
git add .
git commit -m "doing..."
git config --global user.email "xxxx@xxxx"
git config --global user.name "xxxx"
git push -u origin main
若有权限,则需要输入用户名和token
自己的代码提交到别人分支的方法:
(1) 克隆目标仓(别人的仓)
git clone https://github.com/target.git
(2)在别人的分支上创建新子分支your_new_branch做中介
git checkout -b your_new_brach origin/target_branch
(3)拉取自己分支上的代码
git pull https://github.com/mycode.git my_branch
此时若出现:自动合并失败,修正冲突然后提交修正的结果。
则可以用git rm删除冲突文件,或使用git add添加修改后的冲突文件,然后使用
git commit -m "xxx"
进行提交
然后
git pull https://github.com/mycode.git my_branch
再拉一下试试,若正常则出现如下提示
已经是最新的。
(4)切换到要提交的目标分支
git checkout target_branch
(5)合并
git merge --no-ff your_new_branch
(6)push
git push origin target_branch
此时若有权限问题,则需要对方的人给你此仓权限。