学习Pull request

我从我的导师Xing Fan指导和帮助,利用我的导师chunlong Li提供ChatGPT,在百度搜索,学习一些资料。以下很多内容都是我的导师Xing Fan做的。谢谢Xing Fan。考虑到隐私,不适合截图公开。

第一步:

打开Git Bash Here

如果空白文件夹的话,git init。

第二步:

远程仓库建立联系。

git clone <git repo url>

如果已经有了本地仓库,可以省略远程仓库建立联系。

扫描二维码关注公众号,回复: 17043720 查看本文章

第三步:

切换分支如下:

git checkout <your git branch name>

自己取的本地分支名

我学到了git checkout -b xxxxx,在本地上可以随意换分支名。


切换branch直接用git checkout <branch_name>就可以,加上-b是创建一个branch

创建新的分支如下:

git checkout -b <new-branch>

查看远程所有分支git branch -r。

第四步:

git add <文件名>

git commit -m "名字"

以下的内容,我没试过。

git stash

git pulll origin <远程分支名>

git stash pop

第五步:

确定需要拉的分支名

在Github的网页上确认一下

git fetch origin <远程分支>

拉取他人分支

git pull origin <git branch name you want to sync with>.

第六步:

调试,修改之后 ,git add <paths of files you want to commit>

第七步:

git commit -m "<commit info you want to attached to your commit>"

第八步:

git merge <远程分支名>

第九步:

git push(第一次需要设置远程branch,terminal里会有提示:git push --set-upstream origin <branch name>)

git push -u origin 分支名

就是一般流程是
1. clone到本地
2. 在本地创建自己的branch
3. 拉取main branch最新代码
4. 本地开发调试
5. commit & push 本地代码到远端
6. 用自己的branch发起pull request申请merge到main branch
7. 其他人code review结束 approve pr
8. merge到main branch

1. git clone <git repo url>
2. git checkout -b <your git branch name> (我把我的branch都放在xingfan这个folder下面,所以叫做xingfan/header,你可以放在你自己名字命名的文件夹下)
3. git pull origin <git branch name you want to sync with> 比如 git pull origin main,或者git pull origin xingfan/header
4. 调试,修改之后 git add <paths of files you want to commit>
5. git commit -m "<commit info you want to attached to your commit>"
6. git push (第一次需要设置远端branch,terminal里会有提示:git push --set-upstream origin <branch name>)

猜你喜欢

转载自blog.csdn.net/DXB2021/article/details/132166472