Git推送问题
為什么80%的碼農都做不了架構師?>>> ??
創建一個空的遠程庫之后怎樣開始工作?摘自碼云的提示
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添加文件時直接使用目錄即可,典型過程如下:
注意 git add 有兩個選項:
- -u, --update 更新修改和刪除的文件,但不會添加新文件
- -A, --all, --no-ignore-removal 添加,修改和刪除文件
二、無共同祖先時的推送
主要問題描述
fatal: refusing to merge unrelated histories
過程示例
要點
1. 如果沒有登錄網站手動創建遠程庫,那么本地庫是沒辦法推送的,錯誤如下:
# 試圖關聯遠程庫,但此時遠程庫尚未創建 git remote add origin git@gitee.com:wqli/Scheduler.git # 推送錯誤 git push -u origin master2. git pull發生分支關聯問題,按照提示操作即可
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倉庫refusing to merge unrelated histories
2. Git沒有共同祖先的兩個分支如何合并?
轉載于:https://my.oschina.net/wqli/blog/1542249
總結
- 上一篇: CentOS下安装protobuf
- 下一篇: Hadoop1.x之hdfs集群搭建