Git推送问题
為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??
創(chuàng)建一個(gè)空的遠(yuǎn)程庫(kù)之后怎樣開始工作?摘自碼云的提示
Git global settings:
git config --global user.name "username" git config --global user.email "your_email"Create git repository:
mkdir SomeLibrary cd SomeLibrary git init touch README.md git add README.md git commit -m "first commit" # HTTPS連接方式 git remote add origin https://gitee.com/username/SomeLibrary.git # SSH連接方式 git remote add origin git@gitee.com:username/SomeLibrary.git git push -u origin masterExisting project?
cd existing_git_repo git remote add origin https://gitee.com/username/SomeLibrary.git git push -u origin master一、推送目錄
如果想要推送目錄及子目錄中的所有文件,在使用git add添加文件時(shí)直接使用目錄即可,典型過程如下:
注意 git add 有兩個(gè)選項(xiàng):
- -u, --update 更新修改和刪除的文件,但不會(huì)添加新文件
- -A, --all, --no-ignore-removal 添加,修改和刪除文件
二、無共同祖先時(shí)的推送
主要問題描述
fatal: refusing to merge unrelated histories
過程示例
要點(diǎn)
1. 如果沒有登錄網(wǎng)站手動(dòng)創(chuàng)建遠(yuǎn)程庫(kù),那么本地庫(kù)是沒辦法推送的,錯(cuò)誤如下:
# 試圖關(guān)聯(lián)遠(yuǎn)程庫(kù),但此時(shí)遠(yuǎn)程庫(kù)尚未創(chuàng)建 git remote add origin git@gitee.com:wqli/Scheduler.git # 推送錯(cuò)誤 git push -u origin master2. git pull發(fā)生分支關(guān)聯(lián)問題,按照提示操作即可
There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details.git pull <remote> <branch>If you wish to set tracking information for this branch you can do so with:git branch --set-upstream-to=origin/<branch> master3. 無共同祖先問題,提示信息如下:
fatal: refusing to merge unrelated histories解決辦法
git pull --allow-unrelated-histories參考
1. git無法pull倉(cāng)庫(kù)refusing to merge unrelated histories
2. Git沒有共同祖先的兩個(gè)分支如何合并?
轉(zhuǎn)載于:https://my.oschina.net/wqli/blog/1542249
總結(jié)
- 上一篇: CentOS下安装protobuf
- 下一篇: Hadoop1.x之hdfs集群搭建