1 创建分支
$ git branch 分支名

2切换到分支
$ git checkout 分支名

3查看提交
git log --oneline --decorate --graph --all

4 轻量级tag 是一个commit而已
git tag "v0" hash值

5 annoation tag 其实是一个tag对象,tag对象指向了一个commit
git tag -a "tagName" hash值

6查看tag
git tag

7设置别名
$ git config --global alias.lol "log --oneline --decorate --graph --all"
$ git lol

分离头指针

1 用git checkout切换到一个commit时,这时候head指向了一个commit而不是一个分支名时候,这时处于分离头指针状态
,在新这个切换的commit上工作,工作历史会丢失。

rudy-Pc :: ~/git_checkout ‹master› » git checkout v0
Note: checking out 'v0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b <new-branch-name>

HEAD 目前位于 329f7cb... init on master first

所以解决办法。是执行git checkout -b branch_name,基于这个commit创建分支,然后在进行工作
这个命令相当于 git branch 和git checkout的组合

rudy-Pc :: ~/git_checkout ‹329f7cb› » git checkout -b fixv0
切换到一个新分支 'fixv0'

在这个fixv0上工作

stash

1 在一个分支上进行了操作,并提交到了暂存去,这时候如果checkout到其他分支就会发生,新checkout的分支内容将原来没有commit的覆盖掉。
这时要么将原来的commit掉,要么使用git stash保存起来

git checkout master
error: Your local changes to the following files would be overwritten by checkout:
master.txt
Please, commit your changes or stash them before you can switch branches.
Aborting

2暂存区,这样临时操作的工作去内容和暂存区就会保存了
git stash save -a “stash info

3 当切换到了其他分支工作完成后,再想切换回原来的stash保存的哪个分支,需要将stash的东西还原

git stash 查看

加入--index是将暂存区也还原
git stash pop --index stash@{0}

4 git apply 不清除stash历史,同时将stash状态还原,git pop会清除stash历史
git stash apply --index stash@{0}

5手动删除 stash历史

git stash drop stash@{0}

6一次性清理所有stash 历史
git stash clear

合并分支

1 想将a 分支内容合并到b分支上

需要线切换到b分支
git checkout b
然后再将a分支内容合并过来
git merge a

2冲突问题

发生冲突的文件处在工作区,决掉冲突文件后。需要添加到暂存去然后再commmit

3取消合并
git merge --abort

git分支管理和stash的更多相关文章

  1. Git 分支管理和冲突解决

    Git 分支管理和冲突解决 创建分支 git branch 没有参数,显示本地版本库中所有的本地分支名称. 当前检出分支的前面会有星号. git branch newname 在当前检出分支上新建分支 ...

  2. [git] git 分支管理和工作流程

    分支管理 列举本地分支.下面的 * 是 HEAD 所指向的分支,标识当前工作目录所用的分支.其他分支隐藏在 git 仓库中,通过 git checkout 命令才能访问和修改. $ git branc ...

  3. git分支管理和工作流规范:不同场景细化和演示

    https://www.iteye.com/blog/qqtalk-2415889 前两篇介绍了 git基本概念 和 具体的规范,本篇针对不同的使用场景做演示. 分支 分支命名 master 分支名称 ...

  4. Git应用—03分支管理和冲突解决(转载)

    Git 分支管理和冲突解决 https://www.cnblogs.com/mengdd/p/3585038.html 创建分支 git branch 没有参数,显示本地版本库中所有的本地分支名称. ...

  5. 关于git-Git 分支管理和冲突解决

    创建分支 git branch 没有参数,显示本地版本库中所有的本地分支名称. 当前检出分支的前面会有星号. git branch newname 在当前检出分支上新建分支,名叫newname. gi ...

  6. Git敏捷开发--stash命令

    save 执行git stash,默认以commit info保存当前的stash信息 当在某个commit下,执行多次stash时,无法友好地区分每个stash的改动.save 命令可以清晰地标识每 ...

  7. IDEA 中git的分支管理和使用说明

    1. 为什么要建立分支 git默认的主分支名字为master,一般团队开发时,都不会在master主分支上修改代码,而是建立新分支,测试完毕后,在将分支的代码合并到master主分支上. 2.操作如下 ...

  8. git学习记录——分支管理和多人协作

    在公司里难免会出现多个人一起工作,这就需要构建多个分支派发给多个人去干活 这就产生一个需求,分支管理 分支的创建,合并和删除 其他版本控制系统如SVN等都有分支管理,但是用过之后你会发现,这些版本控制 ...

  9. GitHub笔记(三)——分支管理和多人协作

    三.分支管理 0 语句: 查看分支:git branch 创建分支:git branch <name> 切换分支:git checkout <name> 创建+切换分支:git ...

随机推荐

  1. linux重启和关闭系统命令

    重启命令: 1.reboot 2.shutdown -r now 立刻重启(root用户使用) 3.shutdown -r 10 过10分钟自动重启(root用户使用) 4.shutdown -r 2 ...

  2. 自定义android程序一段时间无操作后的功能

    项目中遇见一个这样的需求,就是当软件在一定时间没有操作时候需要弹出广告页面,当点击广告页面时又进行软件操作,也就是广告要在软件打开并且处于未操作状态才会出来. 方法一:用handler+onTouch ...

  3. Heap Only Tuples (HOT)

    Introduction ------------ The Heap Only Tuple (HOT) feature eliminates redundant index entries and a ...

  4. 【转】php利用mkdir创建多级目录

    先介绍一下 mkdir() 这个函数: mkdir($path,0777,true); 第一个参数:必须,代表要创建的多级目录的路径: 第二个参数:设定目录的权限,默认是 0777,意味着最大可能的访 ...

  5. hibernate 双向一对多关系(Annotation mappedBy注解理解)

    1.@mappedBy 属性简单理解为设定为主表(OneToMany方)(这只是我个人理解,上面文章中也有提到过) 所以另一端(ManyToOne)则需要设置外键@JoinColumn(name=&q ...

  6. tomcat如何按站点调试本机程序

    1.配置host host地址:c:\windows\system32\drivers\etc 配置本机域名: # localhost name resolution is handled withi ...

  7. tomcat内存修改 解决内存溢出异常

    有时候tomcat刚解压完,部署项目后运行会报内存溢出的错误. 原因:项目过大,tomcat内存小. 解决:找到[tomcat]/bin/catlina.bat文件,打开: 在@echo off上面( ...

  8. JQueryMobile + PhoneGap 经验总结

    1. pageinit & pageshow JQM的官方手册重点提醒了使用$(document).bind(‘pageinit’)代替$(document).ready(). 但当你需要对某 ...

  9. Nova分析(1)——整体架构

    Conceptual Diagram Logical diagram Nova is the most complicated and distributed component of OpenSta ...

  10. PHPWord生成word实现table合并(colspan和rowspan)

    PHPWord(http://phpword.codeplex.com/)是一个很好处理和生成WORD文档的工具,但是生成复杂的word,如colspan和rowspan的实现,还是需要你做些修改. ...