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

checkout from neighbour branch undeletes a path?

From
Peter Vereshagin <peter@vereshagin.org>
Date
Nov 13, 2012, 15:23 UTC
Message-ID
<20121113152341.GC6561@external.screwed.box>
Hello.

Am wondering if 'checkout branch path' undeletes the files? For the example below I'd like the 'file00.txt' to be deleted and never checked out from the previous branch... How can I do that?

  $ git init                                                                                             
  Initialized empty Git repository in /tmp/repo00/.git/
  $ mkdir pathdir
  $ echo test00 > pathdir/file00.txt
  $ git add pathdir
  $ git commit -am 'added file00.txt'
  [master (root-commit) d4f7c70] added file00.txt
   1 files changed, 1 insertions(+), 0 deletions(-)
   create mode 100644 pathdir/file00.txt
  $ git branch -m master branch00
  $ git branch branch01
  $ rm pathdir/file00.txt
  $ echo test01 > pathdir/file01.txt
  $ git add pathdir
  $ git status
  $ git commit -am 'added file01.txt; removed file00.txt'
  [branch00 c3e78ff] added file01.txt; removed file00.txt
   2 files changed, 1 insertions(+), 1 deletions(-)
   delete mode 100644 pathdir/file00.txt
   create mode 100644 pathdir/file01.txt
  $ git checkout branch01
  Switched to branch 'branch01'
  $ rm -r pathdir
  $ git checkout branch00 pathdir
  $ find pathdir/
  pathdir/
  pathdir/file00.txt
  pathdir/file01.txt
  $

I know about 'merge' and it's not the what I need: to import only the particular subdirectory from the previous branch.

Thank you.

-- Peter Vereshagin <peter@vereshagin.org> (http://vereshagin.org) pgp: A0E26627

Next: Junio C Hamano
Message 1 of 4 in “checkout from neighbour branch undeletes a path?”
  1. Peter VereshaginNov 13, 2012
  2. Junio C HamanoNov 13, 2012
  3. Peter VereshaginNov 13, 2012
  4. Junio C HamanoNov 13, 2012

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.