通過idea工具將原生代碼新增到網路git伺服器上
阿新 • • 發佈:2019-02-11
一,工具
出現錯誤的主要原因是github中的README.md檔案不在原生代碼目錄中
輸入git命令:
git pull --rebase origin master
操作步驟:
D:\gitspaces\demo\aaa>git push origin master ! [rejected] master -> master (fetch first) 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. D:\gitspaces\demo\aaa >git pull --rebase origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
First, rewinding head to replay your work on top of it...
Applying: 新增aaa 目錄
Warning: Your console font probably doesn't support Unicode. If you experience s
trange characters in the output, consider switching to a TrueType font such as C
onsolas!
D:\gitspaces\demo\aaa>git push -u origin master
Counting objects: 50, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (41/41), done.
Writing objects: 100% (50/50), 10.93 KiB | 0 bytes/s, done.
Total 50 (delta 17), reused 0 (delta 0)
825d126..0ff4c7b master -> master
Branch master set up to track remote branch master from origin.
D:\gitspaces\demo\aaa>
備註:
方法/步驟
在使用git 對原始碼進行push到網路git上時可能會出錯,資訊如下
此時很多人會嘗試下面的命令把當前分支程式碼上傳到master分支上。
$ git push -u origin master
但依然沒能解決問題
出現錯誤的主要原因是網路git中的README.md檔案不在原生代碼目錄中
可以通過如下命令進行程式碼合併【注:pull=fetch+merge]
git pull --rebase origin master
執行上面程式碼後可以看到原生代碼庫中多了README.md檔案
idea、git 安裝、配置均不贅述。
二, 本地專案git提交
1.建立本地倉庫
2.程式碼提交到本地git(先add
後commit)
三,專案提交
window下cmd到專案所在目錄。如:D:\gitspaces\demo\aaa
需要提交到網路git中(如:開源中國):https://git.oschina.net/xxxxx/aaa.git
注:用https的方式連線,別用SSH的方式連線!
輸入git命令:
1.git remote add origin /aaa.git
2.git push origin master
輸入使用者名稱和密碼。
如果出現
出現錯誤的主要原因是github中的README.md檔案不在原生代碼目錄中
輸入git命令:
git pull --rebase origin master
操作步驟:
D:\gitspaces\demo\aaa>git push origin master ! [rejected] master -> master (fetch first) 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. D:\gitspaces\demo\aaa