使用git 将自己的本地文件git到github上面的完整过程

1.  首先在github网站上新建一个仓库,复制仓库地址(HTTP形式或者SSH形式,后者利用SSH,在最后一步push 的时候可以不用输入用户名和密码)。

  

 

2.  在本地某个你想要的(文件夹)目录下,右击—“Git Bash Here”后在控制台上进行以下命令的执行操作:

1 $  git  clone  https://github.com/shenxiaolinZERO/160322T.git //将远程仓库克隆到本地
2 (或者 $  git  clone  git@github.com:shenxiaolinZERO/160322T.git)
3 $  git  init  //初始化本地仓库
4 $  git  add  . //添加该文件夹目录下的所有文件
5 $  git  commit  -m  “ my commit infomation”  //备注提交注释或者信息
6 $  git  remote add  origin  https://github.com/shenxiaolinZERO/160322T.git //首次才要
7 $  git  push  -u  origin  master  //第一次的时候需要加 –u,从第二次开始就不用了
8 
9  OK !

3.  文件夹更新了内容,第二次将变化的内容git 到github 上面去,要在第一次时一样的文件夹目录下(比如第一次是:C://Mac/Home/0)[ 或者下一级,要看到 master],鼠标右击—“Git Bash Here”后在控制台上进行以下命令的执行操作:

1 $  git  add  . //
2 $  git  commit  -m  “ my commit infomation”  //备注提交注释或者信息
3 $  git  push  origin  master  //注意第二次不用加 –u
4 
5  OK !

注意如果添加的文件过大,在最后一步会提示 :

fatal: The remote end hung up unexpectedly

建议先在本地建立自己的SSH密码对,然后将公钥上传到github就行了。 可参见:为Github 托管项目的访问添加SSH keys

原文地址:https://www.cnblogs.com/shenxiaolin/p/5308093.html