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. UserDefault的使用,保存小数据到本地-iOS

    //保持到本地数据 NSArray *array=@[@"234",@"sdfe"]; NSUserDefaults *userDefault=[NSUserD ...

  2. MySQL – optimizer_search_depth

    Working on customer case today I ran into interesting problem – query joining about 20 tables (thank ...

  3. AR、美颜、机器人:计算机视觉库几乎无所不在

    最近日本推出的反美颜应用Primo可能让感到不胜惶恐.其实,这样反人类的应用,你也能写出,不过必须了解的一些技术,就是计算机视觉.目前,计算机视觉库包括FastCV.OpenCV.JavaCV等. 相 ...

  4. 阿里云安装nginx 和 php-fpm

    yum install yum-priorities -y rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-releas ...

  5. ios 企业发布

    ios 1. 支持的tls 协议 1.2 windows server 默认没有启用 检测的网站: https://www.ssllabs.com/ssltest 解决的方法: IIS crypto ...

  6. android 完全退出应用程序(重要)

    android退出应用程序会调用android.os.Process.killProcess(android.os.Process.myPid())或是System.exit(0),这只是针对第一个A ...

  7. JavaScript:改变li前缀图片和样式

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  8. fastjson 使用方法

    Fastjson介绍 Fastjson是一个Java语言编写的JSON处理器. 1.遵循http://json.org标准,为其官方网站收录的参考实现之一. 2.功能qiang打,支持JDK的各种类型 ...

  9. C# Color Table颜色对照表

    .AliceBlue 240,248,255 .LightSalmon 255,160,122 .AntiqueWhite 250,235,215 .LightSeaGreen 32,178,170 ...

  10. astats日志分析系统

    Awstats是一个免费非常简洁而且强大有个性的网站日志分析工具. 功能: 一:访问量,访问次数,页面浏览量,点击数,数据流量等 二:精确到每月.每日.每小时的数据 三:访问者国家 四:访问者IP 五 ...