用命令行向GitHub添加Project

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

1、首先在GitHub创建一个新的仓库,为了避免出错,不要用README license,gitignore 初始化仓库。这些可以稍后再添加。

用命令行向GitHub添加Project_第1张图片
2、打开本地电脑安装的Git Bash

用命令行向GitHub添加Project_第2张图片
3、将当前工作目录指向本地项目所在目录。

用命令行向GitHub添加Project_第3张图片
4、初始化本地目录,作为Git仓库

$ git init


5、添加文件到新的本地仓库。这是第一次提交阶段

$ git add .
# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.


6、提交文件

$ git commit -m "First commit"
# Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.


7、复制GitHub仓库快速设置页面的远程仓库URL

用命令行向GitHub添加Project_第4张图片
8、在命令提示符中,添加远程仓库URL

$ git remote add origin remote repository URL
# Sets the new remote
$ git remote -v
# Verifies the new remote URL


9、向GitHub推送本地仓库有改动的文件
 

$ git push origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin

 

转载于:https://my.oschina.net/benz001/blog/3059498

你可能感兴趣的:(用命令行向GitHub添加Project)