Git Summary

263 阅读1分钟

Git Command Lines

commit操作

1. 回退commit

使用场景:不小心commit了一个不应该commit的修改,但是还没有push,想撤销该commit。

  • 只回退提交点(不清除本地的修改 - 常用

git reset

  • 既回退提交点,又清除更改(慎重使用

git reset --hard

branch操作

创建分支

将远程git仓库里的指定分支拉取到本地(本地不存在的分支)

git checkout -b 本地分支名 origin/远程分支名

将本地分支push到远程

git push origin eastist/dev/screenshare

track分支到远程(跟踪远程分支,方便git pull等操作)

git branch --set-upstream-to origin/远程分支名

删除分支

  • 删除本地分支

git branch -d 分支名

  • 删除远程分支

git push origin –-delete 分支名

查看Config(Global配置)

查看当前用户(global)配置:git config --global --list ,举例output >>>

user.name=xxname123
user.email=xxname123@qq.cn
http.version=HTTP/1.1

Git Common Errors

git分支名一直rebasing

直接删除当前目录下的.git/rebase-apply(rebase-apply是目录)

rm -rf .git/rebase-apply

git可视化工具

  • (1)github桌面版
  • (2)AS中使用git