将git本地代码上传到github

前提条件:创建一个github账号,和下载git软件。

我自己使用的是windows

1.创建仓库

  在你想要上传的文件夹处右击空白,进入Git Bash Here

  或者用命令行(cmd)进到当前文件

  开始了,输入:git init

$ git init
Initialized empty Git repository in D:/code/前端练习/html5/.git/

 

2.选择文件

  单独选择:git add 文件名

  全部选择:git add .

  选择文件后可以用 git status查看文件状态

$ git add task1.html
---------------------------
$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   task1.html

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        1.html
        images/

 

3.提交到仓库

  命令:git commit -m "输入你备注的信息"

$ git commit -m "task1"
[master (root-commit) 6c8bc6b] task1
 1 file changed, 53 insertions(+)
 create mode 100644 task1.html

 

4.github上创建自己的Repository和复制链接

 

5.将本地git和github进行关联

$ git remote add origin https://github.com/q2500819/learning.git

 

6.上传

  上传前先:git pull origin master 

        

  若出现如上图中错误的主要原因是github中的README.md文件不在本地代码目录中

  那么我们可以:git pull --rebase origin master

$ git pull --rebase origin master
From https://github.com/q2500819/gitLearning
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: task1

  开始上传:git push -u origin master

$ git push -u origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 550 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/q2500819/gitLearning.git
   74d5743..5a5e12b  master -> master
Branch master set up to track remote branch master from origin.

 

 

  

 

转载于:https://www.cnblogs.com/webSpider/p/7233541.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值