git

好使的教程 --> 猴子都能懂的 git 入门open in new window

常用命令

revert

# 回退一个commit
git revert commit号

# 回退多个连续的commit (后面的,前面的]
git revert 后面的...前面的

添加远程仓库并取别名

git remote add upstream xxxxxx(上游仓库地址)

基于远程分支新建一个分支并切换过去

git checkout upstream/dev -b xxxx(分支名)

stash

# 暂存现在的内容
git stash [save '描述']
# 查看所有的暂存
git stash list
# 清空所有的暂存
git stash clear
# 删除某一个暂存,默认删除 stash@{0}
git stash drop [stash@{某一个序号}]
# 恢复某一个暂存并删掉它,默认恢复 stash@{0}
git stash pop [stash@{某一个序号}]
# 同上恢复,但是不删掉它
git stash apply [stash@{某一个序号}]

clone

git clone 加 --single-branch 是下载单个分支, --depth=1 是下载单个 commit 这俩配置项可以提高拉取代码的速度

 git clone --depth=1 --single-branch git @github.com:ant-design/ant-design.git

设置命令别名

# git lg
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

报错

LF will be replaced by CRLF the next time Git touches it

git config --global core.autocrlf false
Last Updated: