[Git & GitHub] 利用Git Bash进行第一次提交文件

转载:https://blog.csdn.net/dietime1943/article/details/72420042

利用Git Bash进行第一次提交文件

快下班的时候,MD群里有人问怎么向github上提交文件,下面进行简单的介绍:

(1) GitHub中创建一个工程

仓库的https地址:https://github.com/bluetata/blog.csdn.dietime1943.git

GitHub上创建仓库后生成的提示

Create a new repository on the command line :

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/bluetata/blog.csdn.dietime1943.git
git push -u origin master

Push an existing repository from the command line :

git remote add origin https://github.com/bluetata/blog.csdn.dietime1943.git
git push -u origin master

(2) 初始化git目录

$ cd D:/001_workspaces/098_Github
$ git init

如果不执行这条命令, 就会出现错误 :fatal: Not a git repository (or any of the parent directories): .git

(3) 追加文件到缓存

$ git add -A// 表示将所有的已跟踪的文件的修改与删除和新增的未跟踪的文件都添加到暂存区

(4) 进行commit提交

$ git commit -m "commit test"

如果第一次进行提交会出现如下提示信息:

bluetata@IBM012-PC06874UMINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)
$ git commit -m "commit test"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'bluetata@IBM012-PC06874U.(none)')

根据提示按照如下输入即可(输入完后会弹出github登录的pop提示框):

bluetata@IBM012-PC06874UMINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)
$ git config --global user.email "dietime1943@hotmail.com"

bluetata@IBM012-PC06874UMINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)
$ git config --global user.name "bluetata"

(5) Push到远程仓库(提交到github服务器中)

$ git push -u origin master

最后:附上完整的操作记录:

    bluetata@IBM012-PC06874U MINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)  
    $ ll  
    total 13  
    -rw-r--r-- 1 bluetata 197121 2263 Feb 17 11:03 'add user library to project in eclipse.md'  
    drwxr-xr-x 1 bluetata 197121    0 May 11 16:18  article/  
    drwxr-xr-x 1 bluetata 197121    0 Mar 29 22:10  interviews/  
    drwxr-xr-x 1 bluetata 197121    0 Mar 29 22:10  jsoup/  
    drwxr-xr-x 1 bluetata 197121    0 Mar 29 22:10  maven/  
    -rw-r--r-- 1 bluetata 197121   73 Mar 28 19:02  README.md  
    -rw-r--r-- 1 bluetata 197121 2154 Feb  8 10:06 'solution of tomcat 404.md'  
      
    bluetata@IBM012-PC06874U MINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)  
    $ git add -A  
      
    bluetata@IBM012-PC06874U MINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)  
    $ git commit -m "commit test"  
      
    *** Please tell me who you are.  
      
    Run  
      
      git config --global user.email "you@example.com"  
      git config --global user.name "Your Name"  
      
    to set your account's default identity.  
    Omit --global to set the identity only in this repository.  
      
    fatal: unable to auto-detect email address (got 'bluetata@IBM012-PC06874U.(none)')  
      
    bluetata@IBM012-PC06874U MINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)  
    $ git config --global user.email "dietime1943@hotmail.com"  
      
    bluetata@IBM012-PC06874U MINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)  
    $ git config --global user.name "bluetata"  
      
    bluetata@IBM012-PC06874U MINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)  
    $ git add -A  
      
    bluetata@IBM012-PC06874U MINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)  
    $ git commit -m "commit test"  
    [master f6d6241] commit test  
     6 files changed, 6 insertions(+), 96 deletions(-)  
     create mode 100644 .tags1  
     delete mode 100644 Jsoup01.html  
     delete mode 100644 Jsoup01.md  
     delete mode 100644 Jsoup02.md  
     create mode 100644 article/CSDN link problems.md  
     rename "maven/ \343\200\220\350\207\252\345\255\246maven\347\263\273\345\210\227\343\200\221\345\210\233\345\273\272simple project.md" => "maven/\343\200\220\350\207\252\345\255\246maven\347\263\273\345\210\227\343\200\221\345\210\233\345\273\272simple project.md" (100%)  
      
    bluetata@IBM012-PC06874U MINGW64 /d/001_workspaces/098_Github/blog.csdn.dietime1943 (master)  
    $ git push -u origin master  
    Counting objects: 6, done.  
    Delta compression using up to 4 threads.  
    Compressing objects: 100% (5/5), done.  
    Writing objects: 100% (6/6), 678 bytes | 0 bytes/s, done.  
    Total 6 (delta 3), reused 0 (delta 0)  
    remote: Resolving deltas: 100% (3/3), completed with 3 local objects.  
    To https://github.com/bluetata/blog.csdn.dietime1943.git  
       99590f3..f6d6241  master -> master  
    Branch master set up to track remote branch master from origin.  

 

注:本文原创由`bluetata`发布于blog.csdn.net、转载请务必注明出处。

posted @ 2018-06-09 10:19 Rest探路者 阅读( ...) 评论( ...) 编辑 收藏
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐