GITHUB push code 2020年1月22日


 

 在和籽藤溝通之后,意識到了在GITHUB上記錄學習過程的重要性,為了記錄,也為了激勵堅持學習,之后會記錄每次學習過程。

 

目的:將Python 代碼push到github

 

push 成功的前提:

1. 初始化

2. 登錄

3. 加載要提交的文件

4. 關注遠程倉庫

5. 本地update到最新版本的項目

 

1. git push -u origin master

報錯:fatal: not a git repository (or any of the parent directories): .git

  = git init 

 

2. git push -u origin master

報錯:

*** Please tell me who you are.

Run

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address ()

= git config --global user.email "you@example.com"
= git config --global user.name "Your Name"

 

3.  git commit

報錯:

On branch master  Initial commit  Untracked files:  

nothing added to commit but untracked files present

解釋:

這是git沒有把提交的文件加載進來,但是把需要提交的文件都列出來了,只需要用git add XXX(文件名) 把需要提交的文件加上 ,然后git commit -m “xx”,再git push -u origin master重新提交就可以了

git add .是把你修改的東西添加到本地倉庫,Git提交過程有3個環節:本地 本地倉庫 遠程 ,只有把本地修改的東西,添加到 . 目錄下,表明你修改的東西,添加到了本地倉庫,本地倉庫如何和遠程倉庫建立關系?通過git push 推上去即可。

4. = git add alien_invasion

報錯:

error: 'alien_invasion/' does not have a commit checked out

= git add alien_invasion/

# 后面加上一個"/"即可,因為這是一個文件夾,要加上這個,其他的文件類似這樣,要說明類型。

 

5. git commit -m “alien_invasion”

= 完成

git commit 命令用來將本地暫存的修改提交到版本庫

 

6. git push -u origin master

報錯:

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

Please make sure you have the correct access rights
and the repository exists.

= git remote add origin “https://github.com/GEORGE1256/WAREHOUSE

原因:沒有關注遠程倉庫為origin

 

7. git push -u origin master

error:  ! [rejected]  master -> master (fetch first) error: failed to push some refs to 'https://github.com/GEORGE1256/WAREHOUSE' hint: Updates were rejected because the remote contains work that you do hint: not have locally.

= git pull -- reabse origin master

原因:

本地沒有update到最新版本的項目(git上有README.md文件沒下載下來)

本地直接push所以會出錯。

Enumerating: 列舉,枚舉

 

8. git push -u origin master

= ok


免責聲明!

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



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