在git bash下
1. mkdir project
2. cd project
3. git init (初始化仓库)
把 本地仓库项目 推送到 远程仓库
1. git add . (将当前目录下的文件加入到仓库)
2. git commit -m '描述'
3. git remote add origin git_address(远程git地址)
4. git push -u origin master (推送到远程仓库)
执行第四部时候报错
To https://git.coding.net/
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://git.coding.net/'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
报错因为远程仓库与本地仓库文件不一致,使用git pull拉下远程仓库代码到本地
5. git pull
接着又报如下错误:
warning: no common commits
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From https://git.coding.net/solent/xingzuo
* [new branch] master -> origin/master
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> master
报错原因: 是没有指定本地master和远程origin/master的连接,执行git branch --set-upstream master origin/master,设置链接`
6. git branch --set-upstream master origin/master
然后再执行 git pull
7. git pull
fatal: refusing to merge unrelated histories
又报错,,
8. git pull origin master --allow-unrelated-histories
shift + : wq 退出来
From https://git.coding.net/
* branch master -> FETCH_HEAD
Merge made by the 'recursive' strategy.
LICENSE | 191 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
README.md | 1 +
2 files changed, 192 insertions(+)
create mode 100644 LICENSE
create mode 100644 README.md
9. git push -u origin master
Counting objects: 1850, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1824/1824), done.
Writing objects: 100% (1850/1850), 10.49 MiB | 29.00 KiB/s, done.
Total 1850 (delta 375), reused 0 (delta 0)
To https://git.coding.net/
644871f..fe8a07c master -> master
Branch master set up to track remote branch master from origin.
提示出错信息 : fatal:remote origin already exists。
1. git remote rm origin
2. git remote rm origin https://git.coding.net/
提示出错信息 :usage: git remote remove <name>
1. git remote -v
<name> https://git.coding.net/
git remote rm <name>
git push -u origin master
网友评论