[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`发布于blog.csdn.net、转载请务必注明出处。
所有评论(0)