* checkout on an empty directory fails
@ 2012-01-05 10:09 René Doß
2012-01-05 11:06 ` Nguyen Thai Ngoc Duy
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: René Doß @ 2012-01-05 10:09 UTC (permalink / raw)
To: git
I have a clean derectory ang the git database. Now I want check out the
master.
The master is the last commit. The files name are displayed but not
stored out in directory.
Why can not I check out?
René Doß
red@linux-nrd1:~/iso/a> ls -a
. .. .git
red@linux-nrd1:~/iso/a> git checkout master
D SP601_RevC_annotated_master_ucf_8-28-09.ucf
D rtl/ether_speed.vhd
D rtl/ether_top.vhd
D rtl/ether_tx.vhd
D rtl/takt.vhd
D sim/makefile
D sim/tb_ether_top.vhd
Already on 'master'
red@linux-nrd1:~/iso/a> ls
red@linux-nrd1:~/iso/a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: checkout on an empty directory fails
2012-01-05 10:09 checkout on an empty directory fails René Doß
@ 2012-01-05 11:06 ` Nguyen Thai Ngoc Duy
2012-01-05 12:38 ` René Doß
2012-01-05 11:07 ` Ramkumar Ramachandra
2012-01-05 11:13 ` Thomas Rast
2 siblings, 1 reply; 7+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2012-01-05 11:06 UTC (permalink / raw)
To: René Doß; +Cc: git
On Thu, Jan 5, 2012 at 5:09 PM, René Doß <doss@gmx.de> wrote:
> I have a clean derectory ang the git database. Now I want check out the
> master.
> The master is the last commit. The files name are displayed but not stored
> out in directory.
>
> Why can not I check out?
try "git checkout ." but be careful because this command overwrites
any changes you have in the directory.
>
> red@linux-nrd1:~/iso/a> ls -a
> . .. .git
> red@linux-nrd1:~/iso/a> git checkout master
> D SP601_RevC_annotated_master_ucf_8-28-09.ucf
> D rtl/ether_speed.vhd
> D rtl/ether_top.vhd
> D rtl/ether_tx.vhd
> D rtl/takt.vhd
> D sim/makefile
> D sim/tb_ether_top.vhd
> Already on 'master'
> red@linux-nrd1:~/iso/a> ls
> red@linux-nrd1:~/iso/a>
--
Duy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: checkout on an empty directory fails
2012-01-05 10:09 checkout on an empty directory fails René Doß
2012-01-05 11:06 ` Nguyen Thai Ngoc Duy
@ 2012-01-05 11:07 ` Ramkumar Ramachandra
2012-01-05 11:13 ` Thomas Rast
2 siblings, 0 replies; 7+ messages in thread
From: Ramkumar Ramachandra @ 2012-01-05 11:07 UTC (permalink / raw)
To: René Doß; +Cc: git
Hi René,
René Doß wrote:
> I have a clean derectory ang the git database. Now I want check out the
> master.
> [...]
>
> red@linux-nrd1:~/iso/a> ls -a
> . .. .git
> red@linux-nrd1:~/iso/a> git checkout master
> D SP601_RevC_annotated_master_ucf_8-28-09.ucf
> [...]
In such situations, "git status" usually has something helpful to say.
You're already on the "master" branch, and you can reset your
worktree with `git reset --hard` (caution: please read the manpage).
-- Ram
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: checkout on an empty directory fails
2012-01-05 10:09 checkout on an empty directory fails René Doß
2012-01-05 11:06 ` Nguyen Thai Ngoc Duy
2012-01-05 11:07 ` Ramkumar Ramachandra
@ 2012-01-05 11:13 ` Thomas Rast
2 siblings, 0 replies; 7+ messages in thread
From: Thomas Rast @ 2012-01-05 11:13 UTC (permalink / raw)
To: René Doß; +Cc: git
René Doß <doss@gmx.de> writes:
> I have a clean derectory ang the git database. Now I want check out
> the master.
Ok, but why? What problem were you really trying to solve?
> red@linux-nrd1:~/iso/a> git checkout master
> D SP601_RevC_annotated_master_ucf_8-28-09.ucf
> D rtl/ether_speed.vhd
> D rtl/ether_top.vhd
> D rtl/ether_tx.vhd
> D rtl/takt.vhd
> D sim/makefile
> D sim/tb_ether_top.vhd
> Already on 'master'
git-checkout considers this an uncommitted change compared to the
current branch (HEAD). It actually ensures that you do not lose such
changes.
To get your files back, you can use the file-argument form of checkout
git checkout -- .
or the "really give me back the HEAD state, period" form of git-reset
git reset --hard
Both of those *will* destroy uncommitted changes with no recourse or
backup, so be careful.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Re: checkout on an empty directory fails
2012-01-05 11:06 ` Nguyen Thai Ngoc Duy
@ 2012-01-05 12:38 ` René Doß
2012-01-05 13:59 ` Holger Hellmuth
0 siblings, 1 reply; 7+ messages in thread
From: René Doß @ 2012-01-05 12:38 UTC (permalink / raw)
To: git
Thank you for your help. I can not understand what is the mistake?
qgit displays me the tree correct.
git status says not special informations.
Only git checkout . works.
What means the point in checkout?
René
red@linux-nrd1:~/iso/a> git status
# On branch master
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working
directory)
#
# deleted: SP601_RevC_annotated_master_ucf_8-28-09.ucf
# deleted: rtl/ether_speed.vhd
# deleted: rtl/ether_top.vhd
# deleted: rtl/ether_tx.vhd
# deleted: rtl/takt.vhd
# deleted: sim/makefile
# deleted: sim/tb_ether_top.vhd
#
no changes added to commit (use "git add" and/or "git commit -a")
ed@linux-nrd1:~/iso/a> ls
red@linux-nrd1:~/iso/a> git reset --hard
HEAD is now at efb7b86 Simulation ergaenzt
red@linux-nrd1:~/iso/a> git checkout master
Already on 'master'
red@linux-nrd1:~/iso/a> git checkout .
red@linux-nrd1:~/iso/a> ls
rtl sim SP601_RevC_annotated_master_ucf_8-28-09.ucf <--here are the
files back!!!!
red@linux-nrd1:~/iso/a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: checkout on an empty directory fails
2012-01-05 12:38 ` René Doß
@ 2012-01-05 13:59 ` Holger Hellmuth
2012-01-05 19:33 ` Dirk Süsserott
0 siblings, 1 reply; 7+ messages in thread
From: Holger Hellmuth @ 2012-01-05 13:59 UTC (permalink / raw)
To: René Doß; +Cc: git
On 05.01.2012 13:38, René Doß wrote:
> git status says not special informations.
versus
> red@linux-nrd1:~/iso/a> git status
> # On branch master
> # Changed but not updated:
> # (use "git add/rm <file>..." to update what will be committed)
> # (use "git checkout -- <file>..." to discard changes in working directory)
> #
> # deleted: SP601_RevC_annotated_master_ucf_8-28-09.ucf
> # deleted: rtl/ether_speed.vhd
> # deleted: rtl/ether_top.vhd
> # deleted: rtl/ether_tx.vhd
> # deleted: rtl/takt.vhd
> # deleted: sim/makefile
> # deleted: sim/tb_ether_top.vhd
> #
This *is* special information: It tells you that master has those 7
files but your working directory has none of them (i.e. it is as if you
had deleted them from your working directory).
"git checkout <branch>" switches between branches, *but* leaves changes
you made (files you edited, added or deleted) intact! This is so you can
switch branches before commiting if you suddenly realize you are in the
wrong branch.
"git checkout -- <paths...>" or in your case "git checkout -- ." is
different, it really overwrites the files in your working dir with the
versions stored somewhere else, by default from the index.
> What means the point in checkout?
"." is simply your current directory
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: checkout on an empty directory fails
2012-01-05 13:59 ` Holger Hellmuth
@ 2012-01-05 19:33 ` Dirk Süsserott
0 siblings, 0 replies; 7+ messages in thread
From: Dirk Süsserott @ 2012-01-05 19:33 UTC (permalink / raw)
To: Holger Hellmuth; +Cc: René Doß, git
Am 05.01.2012 14:59 schrieb Holger Hellmuth:
> On 05.01.2012 13:38, René Doß wrote:
>> git status says not special informations.
>
> versus
>
>> red@linux-nrd1:~/iso/a> git status
>> # On branch master
>> # Changed but not updated:
>> # (use "git add/rm <file>..." to update what will be committed)
>> # (use "git checkout -- <file>..." to discard changes in working
>> directory)
>> #
>> # deleted: SP601_RevC_annotated_master_ucf_8-28-09.ucf
>> # deleted: rtl/ether_speed.vhd
>> # deleted: rtl/ether_top.vhd
>> # deleted: rtl/ether_tx.vhd
>> # deleted: rtl/takt.vhd
>> # deleted: sim/makefile
>> # deleted: sim/tb_ether_top.vhd
>> #
>
> This *is* special information: It tells you that master has those 7
> files but your working directory has none of them (i.e. it is as if you
> had deleted them from your working directory).
>
> "git checkout <branch>" switches between branches, *but* leaves changes
> you made (files you edited, added or deleted) intact! This is so you can
> switch branches before commiting if you suddenly realize you are in the
> wrong branch.
>
> "git checkout -- <paths...>" or in your case "git checkout -- ." is
> different, it really overwrites the files in your working dir with the
> versions stored somewhere else, by default from the index.
>
>> What means the point in checkout?
>
> "." is simply your current directory
Another way of reviving the deleted files and restore the master branch is
$ git checkout -f master # or git checkout --force master
This will unconditionally checkout master and overwrite the local
changes, including the deletions Holger mentioned.
For me, "checkout --force" is more intuitive than "reset --hard" or
"checkout .".
Dirk
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-01-05 19:33 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-05 10:09 checkout on an empty directory fails René Doß
2012-01-05 11:06 ` Nguyen Thai Ngoc Duy
2012-01-05 12:38 ` René Doß
2012-01-05 13:59 ` Holger Hellmuth
2012-01-05 19:33 ` Dirk Süsserott
2012-01-05 11:07 ` Ramkumar Ramachandra
2012-01-05 11:13 ` Thomas Rast
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).