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 "[email protected]"
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 "[email protected]"
= 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

猜你喜欢

转载自www.cnblogs.com/George19950505/p/12229338.html