Git的配置和初级使用
Git的配置和初级使用
- 下载安装Git之后,先把仓库下载下来
git clone https://github.com/rsa2063/rsa2063.github.io
- 在下载下来的文件夹中右键Git Bash Here,当然也有一个Git GUI Here,但是你知道的,有zb需求,还是用命令行吧
- 打开命令行后
git status
,查看仓库状态,查看仓库是否有未提交的文件,没有的话会显示clean
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
- 修改或者新增文件后,再调用
git status
,untracked files即为还没有添加到仓库的文件
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: index2.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
post/2017030401.md
no changes added to commit (use "git add" and/or "git commit -a")
- 添加更改到仓库
git add .
,.
表示添加当前文件夹下的所有文件,当然也可以指定文件名 使用默认设置的话,在windows下会有如下警告
warning: LF will be replaced by CRLF in index2.md.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in post/2017030401.md.
The file will have its original line endings in your working directory.
输入git config --global core.autocrlf false
即可(windows和unix的换行符不一样导致,具体不太清楚)
- 提交到仓库,第一次使用时必须设置邮箱用户名,依照提示设置即可,可随意设置,主要作用好像就是在log里显示提交人,提交时的附加信息是必须的不能为空
$ git commit -m "add 2017030401 about wikizh"
*** 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: empty ident name (for <(NULL)>) not allowed
- 提交到远程仓库
git push
,执行后会弹出界面,输入github的用户名密码即可 - 总结一下所谓初级使用就是只使用如下几句命令
git status
git add .
git commit -m "add 2017030401 about wikizh"
git push
git pull
git clone https://github.com/rsa2063/rsa2063.github.io --这个不太常用
ps:markdown使用```代码块的时候上下最好空一行,否则可能显示会有问题
reference
Updated: 2022-12-10 21:21
Created: 2017-03-04 02:33