From: Marius Storm-Olsen <mstormo@gmail.com>
To: Arup Rakshit <aruprakshit@rocketmail.com>, git@vger.kernel.org
Subject: Re: untracked file deleted from the master branch, when checked out to it from a local branch
Date: Tue, 20 May 2014 13:29:40 -0500 [thread overview]
Message-ID: <537B9F14.3030403@gmail.com> (raw)
In-Reply-To: <2726779.MFtIaLB4b4@linux-wzza.site>
On 5/20/2014 12:20 PM, Arup Rakshit wrote:
> On Tuesday, May 20, 2014 12:06:49 PM you wrote:
>
>>
>> It never "came to the new branch", as it was never version controlled,
>> it was an untracked file left behind when you switched branches.
>>
>> Once you added it to the new branch, change_class, it became a version
>> controlled file,
>
> This is still didn't get it. If an untracked file didn't come in the new
> branch, how would I able to add it to stage ? I am not getting this part. You
> are right, but I am not able to understand this one, my bad! :(
Ok, step by step:
You've created test.rd, that was never added to the git repo. (You never
committed it to the master branch.)
> ***********HERE I switched to a NEW Branch****************
> Arup-iMac:arup_git shreyas$ git checkout -b change_class
> Switched to a new branch 'change_class'
> Arup-iMac:arup_git shreyas$ ls
> git_1.txt test.rb
test.rd is untracked, so still there. Git doesn't touch untracked files.
> Arup-iMac:arup_git shreyas$ vi test.rb
> Arup-iMac:arup_git shreyas$ head -1 test.rb
> class Fooo
> Arup-iMac:arup_git shreyas$ head -2 test.rb
> class Fooo
> def self.bar
You modified it
> Arup-iMac:arup_git shreyas$ git commit -am 'changed the class name'
> # On branch change_class
> # Untracked files:
> # (use "git add <file>..." to include in what will be committed)
> #
> #test.rb
> nothing added to commit but untracked files present (use "git add" to
track)
You did nothing here..
> Arup-iMac:arup_git shreyas$ git add test.rb
> Arup-iMac:arup_git shreyas$ git commit -am 'changed the class name'
> [change_class 2d40033] changed the class name
> 1 file changed, 7 insertions(+)
> create mode 100644 test.rb
Your previously untracked file has now been checked in. It's no longer
untracked, so now Git cares.
> Arup-iMac:arup_git shreyas$ cat test.rb
> class Fooo
> def self.bar
> 12
> end
> end
>
> Fooo.bar
> Arup-iMac:arup_git shreyas$ git checkout master
> Switched to branch 'master'
You switched back to master branch, which contains no test.rb (as it's
clean and has never been committed to), so therefore Git removes the
file, since the now tracked test.rb shouldn't be on the master branch.
--
.marius
prev parent reply other threads:[~2014-05-20 18:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 15:38 untracked file deleted from the master branch, when checked out to it from a local branch Arup Rakshit
2014-05-20 16:56 ` Marius Storm-Olsen
2014-05-20 16:03 ` Arup Rakshit
2014-05-20 17:06 ` Marius Storm-Olsen
2014-05-20 17:20 ` Arup Rakshit
2014-05-20 18:24 ` Junio C Hamano
2014-05-20 17:40 ` Arup Rakshit
2014-05-20 18:44 ` Marius Storm-Olsen
2014-05-21 10:21 ` Sergei Organov
2014-05-20 18:29 ` Marius Storm-Olsen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=537B9F14.3030403@gmail.com \
--to=mstormo@gmail.com \
--cc=aruprakshit@rocketmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).