本地创建好的项目通过git提交到github

情况:本地项目已经创建好,但是在github上并没有项目。

1、创建项目文件夹,如:E:\test\demo

2、demo目录下有我们已经写好的文件,如:新建文本文档.txt

3、打开命令行,进入到demo目录,执行git init命令初始化目录

4、登录你的github,创建与项目名称一样的项目

5、打开命令行,在项目目录下执行:git pull --rebase 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.

这个错误是因为我们没有将我们本地的项目和github上的项目进行关联。

执行git remote add origin 你的项目地址

如刚才我们新建的项目地址:git remote add origin https://github.com/xishaoguo/demo.git

6、这时我们就将两个项目成功关联进来了,然后执行:

git pull --rebase origin 分支名    //将github上的项目更新到本地,如果不更新会报错

7、这时在我们本地的项目中就已经有了github项目里面的README.MD

然后执行:

git add .            //添加项目目录下的所有文件

git commit -m "随便写东西"             //提交的信息

git push -u origin master                   //开始提交

8、这时就已将我们本地里面的项目提交到了github,在github上就可以看到我们本地的:新建文本文档.txt  文件

猜你喜欢

转载自blog.csdn.net/xishaoguo/article/details/84792276
今日推荐