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

git常用操作

时间:2016-05-27 22:06:44      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:git常用操作

git一般的流程是



1 克隆一个git仓库的开发项目

git clone <git url>

2 在该目录下苍创建文件,创建文件后要add commit的常用操作

git add <youfile>
git add .

git commit -m "提示标记信息"


3 要查看状态

git status
git log -p -2  # 查看最近两次详细修改内容的diff
git remote -v


4 发现不对要撤销

git checkout <your file>
git checkout .
git reset <youfile>
git reset .


5 如果有分支

查看分支信息

git branch
git branch -v

新建分支

git branch <new branch>

删除分支

git branch -d <you branch>

强制删除 

git branch -D <you branch>

6 提交到远程

git push origin master


7 常用工具

git mergetool

对比工作区和stage区的文件差异

git diff



克隆一个分支到本地,本地会有一个git的项目目录

git clone <git url>

git remote -v

git status

git remote add ops15 ops@10.59.76.15:/home/ops/ops_controller

git add .   (git add . -A )

git add -A

git add youfile

git stash

git diff

git log -p

git log -p -2

git mergetool

git branch 

git checkout

git pull origin master

git push origin master


撤销工作区的所有修改

git checkout .

撤销工作区的指定文件的修改

git checkout <youfile>


撤销所有的stage区域 到工作区

git reset .


查看所有分支

git branch

删除指定分支

git branch -d <you branch>

查看各个分支的提交状况

git branch -v

创建新分支

git branch <new branch>



本文出自 “崔德华运维打工从业路” 博客,请务必保留此出处http://cuidehua.blog.51cto.com/5449828/1783912

git常用操作

标签:git常用操作

原文地址:http://cuidehua.blog.51cto.com/5449828/1783912

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