git常用命令

cd /var/wwwroot/ 进入到网站根目录

git clone git@www.gitlab.com:root/aaa.git 拉取项目

git clone -b v2.8.1 https://git.oschina.net/oschina/android-app.git  拉取指定分支的代码

cd aaa 进入刚拉下来的项目目录

git branch -a 列出远程跟踪及本地分支

cat .git/HEAD 查看当前在哪个分支

git remote update  更新远程分支

git log 显示提交日志

git remote -v 查看本机git链接地址,根据这个地址得出git clone后面的链接

git remote update  更新远程分支

git checkout -b v/1.0 切换到这个分支

cat .git/HEAD 再次查看会看出变化

git push 更新远程分支

git pull origin v/1.0 从git库拉代码

git log 查看提交日志

git init 创建一个空的 Git 版本库或重新初始化一个已存在的版本库

git rebase 本地提交转移至更新后的上游分支中

git reset --hard 代码回滚

原文地址:https://www.cnblogs.com/leon2659/p/9342591.html