• 微信:WANCOME
  • 扫码加微信,提供专业咨询
  • 服务热线
  • 13215191218
    13027920428

  • 微信扫码访问本页
Git命令
Git必知必会命令

Git必知必会命令

基础
git init初始化一个仓库
git clone [git-url]克隆一个已存在的仓库
配置
git config --global user.name "Your Name"设置用户名
git config --global user.email "youremail.com"设置邮箱地址
暂存/提交
git add .暂存所有修改
git add [file_path]暂存一个特定的文件
git commit -m "Commit message"提交暂存的修改
查看修改
git status查看状态
git log查看提交日志
git diff比较修改的不同
管理分支
git branch列出所有分支
git branch [branch-name]创建一个新分支
git checkout [branch-name]切换到一个指定分支
git checkout -b [branch-name]创建并切换到一个新分支
git branch -d [branch-name]删除一个指定分支
远程仓库
git remote add [git-url]添加一个远程仓库
git remote -v列出所有远程仓库
git pull [remote-name] [branch-name]拉取一个远程分支到本地
git push [remote-name] [branch-name]Push本地修改到一个远程分支
取消修改
git reset --hard HEAD~1撤销最近的提交
git reset取消暂存的修改
git checkout -- [file-path]丢弃工作目录中的修改
合并
git merge [branch-name]合并指定的分支到当前分支
git rebase [branch-name]把当前分支的修改基于指定分支重新应用(变基)
标签
git tag [tag-name]在当前提交上创建一个tag标签