git ------ 將本地項目推送到遠程空倉庫

番外:基礎配置

//1.配置全局的git倉庫的 用戶名 和 郵箱

git config --global user.name '倉庫的賬號名'

git config --global user.email '綁定的郵箱'

本地SSH配置與關聯(lián):https://mp-new.csdn.net/mp_blog/creation/editor/90054236



第一步:建立遠程倉庫(碼云晃择、GitHub等)


第二步:進入到對應的項目文件夾根目錄中:

git init? //生成.git文件


3断部、將本地和遠程廠庫關聯(lián)起來

git remote add origin 遠程倉庫地址

4、將本地代碼推送到庫上

git add .

git commit -m '提交信息' -n

git push -u origin master? //第一次初始化倉庫時:-u 之后不用

5.在第四步時可能會報錯:

To https://gitee.com/all-ko/react.git

! [rejected]? ? ? ? master -> master (fetch first)

error: failed to push some refs to 'https://gitee.com/all-ko/react.git'

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.

原因:是因為github中的README.md文件不在本地代碼目錄中俐填,可以通過如下命令進行代碼合并

git pull --rebase origin master

//之后重復第四步最后的命令:

git push -u origin master?

出現(xiàn)這樣的代碼,即為拉取readme成功:

$ git pull --rebase origin master

warning: no common commits

remote: Enumerating objects: 4, done.

remote: Counting objects: 100% (4/4), done.

remote: Compressing objects: 100% (4/4), done.

remote: Total 4 (delta 0), reused 0 (delta 0)

Unpacking objects: 100% (4/4), done.

From https://gitee.com/all-ko/react

* branch? ? ? ? ? ? master? ? -> FETCH_HEAD

* [new branch]? ? ? master? ? -> origin/master

First, rewinding head to replay your work on top of it...

Applying: 首次提交

接著運行:

git push -u origin master?

出現(xiàn)這樣的代碼俊嗽,本地項目推到遠程即告一段落^_^:

$ git push -u origin master

Enumerating objects: 17, done.

Counting objects: 100% (17/17), done.

Delta compression using up to 8 threads

Compressing objects: 100% (14/14), done.

Writing objects: 100% (16/16), 74.71 KiB | 1.36 MiB/s, done.

Total 16 (delta 0), reused 0 (delta 0)

fatal: the remote end hung up unexpectedly

fatal: the remote end hung up unexpectedly

6.最后運行代碼:

git push origin master //注意此刻推得分支即為想要將文件放的分支


另外::::

上面報錯:

git push --set-upstream origin master

Administrator@WIN-QTM6B4FMB6V MINGW64 /d/前端項目/webstromfiles/huaanwares (master)

$ git push --set-upstream origin master

To https://gitee.com/all-ko/huaan_statistical_software.git

! [rejected]? ? ? ? master -> master (fetch first)

error: failed to push some refs to 'https://gitee.com/all-ko/huaan_statistical_software.git'

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.

當你確定倉庫里面內(nèi)容不用時雾家,可強制推送:

?git push --set-upstream origin master -f

Administrator@WIN-QTM6B4FMB6V MINGW64 /d/前端項目/webstromfiles/huaanwares (master)

$ git push --set-upstream origin master -f

Enumerating objects: 69, done.

Counting objects: 100% (69/69), done.

Delta compression using up to 4 threads

Compressing objects: 100% (59/59), done.

Writing objects: 100% (69/69), 405.77 KiB | 7.38 MiB/s, done.

Total 69 (delta 0), reused 0 (delta 0)

remote: Powered by GITEE.COM [GNK-3.8]

To https://gitee.com/all-ko/huaan_statistical_software.git

+ ef6516a...4b29d58 master -> master (forced update)

Branch 'master' set up to track remote branch 'master' from 'origin'.


————————————————

版權聲明:本文為CSDN博主「絕世唐門三哥」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權協(xié)議绍豁,轉(zhuǎn)載請附上原文出處鏈接及本聲明芯咧。

原文鏈接:https://blog.csdn.net/COCOLI_BK/article/details/98730007

?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市竹揍,隨后出現(xiàn)的幾起案子敬飒,更是在濱河造成了極大的恐慌,老刑警劉巖芬位,帶你破解...
    沈念sama閱讀 221,273評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件无拗,死亡現(xiàn)場離奇詭異,居然都是意外死亡昧碉,警方通過查閱死者的電腦和手機英染,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,349評論 3 398
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來被饿,“玉大人四康,你說我怎么就攤上這事∠廖眨” “怎么了闪金?”我有些...
    開封第一講書人閱讀 167,709評論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長哥牍。 經(jīng)常有香客問我毕泌,道長,這世上最難降的妖魔是什么嗅辣? 我笑而不...
    開封第一講書人閱讀 59,520評論 1 296
  • 正文 為了忘掉前任撼泛,我火速辦了婚禮,結果婚禮上澡谭,老公的妹妹穿的比我還像新娘愿题。我一直安慰自己,他們只是感情好蛙奖,可當我...
    茶點故事閱讀 68,515評論 6 397
  • 文/花漫 我一把揭開白布潘酗。 她就那樣靜靜地躺著,像睡著了一般雁仲。 火紅的嫁衣襯著肌膚如雪仔夺。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 52,158評論 1 308
  • 那天攒砖,我揣著相機與錄音缸兔,去河邊找鬼日裙。 笑死,一個胖子當著我的面吹牛惰蜜,可吹牛的內(nèi)容都是我干的昂拂。 我是一名探鬼主播,決...
    沈念sama閱讀 40,755評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼抛猖,長吁一口氣:“原來是場噩夢啊……” “哼格侯!你這毒婦竟也來了?” 一聲冷哼從身側響起财著,我...
    開封第一講書人閱讀 39,660評論 0 276
  • 序言:老撾萬榮一對情侶失蹤联四,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后瓢宦,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體碎连,經(jīng)...
    沈念sama閱讀 46,203評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡灰羽,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,287評論 3 340
  • 正文 我和宋清朗相戀三年驮履,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片廉嚼。...
    茶點故事閱讀 40,427評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡玫镐,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出怠噪,到底是詐尸還是另有隱情恐似,我是刑警寧澤,帶...
    沈念sama閱讀 36,122評論 5 349
  • 正文 年R本政府宣布傍念,位于F島的核電站矫夷,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏憋槐。R本人自食惡果不足惜双藕,卻給世界環(huán)境...
    茶點故事閱讀 41,801評論 3 333
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望阳仔。 院中可真熱鬧忧陪,春花似錦、人聲如沸近范。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,272評論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽评矩。三九已至叶堆,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間斥杜,已是汗流浹背虱颗。 一陣腳步聲響...
    開封第一講書人閱讀 33,393評論 1 272
  • 我被黑心中介騙來泰國打工俯萌, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人上枕。 一個月前我還...
    沈念sama閱讀 48,808評論 3 376
  • 正文 我出身青樓咐熙,卻偏偏與公主長得像,于是被迫代替她去往敵國和親辨萍。 傳聞我的和親對象是個殘疾皇子棋恼,可洞房花燭夜當晚...
    茶點故事閱讀 45,440評論 2 359

推薦閱讀更多精彩內(nèi)容