Git 命令

1. 日常操作

每天都要用到的命令

$ git add .
$ git commit -m 'add firest'
$ git push
$ git pull

commit 时报错,运行下面的代码排除错误

$ npm run lint

2. 基本命令

简易的命令行入门教程:

Git 全局设置,平时我也没用过:

git config --global user.name "fanhl"
git config --global user.email "fanhl@gov.cn"

创建 git 仓库:

mkdir wukong-doc
cd wukong-doc
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin https://gitee.com/www/wukong-doc.git
git push -u origin master

按照上面的做法,每次 push 都要带上参数不方便,在实际情况,只用git push就可以了,但是要先 clone 下来才能,或者 origin 也设置成 master。

已有仓库?

cd existing_git_repo
git remote add origin https://gitee.com/www/wukong-doc.git
git push -u origin master