Git学習-Git stashの使い方


Git学習-Git stashの使い方
1、引用dev分岐で新しい需要を開発している場合、需要が半分に開発されている場合、バグがあるというフィードバックがありますが、あなたの新しい機能が半分になっても提出したくない場合は、コマンドgit stashを使用して現在の進捗状況(ワークスペースと一時保存エリア)を保存することができます.その後、別のブランチに切り替えてバグを修正し、修正が完了した後、git checkout devでdevブランチに戻り、コマンドgit stash popを使用して以前の進捗状況を回復して開発を継続する.
2、使い方
1、まず2つのコマンドを紹介します:git stashgit stash save ""git stash:ワークスペースと一時保存領域を保存する
git stash save「case」:今回は検索しやすい名前「case」を格納しました.
2、git stash list:
以前に保存したすべてのバージョンのリストを表示
$ git stash list
stash@{0}: WIP on Practice: 2f70846 Complete practice view and network
stash@{1}: WIP on Practice: 2f70846 Complete practice view and network
stash@{2}: WIP on Practice: 2f70846 Complete practice view and network
stash@{3}: WIP on Practice: 2f70846 Complete practice view and network
stash@{4}: WIP on Practice: 812e77b Add collectionView and AnswerView
stash@{5}: WIP on Practice: 53bb0c1 add tableView of questions and refactor the code of scrollView

3、git stash pop[stash_id]とgit stash apply
git stash pop:特定のバージョンを復元し、stash_idを指定しなければ最新のストレージバージョンをデフォルトで復元し、復元に成功した後にコマンドを入力:git status修正したファイルが表示されます.
$ git stash pop stash@{0}
Auto-merging WePeiYang/Shared/Network/SolaSessionManager.swift
CONFLICT (content): Merge conflict in WePeiYang/Shared/Network/SolaSessionManager.swift
Auto-merging WePeiYang/Practice/Practice/QuestionTableView/OptionsCell.swift
CONFLICT (content): Merge conflict in WePeiYang/Practice/Practice/QuestionTableView/OptionsCell.swift
Auto-merging WePeiYang/Practice/Practice/Exercise/Model/ExerciseNetwork.swift
Auto-merging WePeiYang.xcodeproj/project.pbxproj
CONFLICT (content): Merge conflict in WePeiYang.xcodeproj/project.pbxproj

git stash apply:スタック内のコンテンツを現在のディレクトリに適用します.git stash popとは異なり、このコマンドはスタックからコンテンツを削除しません.つまり、スタック内のコンテンツをワークディレクトリに複数回適用し、複数のブランチの場合に適応することができます.
$ git stash apply
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   src/main/java/com/wy/StringTest.java

no changes added to commit (use "git add" and/or "git commit -a")

$ git stash list
stash@{0}: On master: case2
stash@{1}: On master: case1

4、git stash drop [stash_id]
ストレージの進行状況を削除します.stash_を指定しない場合idは、デフォルトで最新のストレージ進捗を削除します.
$ git stash drop stash@{5}
Dropped stash@{5} (00a18888b0d4c7e9c7d543e9798e7de8df967bc3)

5、git stash clear
すべてのストレージの進行状況をクリア
6、git stash show [stash_id]
stash_idが指定されていない場合は、スタックに新しく保存されたstashと現在のディレクトリの違いがデフォルトで表示されます.git stash show stash@{1}指定したstashと現在のディレクトリの違いを表示します.
詳細は、git stash show -pで確認します.