Git Bash上傳文件


今天通過Git Bash上傳了一個項目(之前是通過Github Desk上傳的),操作命令如下:

在目錄下shift+右鍵打開Git Bash

1.git init

2.git add *.py

3.git commit -m 'first'

4.然后在Github上新建一個倉庫add repository,輸入倉庫名和描述

5.遠程關聯倉庫,git remote add origin git@github.com:hyqyoung(用戶名)/yylc_jdpm(倉庫名).git

6.開始上傳文件git push -u origin master

如果第六步遇到問題:

fatal: 'orign' does not appear to be a git repository
fatal: Could not read from remote repository.

則先刪除關聯:git remote rm origin

然后再執行第五、六步,要注意的是這里命令不要用上下鍵去調用,可能不會更新原來的操作,需要手敲

2018.5.4

今天在上傳代碼過程中,最后一步push的時候報了如下錯誤:

To github.com:hyqyoung/yylc_jdpm.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:hyqyoung/yylc_jdpm.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因是之前在GitHub的倉庫里新建了一個README的文件,沒有pull到本地。

所以在Github的遠程倉庫里做了一些變化的話,要及時pull到本地,代碼:

git pull origin master

然后再進行1到6的步驟上傳代碼就可以了,

但是我原來做了一步不恰當的操作,那就是

git push -u origin master -f 

強制執行,導致原來的遠程倉庫里的東西全部被替換掉了,所以切記這種操作是不可取的,並且盡量在本地做出一些修改,然后再push到GitHub上

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM