第一步:fork 别人的仓库并设置同步
1.进入别的仓库地址,并点击fork
2.进入自己fork过的自己的仓库,在commandline git clone
git clone https://github.com/YOUR-USERNAME/Spoon-Knife
3.clone之后
$git clone https://github.com/YOUR-USERNAME/Spoon-Knife
Cloning into `Spoon-Knife`...
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (8/8), done.
remove: Total 10 (delta 1), reused 10 (delta 1)
Unpacking objects: 100% (10/10), done.
4.设置仓库同步更新
1.cd进入仓库目录 git remote -v ,显示所有的源
git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
2.将原作者的仓库地址复制之后,在终端敲
git remote add upstream https://github.com/octocat/Spoon-Knife.git
这样之后就把作者的git仓库作为你的一个远端仓库地址了
3.查看远端仓库
git remote -v
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
这样你就可以将自己的代码提交自己fork的目录下,然后再将作者新的提交,merge到自己的仓库,就保持了两个仓库同步了
pull request
新建一个分支用于提交自己对代码的改动
git branch testPull
修改你的代码 并提交和推送到远端
git commit -m "branch test"
git push --set-upstream origin testPull
网友评论