利用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 "[email protected]"
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 "[email protected]"
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 "[email protected]"
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 "[email protected]"
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、转载请务必注明出处。