在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 (推送到遠程倉庫)
執(zhí)行第四部時候報錯
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的連接拴曲,執(zhí)行git branch --set-upstream master origin/master逗威,設置鏈接`
6. git branch --set-upstream master origin/master
然后再執(zhí)行 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