{"thread":{"id":"18101","subject":"git-add and index","startedAt":"2009-03-03T07:20:08Z","lastAt":"2009-03-03T08:00:52Z","messageCount":2,"participants":["bill lam","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"106773","messageId":"20090303072008.GB7478@b2j","threadId":"18101","inReplyTo":null,"subject":"git-add and index","fromName":"bill lam","fromEmail":"cbill.lam@gmail.com","sentAt":"2009-03-03T07:20:08Z","receivedAt":"2009-03-03T07:20:08Z","isPatch":false,"sender":{"key":"cbill.lam@gmail.com","avatar":null},"body":"I have 2 questions related to index\n1. Is it safe to just git-add (without commit) for local changes made\n   before checkout or switch to another branch?\n2. How to checkout the changes as recorded in index from git-add that\n   not yet commit to the working tree?\n\nThanks!\n\n-- \nregards,\n====================================================\nGPG key 1024D/4434BAB3 2008-08-24\ngpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3\n唐詩179 王維  奉和聖製從蓬萊向興慶閣道中留春雨中春望之作應制\n    渭水自縈秦塞曲  黃山舊遶漢宮斜  鑾輿迥出千門柳  閣道迴看上苑花\n    雲裡帝城雙鳳闕  雨中春樹萬人家  為乘陽氣行時令  不是宸遊玩物華\n"},{"id":"106783","messageId":"7vprgzf32j.fsf@gitster.siamese.dyndns.org","threadId":"18101","inReplyTo":"20090303072008.GB7478@b2j","subject":"Re: git-add and index","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-03-03T08:00:52Z","receivedAt":"2009-03-03T08:00:52Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"bill lam <cbill.lam@gmail.com> writes:\n\n> I have 2 questions related to index\n> 1. Is it safe to just git-add (without commit) for local changes made\n>    before checkout or switch to another branch?\n\nAs long as the other branch does not touch the same path, it should be kept\nin the index during the branch switching.\n\n\"Is it safe\" and \"does it work like this\" questions are easier to answer by\na bit of experimenting in a toy repository these days ;-).\n\n> 2. How to checkout the changes as recorded in index from git-add that\n>    not yet commit to the working tree?\n\n\"git checkout -- path\"?  If you do not have a revision that can be referred\nto as path (iow the file you are trying to check out of the index is not\ne.g. \"master\"), you do not have to say -- and just \"git checkout path\"\nshould suffice.\n"}]}