git分支切换与git rebase , git stash

今天在dev分支开发直播的其余功能,老大忽然发消息说在master分支修改一下网站文章的样式,所以发生了对git的一些了解.html

正在dev分支开发,那么dev分支开发的东西怎么办呢,这就要用的git的存储功能的,git stash向堆栈推送一个新的储藏,只要运行git stash这就要用的git的存储功能的git

1 $ git stash
2 Saved working directory and index state WIP on dev: 3b1687c 房间加载更多
3 HEAD is now at 3b1687c 房间加载更多

 那么怎么查看存储呢?git stash命令就是查看储藏的列表服务器

1 $ git stash list
2 stash@{0}: WIP on dev: 3b1687c 房间加载更多

可是用git status命令查看文件状态,发现文件被保存,可是图片没有,所以用git stash apply返回以前的状态,又用git add, git commit命令对暂存,而后又git stash,这样子就图片就被储藏了app

 1 $ git status
 2 On branch master
 3 Your branch is up-to-date with 'origin/master'.
 4 Untracked files:
 5   (use "git add <file>..." to include in what will be committed)
 6 
 7         static/v1/images/back-top.png
 8         static/v1/images/video-loading.png
 9 
10 nothing added to commit but untracked files present (use "git add" to track)

而后我git checkout master切换到master分支,对需求进行改动提交到远程服务器。以后,返回dev分支,那么怎么merge在master分支的改动呢,固然merge能够使用,可是感受麻烦会有冲突,所以用了git rebase命令操做,ide

先返回dev分支,git checkout dev,在dev分支用git stash apply使用之前储藏,而后git rebase master合并master分支到代码网站

1 $ git stash apply
2 On branch dev
3 nothing to commit, working directory clean
1 $ git rebase master
2 First, rewinding head to replay your work on top of it...
3 Applying: 修改maste分支

 参考文档:https://git-scm.com/book/zh/v1/Git-%E5%B7%A5%E5%85%B7-%E5%82%A8%E8%97%8F%EF%BC%88Stashing%EF%BC%89ui

  http://gitbook.liuhui998.com/4_2.htmlspa

相关文章
相关标签/搜索