* Newbie "svn update" question
@ 2009-12-01 9:25 Mikko Oksalahti
2009-12-01 9:45 ` Howard Miller
2009-12-01 9:49 ` Newbie "svn update" question Tay Ray Chuan
0 siblings, 2 replies; 4+ messages in thread
From: Mikko Oksalahti @ 2009-12-01 9:25 UTC (permalink / raw)
To: git
Hi,
I just started using git for my personal projects at home. Basic usage seems
pretty straight-forward as well as setting up everything. However, I have a
simple question about how do I mimic an "svn update" command on a locally
created repository. Here's what I do:
some_existing_project_dir> git init
some_existing_project_dir> git add .
(about 1000 files added...)
some_existing_project_dir> git commit -a -m "initial commit"
(now I edit 10 files and accidentally delete some files that I'm not aware of)
How do I now get the accidentally deleted files back from the repository without
losing local changes made to 10 files?
I've tried using: "git checkout HEAD ." but my local changes after last commit
will be lost.
I've tried using: "git pull ." but the deleted files are not restored.
So I'm looking for an "svn update" equivalent command that would semantically do
this: "Get the latest version of all files from the repository and merge them
with any local changes I've made to files."
I know a suitable command is available and I'm just a moron who can't read the
manual correctly but help me out anyway :P
Regards,
Mikko
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Newbie "svn update" question
2009-12-01 9:25 Newbie "svn update" question Mikko Oksalahti
@ 2009-12-01 9:45 ` Howard Miller
2009-12-01 12:00 ` Newbie Mikko Oksalahti
2009-12-01 9:49 ` Newbie "svn update" question Tay Ray Chuan
1 sibling, 1 reply; 4+ messages in thread
From: Howard Miller @ 2009-12-01 9:45 UTC (permalink / raw)
To: Mikko Oksalahti; +Cc: git
2009/12/1 Mikko Oksalahti <mikko@azila.fi>:
> Hi,
>
> I just started using git for my personal projects at home. Basic usage seems
> pretty straight-forward as well as setting up everything. However, I have a
> simple question about how do I mimic an "svn update" command on a locally
> created repository. Here's what I do:
>
> some_existing_project_dir> git init
> some_existing_project_dir> git add .
>
> (about 1000 files added...)
>
> some_existing_project_dir> git commit -a -m "initial commit"
>
> (now I edit 10 files and accidentally delete some files that I'm not aware of)
>
> How do I now get the accidentally deleted files back from the repository without
> losing local changes made to 10 files?
>
> I've tried using: "git checkout HEAD ." but my local changes after last commit
> will be lost.
>
> I've tried using: "git pull ." but the deleted files are not restored.
>
> So I'm looking for an "svn update" equivalent command that would semantically do
> this: "Get the latest version of all files from the repository and merge them
> with any local changes I've made to files."
>
> I know a suitable command is available and I'm just a moron who can't read the
> manual correctly but help me out anyway :P
>
> Regards,
> Mikko
'git status' should show you what files you have deleted. 'git
checkout filename' should get them back. I can't think of a way of
recovering every file you have just deleted although - I suspect it
might be tricky. Thinks like 'git pull' only apply to remote
repositories and you don't have one of those. You're not thinking of
it the right way (yet) :-)
Howard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Newbie "svn update" question
2009-12-01 9:25 Newbie "svn update" question Mikko Oksalahti
2009-12-01 9:45 ` Howard Miller
@ 2009-12-01 9:49 ` Tay Ray Chuan
1 sibling, 0 replies; 4+ messages in thread
From: Tay Ray Chuan @ 2009-12-01 9:49 UTC (permalink / raw)
To: Mikko Oksalahti; +Cc: git
Hi
On Tue, Dec 1, 2009 at 5:25 PM, Mikko Oksalahti <mikko@azila.fi> wrote:
> How do I now get the accidentally deleted files back from the repository without
> losing local changes made to 10 files?
>
> I've tried using: "git checkout HEAD ." but my local changes after last commit
> will be lost.
>
> I've tried using: "git pull ." but the deleted files are not restored.
>
> So I'm looking for an "svn update" equivalent command that would semantically do
> this: "Get the latest version of all files from the repository and merge them
> with any local changes I've made to files."
Are you looking for a command that
"Restore deleted files, without reverting local changes",
or
"Get the latest version of all files from the repository and merge
them with any local changes I've made to files."?
I would suggest adding the changed files, then doing a checkout.
git add changed.file1
git add changed.file2
git add -p #alternatively, select hunks/changes to add interactively
git checkout HEAD #although using . (current directory) should give
the same result
Note that your changes have only been added to the index, and you need
to commit them. The index/stage is a concept not in svn. See the user
manual for more on this.
I also suspect you are still thinking in svn mode when you said
getting the latest version from the repository. You already have a
repository locally. It is more an issue of syncing your local
repository with the one that you're following. Unlike svn, every time
you commit, your local repository is updated, not the remote one, and
vice-versa.
--
Cheers,
Ray Chuan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Newbie
2009-12-01 9:45 ` Howard Miller
@ 2009-12-01 12:00 ` Mikko Oksalahti
0 siblings, 0 replies; 4+ messages in thread
From: Mikko Oksalahti @ 2009-12-01 12:00 UTC (permalink / raw)
To: git
Howard Miller <howardsmiller <at> googlemail.com> writes:
>
> 2009/12/1 Mikko Oksalahti <mikko <at> azila.fi>:
> > How do I now get the accidentally deleted files back from the repository
without
> > losing local changes made to 10 files?
>
> 'git status' should show you what files you have deleted. 'git
> checkout filename' should get them back. I can't think of a way of
> recovering every file you have just deleted although - I suspect it
> might be tricky. Thinks like 'git pull' only apply to remote
> repositories and you don't have one of those.
>
> Howard
>
Ok. That helps. I just assumed the 'git pull' would work same way on local and
remote repositories but I guess not then...
> ....You're not thinking of it the right way (yet)
I hate when you say that :P
/Mikko
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-12-01 12:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-01 9:25 Newbie "svn update" question Mikko Oksalahti
2009-12-01 9:45 ` Howard Miller
2009-12-01 12:00 ` Newbie Mikko Oksalahti
2009-12-01 9:49 ` Newbie "svn update" question Tay Ray Chuan
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).