GitHub基本提交操作

来源:互联网 发布:u盘检测工具 知乎 编辑:程序博客网 时间:2024/05/29 13:33

1.在网页版的GitHub下新建仓库
然后

git clone (你的仓库名git@github.com:xxx/xxx.git

2.在GIT bash终端使用 cd 命令切换进clone的目录
此时可以使用git status看下情况,当然,啥也木有

On branch masterInitial commitnothing to commit (create/copy files and use "git add" to track)

3.这里,初始化一下仓库

git init

4.然后把文件夹中你要添加的东西,使用

git add xxx

5.可以建一个readme.md,markdown格式的文件,使用touch命令

touch README.md

6.将文件加入暂存区,然后使用git commit,-m后的是提交信息,是对本次提交的概述

git commit -m "this is a demo,you can say whatever you'd like to say"

不加-m的话,会弹出一个vi编辑器界面,注意把要说的话在写进去,去除#即可,否则不生效
提交好了可以通过git log 看下日志

7.push
到上一步,GitHub上的仓库还木有被更新,此时需用push命令

git push

Done
坑:
如果clone到一个空仓库,开始不init的话,后面会提示你

*** 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: empty ident name (for <(NULL)>) not allowed

这时候可能即使你运行这两行了,也没反应。
解决方法是到你这个文件夹的目录,win的话打开隐藏的.git文件夹,config这个文件打开,加入

[user]name=yournameemail=youremail

就好了。。。

0 0