git分支切換與git rebase , git stash


今天在dev分支開發直播的其他功能,老大突然發消息說在master分支修改一下網站文章的樣式,因此發生了對git的一些了解.

正在dev分支開發,那么dev分支開發的東西怎么辦呢,這就要用的git的存儲功能的,git stash向堆棧推送一個新的儲藏,只要運行git stash這就要用的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,這樣子就圖片就被儲藏了

 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命令操作,

先返回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%89

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

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM