Git checkout with out commit

saachinsiva
saachinsiva
Hi I am very new to GIT and was going through this link and have the below question. Link : [URL="http://www.gitguys.com/topics/switching-branches-without-committing/"]http://www.gitguys.com/topics/switch...ut-committing/[/URL] Scenario 1: 1. Created a file called readme with content "Im from master" in the master branch and committed it. 2. Created a new branch called test using git checkout -b test 3. Changed the content of readme file to "Im from test" in the test branch 4. Without adding to stage or committing,moved back to master branch and see the output as the file has been merged and see the file content as "im from test" in the master branch Scenario 2: 1. Created a file called readme with content "Im from master" in the master branch and committed it. 2. Created a new branch called test using git branch test 3. Modified the file readme to add new line "im second line" and commit it in master branch. 4. Switched to the new branch test and see the content as "Im from master". 5. Modified the file by adding 2nd line as "2nd line from test" and without committing it tried to switch back to master but this time git throws error as cannot switch branch due to local changes and using -m option allows me to do merge. Question Why git allowed me to change the branch and merge it automatically without throwing error in the first scenario not like in the second scenario?

Last updated

1-2 of 2

Reply to this discussion

You cannot edit posts or make replies: You should be logged in before you can post.

Post a reply
932 views