git高级用法

1)  git stash
===============================================================
NAME
git-stash - Stash the changes in a dirty working directory away

SYNOPSIS
git stash list [<options>]
git stash show [<stash>]
git stash drop [-q|--quiet] [<stash>]
git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
git stash branch <branchname> [<stash>]
git stash [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
           [-u|--include-untracked] [-a|--all] [<message>]]
git stash clear
git stash create [<message>]
git stash store [-m|--message <message>] [-q|--quiet] <commit>

DESCRIPTION
Use git stash when you want to record the current state of the working directory and the index, but want to go back to a
clean working directory. The command saves your local modifications away and reverts the working directory to match the HEAD
commit.

The modifications stashed away by this command can be listed with git stash list, inspected with git stash show, and
restored (potentially on top of a different commit) with git stash apply. Calling git stash without any arguments is
equivalent to git stash save. A stash is by default listed as "WIP on branchname ...", but you can give a more descriptive
message on the command line when you create one.

The latest stash you created is stored in refs/stash; older stashes are found in the reflog of this reference and can be
named using the usual reflog syntax (e.g. stash@{0} is the most recently created stash, stash@{1} is the one before it,
                                     stash@{2.hours.ago} is also possible).

===============================================================
git stash : 备份当前工作区德内容,最近一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时将当前工作区中的内容保存到git栈中。
git stash pop: 从Git栈中读取最近一次保存的内容,恢复工作区的相关内容。由于可能存在多个Stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复。
git stash list: 显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。
git stash clear: 清空Git栈。此时使用gitg等图形化工具会发现,原来stash的哪些节点都消失了。

2)当我们在一个分支上merge内容到另外一个分支上的时候,经常会发生error冲突。我们可以使用vim编辑HEAD文件,来解决冲突。
   a. vim   file   修改后保存退出
   b. add   file
   c. 继续执行merge或者是cherry-pick操作。

你可能感兴趣的:(git)