Github 常用命令
小记一些Github常用命令 :
在一个项目中...
假如要修补问题追踪系统上的 #53 问题。顺带说明下,Git 并不同任何特定的问题追踪系统打交道。这里为了说明要解决的问题,把新建的分支取名为 iss53。要新建并切换到该分支,运行 git checkout 并加上 -b 参数:
$ git checkout -b iss53
Switched to a new branch 'iss53' ====================================================
相当于执行 下面 2个命令:
$ git branch iss53
$ git checkout iss53
有必要作些测试,确保修补是成功的,然后回到 master 分支并把它合并进来,然后发布到生产服务器。用 git merge 命令来进行合并:修复完成后,合并到主干,
执行下面语句;
$ git checkout master
$ git merge hotfix
Updating f42c576..3a0874c
Fast-forward
README | -
file changed, deletion(-) ================有冲突的合并,总是不可避免================ $ git merge 分支名
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result.
Git 作了合并,但没有提交,它会停下来等你解决冲突。要看看哪些文件在合并时发生冲突,可以用 git status 查阅:
$ git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit") Unmerged paths:
(use "git add <file>..." to mark resolution) both modified: index.html no changes added to commit (use "git add" and/or "git commit -a")
任何包含未解决冲突的文件都会以未合并(unmerged)的状态列出。Git 会在有冲突的文件里加入标准的冲突解决标记,可以通过它们来手工定位并解决这些冲突。可以看到此文件包含类似下面这样的部分:
<<<<<<< HEAD
<div id="footer">contact : email.support@github.com</div>
=======
<div id="footer">
please contact us at support@github.com
</div>
>>>>>>> iss53
可以看到 ======= 隔开的上半部分,是 HEAD(即 master 分支,在运行 merge 命令时所切换到的分支)中的内容,下半部分是在 iss53 分支中的内容。解决冲突的办法无非是二者选其一或者由你亲自整合到一起。比如你可以通过把这段内容替换为下面这样来解决:
<div id="footer">
please contact us at email.support@github.com
</div>
这个解决方案各采纳了两个分支中的一部分内容,而且我还删除了 <<<<<<<,======= 和 >>>>>>> 这些行。在解决了所有文件里的所有冲突后,运行 git add 将把它们标记为已解决状态(译注:实际上就是来一次快照保存到暂存区域。)。因为一旦暂存,就表示冲突已经解决。如果你想用一个有图形界面的工具来解决这些问题,不妨运行 git mergetool,它会调用一个可视化的合并工具并引导你解决所有冲突:
$ git mergetool This message is displayed because 'merge.tool' is not configured.
See 'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse diffmerge ecmerge p4merge araxis bc3 codecompare vimdiff emerge
Merging:
index.html Normal merge conflict for 'index.html':
{local}: modified file
{remote}: modified file
Hit return to start merge resolution tool (opendiff):
如果不想用默认的合并工具(Git 为我默认选择了 opendiff,因为我在 Mac 上运行了该命令),你可以在上方"merge tool candidates"里找到可用的合并工具列表,输入你想用的工具名。我们将在第七章讨论怎样改变环境中的默认值。
退出合并工具以后,Git 会询问你合并是否成功。如果回答是,它会为你把相关文件暂存起来,以表明状态为已解决。
再运行一次 git status 来确认所有冲突都已解决:
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) modified: index.html
如果觉得满意了,并且确认所有冲突都已解决,也就是进入了暂存区,就可以用 git commit 来完成这次合并提交。提交的记录差不多是这样:
Merge branch 'iss53' Conflicts:
index.html
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
# .git/MERGE_HEAD
# and try again.
#
提交过后,可以把无用的分支删除了....
删除分支的命令:
$ git branch -d 分支名
Deleted branch hotfix (was 3a0874c).
=================================================================================
winXP / GitHub/ git pull收到了conflict,怎么merge? <<<<<<< HEAD 本地文件 ======= 远程pull下来的文件 >>>>>>> 7bb3c50a1d13049ed1187a702ed6f6cbf4f91453 我的做法是手工编辑有conflict的文件,改成我想要的内容,然后commit,这样有问题吗? 但是commit的时候,报错: D:\wamp\www\TMS\tms>git commit -m 'all'
U view/login.html
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict. D:\wamp\www\TMS\tms> 是不是应该用git进行merge,而不是手工编辑。。。。 但是显然git merge时不是merge不了,才把conflict放在一个文件里的啊 。。。找不到头绪 -------------------------------- 解决方法如下(问题留在这里,帮助后来的人) 我应该手工编辑好conflict之后再add,再commit,再push。 D:\wamp\www\TMS\tms>git add view\login.html D:\wamp\www\TMS\tms>git commit -m 'login.html'
[master d0e560d] 'login.html' D:\wamp\www\TMS\tms>git push
http://git-scm.com/book/zh/v1
Github 常用命令的更多相关文章
- Linux 使用 github 常用命令
Linux 使用 github 常用命令 今天整理一下常用的 github 命令,自己只是一个编程小白,有些地方可能做的不是很好,仅仅用作自己的学习使用. 创建一个文件夹用于存放github仓库 m ...
- github常用命令
全局配置 git config --global user.name "lewiscutey"git config --global user.email "lewisc ...
- git(github)常用命令
安装git sudo apt-get install git 显示git版本 git version 显示system属性,对应为/etc/gitconfig文件的内容 git config --sy ...
- GitHub常用命令及使用
GitHub使用介绍 摘要: 常用命令: git init 新建一个空的仓库git status 查看状态git add . 添加文件git commit -m '注释' 提交添加的文件并备注说明gi ...
- GIt/Github常用命令
1)git init:初始化本地仓库 2)创建文件:touch read.txt 3)当操作本地的文件时,使用常用的命令,如(mv,ls..)就可以操作,当操作暂存区的文件时需要在命令前家git,并且 ...
- GitHub 常用命令使用介绍(新同学入门)
经济在不断发展,社会在不断进步,以往的互联网在现在看来都可以称为传统互联网了,因为技术不断的在突破和革新. 本文主要介绍一下版本管理工具,我猜测很多人还是用SVN.CVS或者Resion,但是,今天我 ...
- Github常用命令【转】
本地仓库(local repository) 创建一个本地仓库的流程: 为本地仓库创建一个目录 在目录中执行 git init 对本地仓库所做的改变(例如添加.删除文件等)首先加入到本地仓库的 Ind ...
- github常用命令汇总
创立版本库 mkdir Baiducd Baidugit init SSHssh-keygen -t -rsa -C "TaylorApril947939@gmail"(在gith ...
- Git与github常用命令
Git项目与github建立联系 首先,需要在github上建立一个repository mkdir github-project cd github-project git init 此时githu ...
随机推荐
- override和new的区别
override 1. override是派生类用来重写基类中方法的: 2. override不能重写非虚方法和静态方法: 3. override只能重写用virtual.abstract.overr ...
- 伪元素”:after” , “:before"
伪元素就是源码html中不存在,而视觉上又存在的元素 简单用法: blockquote:before { content: open-quote; // 其他样式 } // ...
- 使用NODEJS+REDIS开发一个消息队列以及定时任务处理
作者:RobanLee 原创文章,转载请注明: 萝卜李 http://www.robanlee.com 源码在这里: https://github.com/robanlee123/RobCron 时间 ...
- 【Android类型SDK测试(一)】认识Android类型的 SDK
(一)SDK是个什么东东 接触软件相关行业的同学都应该知道,SDK(即 Software Development Kit),软件开发包.其作用就是为开发某些软件提供一些便利的东西,包括工具 集合,文档 ...
- Ubuntu Server 安装部署 Cacti 服务器监控
本文的英文版本链接是 http://xuri.me/2013/10/20/install-the-cacti-server-monitor-on-ubuntu-server.html Cacti是一套 ...
- 一段phpcurl代码
$header[] = 'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-fl ...
- ACboy needs your help again!--hdu1702
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ( ...
- 转的git
原文链接:http://blog.csdn.NET/dengjianqiang2011/article/details/9260435 如果输入$ Git remote add origin git@ ...
- QT:多线程HTTP下载文件
这里的线程是指下载的通道(和操作系统中的线程不一样),一个线程就是一个文件的下载通道,多线程也就是同时开起好几个下载通道.当服务器提供下载服务时,使用下载者是共享带宽的,在优先级相同的情况下,总服务器 ...
- codec ruby和json格式输出
zjtest7-frontend:/usr/local/logstash-2.3.4/config# cat geoip.conf input {stdin {} } filter { geoip { ...