git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: untracked file deleted from the master branch, when checked out to it from a local branch

From
Marius Storm-Olsen <mstormo@gmail.com>
Date
May 20, 2014, 16:56 UTC
Message-ID
<537B8959.7090100@gmail.com>
In-Reply-To
<2525467.KRXv8a3gWS@linux-wzza.site>
On 5/20/2014 10:38 AM, Arup Rakshit wrote:
Show 20 quoted lines
> I was following some tutorial (http://gitref.org/branching/#merge) - and doing
> it in my console :
>
> Arup-iMac:arup_git shreyas$ git status
> # On branch master
> nothing to commit, working directory clean
> Arup-iMac:arup_git shreyas$ touch test.rb
> Arup-iMac:arup_git shreyas$ ls
> git_1.txttest.rb
> Arup-iMac:arup_git shreyas$ cat test.rb
> Arup-iMac:arup_git shreyas$ vi test.rb
> Arup-iMac:arup_git shreyas$ cat test.rb
> class Foo
>    def self.bar
>      12
>    end
> end
>
> Foo.bar
> ***********HERE I switched to a NEW Branch****************
...
> ********FROM MASTER BRACH WHY THE FILE test.rb DELETED?***********
> Arup-iMac:arup_git shreyas$ ls
> git_1.txt

Because you never committed the original file to the master branch before you created and switched to the change_class branch.

You're missing
     git add test.rb
     git commit -m "initial version of test.rb"
before you switch branches the first time.
-- 
.marius
Previous: Arup RakshitNext: Arup Rakshit
Message 2 of 10 in “untracked file deleted from the master branch, when checked out to it from a local branch”
  1. Arup RakshitMay 20, 2014
  2. Marius Storm-OlsenMay 20, 2014
  3. Arup RakshitMay 20, 2014
  4. Marius Storm-OlsenMay 20, 2014
  5. Arup RakshitMay 20, 2014
  6. Junio C HamanoMay 20, 2014
  7. Arup RakshitMay 20, 2014
  8. Marius Storm-OlsenMay 20, 2014
  9. Sergei OrganovMay 21, 2014
  10. Marius Storm-OlsenMay 20, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.