2017-07-04 2 views
0

私は2つのバージョンを持っているローカルスクリプトを得ました。だから私は、スクリプトのディレクトリに行き、このでした:私は、エディタでスクリプトを開き、ファイルの末尾に「foobarに」を書いた後Git:分岐?

git init 
git add myscript.py 
git commit -m "initial" 
git checkout -b test_branch 

を。だから、基本的に私は戻ってマスターに私のtest_branchから切り替え

git checkout master 

を:それから私は、コンソールに戻ったと書きました。私はスクリプトを開き、最後にはまだ "foobar"がありました。私はtest_branchにいたときにファイルに書き込んだので、表示されないことを期待していましたか?あなたtest_branchcheckout

+0

。 – jbr

+0

チェックアウト前にスクリプトを追加してコミットしましたか? –

答えて

3

、あなたはそこにいくつかの変更を行い、次にあなたcheckoutあなたmaster支店前に、あなたは最初test_branchに対して行われたすべての変更をコミットする必要があります。

だから、のようになる:あなたがマスターに戻って変更する前にあなたは、あなたのテストブランチにスクリプトに変更をコミットする必要が

git init      #initializing 
git add myscript.py   #added a file, ready to commit 
git commit -m "initial"  #initial commit made to master 

git checkout -b test_branch #created and checked out a new branch 
git add myscript.py   #add a file, ready to commit to test_branch 
git commit -m 'other version' #commit the changes made to test_branch 
git checkout master   #checkout master again 
+1

これは期待どおりに動作します。有用なソフトウェアは何ですか?私はtest_branchに追加してコミットしませんでした。 – user3182532