zoukankan      html  css  js  c++  java
  • git分支管理和stash

    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

  • 相关阅读:
    ubuntu安装与卸载java
    linux ubuntu 用户名,主机名,密码修改,增加用户,删除用户
    linux中sudo fdisk -l报错:GPT PMBR size mismatch will be corrected by write错误
    VM VirtualBox虚拟机vdi扩大磁盘空间容量
    WinSCP传输文件到虚拟机linux报错:SSH2_MSG_CHANNEL_FAILURE for nonexistent channel 0
    parallel python多进程集群模式
    zookeeper报错:ERROR [main:QuorumPeerMain@86]
    hive启动报错:Exception in thread "main" java.lang.RuntimeException: com.ctc.wstx.exc.WstxParsingException: Illegal character entity: expansion character (code 0x8 at
    3.数据链路层
    2.物理层
  • 原文地址:https://www.cnblogs.com/or2-/p/4943367.html
Copyright © 2011-2022 走看看