常用命令

- 初始化
Git init - 设置签名
git config user.name "cemon" - 设置签名邮箱
git config user.email "cemon_liu@126.com" - 设置全局
git config --global - 查看config 签名
git config --list - 查看状态
git status - 提交
git add 文件名git add .添加所有目录文件 commit 命令
git commit -m "更新内容"git commit -am可以跳过add命令 直接提交
- 回退版本
git reset HEAD^几个^ 就是退几个版本 - 移动或者重命名文件
git mv README README.MD - 查看日志文件
git log - 查看指定文件修改记录
git blame file
远程操作命令
- 生成SSH Key
$ ssh-keygen -t rsa -C "youremail@example.com"打开 id_rsa.pub,复制里面的 key。 - 查看远程连接
git remote -v - 添加远程仓库
git remote add origin [url] - 提交代码到远程
git push -u origin master - 取远程代码 并合并
git pull = git fetch git merge
分支的操作
- 创建分支
git branch newbranch - 查看各分支状况
git log --oneline --decorate - 查看分支交叉历史
git log --oneline --decorate --graph --all - 切换分支
git checkout testing - 合并分支
git checkout master git merge testing - 删除分支
git branch -d testing - 删除服务器分支 `git push origin --delete serve
评论(0)