码迷,mamicode.com
首页 > 其他好文 > 详细

git 常用命令

时间:2018-06-14 14:28:55      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:文件   常用   切换   显示   force   init   let   mit   git clone   

# 在当前目录新建一个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 常用命令

标签:文件   常用   切换   显示   force   init   let   mit   git clone   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!