master
私が clear branch -に取り組み始めたとしましょうno changes to commit
。いくつかのローカル変更を行いますが、この変更はbranch
ではなく別の にある必要があることに注意してくださいmaster
。
この変更を移動branch
して、新しいブランチと再ステートmaster
ブランチをステータスに分ける方法はありますno changes to commit
か?
編集
git branchingの受け入れられた回答に従ってください-現在のマスターをブランチにしてから、マスターを以前のバージョンに戻す方法は? ...手順に従うと、私のマスターにはまだ変更されたファイルがあります。最後のコメント 7を参照してください。
何か不足していますか?
$ git branch # 1. starting on master
# On branch master
nothing to commit, working directory clean
# On branch master # 2.modifying a file
# 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: test.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git stash # 3. stashing changes
Saved working directory and index state WIP on master: 393bfad initial commit
HEAD is now at 393bfad initial commit
$ git status
# On branch master
nothing to commit, working directory clean
$ git checkout -b experiment # 4. creating new branch experiment
Switched to a new branch 'experiment'
$ git stash pop # 5. pop staged changes in exper.
# On branch experiment
# 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: test.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (16b6871d43f367edd03f59558eca4163cd1a2b2f)
$ git checkout master #6. going back to master
M test.txt
Switched to branch 'master'
git status
# 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: test.txt #7. in master test.txt is still modified !!!