线上仓库有两个分支,一个主分支main, 一个luochuan分支


线下有一个luochuan分支,此时,线下分支还没有与线上分支关联


git branch , 查看本地当前分支 ,得到 luochuan,如果分支中没有内容,则不显示,

正确的作法是,

git add ./123.text 将内容加进去

git commit -m "第一次"


2,关联

    添加远程仓库地址

    git remote add origin https://github.com/XXXX.git  (写自己的地址)

    如果遇到 链接超时,

    就检查一下,

    git config --global --get http.proxy

    git config --global --get https.proxy

    如果没有内容输出,则说明没有设置

    git代理设置了没有,没有就设置一下

    

    git config --global http.proxy http://<proxy-url>:<proxy-port>

    git config --global https.proxy https://<proxy-url>:<proxy-port>


然后就,git pull 拉取线上仓库的东西到线下,与之合并

拉取时第一个错误即时,提示,没有指定仓库,

这个意思是,线下仓库与线上仓库建立链接对应关系

git branch --set-upstream-to=origin/luochuan luochuan


此时会遇到,冲突,因为线上分支是有内容的,这时要指定一下,处理合并的方式,错误提示里有指出

hint: You have divergent branches and need to specify how to reconcile them.

        你有不同的分支并需要特别指明怎么解决他们

hint: You can do so by running one of the following commands sometime before

        你可以在之前运行以下命令来解决

hint: your next pull:

hint: 

hint:   git config pull.rebase false  # merge 第一种

hint:   git config pull.rebase true   # rebase 第二种

hint:   git config pull.ff only       # fast-forward only 第三种

hint: 

hint: You can replace "git config" with "git config --global" to set a default

hint: preference for all repositories. You can also pass --rebase, --no-rebase,

hint: or --ff-only on the command line to override the configured default per

hint: invocation.


git config pull.rebase true 执行它


3,再次拉取, git pull --rebase , 拉取成功

4,git push