首页 > 其他 > 详细

git 常用命令

时间:2018-06-14 12:18:49      阅读:182      评论:0      收藏:0      [点我收藏+]
# 在当前目录新建一个Git代码库
$ git init 
# 下载一个项目和它的整个代码历史
$ git clone [url]
# 下载远程仓库的所有变动
$ git fetch [remote]
# 显示所有远程仓库
$ git remote -v

# 增加一个新的远程仓库,并命名
$ git remote add [shortname] [url]
# 添加当前目录的所有文件到暂存区
$ git add .
# 提交暂存区到仓库区
$ git commit -m [message]
# 合并指定分支到当前分支
$ git merge [branch]
# 取回远程仓库的变化,并与本地分支合并
$ git pull [remote] [branch]
# 上传本地指定分支到远程仓库
$ git push [remote] [branch] (--force)


# 列出所有本地分支
$ git branch
# 新建一个分支,但依然停留在当前分支
$ git branch [branch-name]
# 切换到指定分支,并更新工作区
$ git checkout [branch-name]
# 新建一个分支,并切换到该分支
$ git checkout -b [branch]
# 删除分支
$ git branch -d [branch-name]
# 删除远程分支
$ git push origin --delete [branch-name]
$ git branch -dr [remote/branch]

# 显示当前分支的版本历史
$ git log
# 显示当前分支的最近几次提交
$ git reflog
# 恢复暂存区的所有文件到工作区
$ git checkout .
# 重置当前分支的HEAD为指定commit,同时重置暂存区和工作区,与指定commit一致
$ git reset --hard [commit]

git 常用命令

原文:https://www.cnblogs.com/yangshifu/p/9182121.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!