如何将本地文件利用git工具上传到github仓库中(超详细)

网址:https://github.com/

首先,打开github, 创建一个仓库用来存放项目
在这里插入图片描述
输入Repository name(仓库名称)和Description(描述)
Public(公共):互联网上的任何人都可以看到此存储库。您选择谁可以提交。
Private(私有的):您可以选择谁可以看到并且提交到此存储库

Initialize this repository with:
Skip this step if you’re importing an existing repository.

Add a README file
   This is where you can write a long description for your project. Learn more.
Add .gitignore
   Choose which files not to track from a list of templates. Learn more.
Choose a license
   A license tells others what they can and can't do with your code. Learn more.

这一部分是这个意思(可根据需要勾选)
在这里插入图片描述

最后再点击Create repository创建存储库

在这里插入图片描述
复制仓库链接
在这里插入图片描述
找到将要上传的文件目录
比如这里的project就是我要上传的文件
右键点击Git Bash Here
在这里插入图片描述

输入命令

git init

这条命令是初始化仓库,将这个目录变成git可以管理的仓库
在这里插入图片描述

git add .

这条命令是将文件添加到暂存区里面去,注意:后面有一个小**.**
在这里插入图片描述

git commit -m 'first project'

这条命令是将命令文件提交到仓库git commit -m '描述内容'

在这里插入图片描述

git remote add origin https://github.com/hanhanwanghahaha/Eating.git

关联git库,因为此时git还不知道要将我们的项目添加到哪里去,接下来就要执行命令:

git remote add origin+刚刚复制的远程仓库的地址

在这里插入图片描述

 git pull --rebase origin master

执行上面这条命令,将文件与远程仓库进行合并
在这里插入图片描述
最后输入命令

git push -u origin master

这条命令是将本地文件推送到github仓库中
在这里插入图片描述
接下来会出现如图所示
在这里插入图片描述
输入你的email和密码就可以啦

在这里插入图片描述
现在项目已经完成上传
我们可以刷新我们的Github
在这里插入图片描述
如此,项目成功上传啦在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/hanhanwanghaha/article/details/108377694