当前位置: 动力学知识库 > 问答 > 编程问答 >

merge - Missing files after git pull?

问题描述:

I have a remote that is the same, or similar, to the rails project in my current directory. To sync the two, I do

git init

git remote add origin [email protected]

git pull

The problem is that some of the files I had in my working copy were added (ie not in the remote), so when I do

git status

it should show a bunch of untracked files. Instead I see the files from the repo that are out of date.

Why didn't it ask me to resolve conflicts in these files? And where are my old files?

网友答案:

The merge implicit in "git pull" must have overwritten local files that were not committed.

I would suggest this sequence:

git init
git add .
git commit -m"local"
git remote add origin [email protected]
git fetch origin

At this point, observe the repository with "gitk --all"

Merge with

git merge remotes/origin/master

This should let you know of conflicts, if any. And local files won't be overwritten.

网友答案:

What if, after the commands you did above, you try doing this?

git checkout blah
git pull origin blah

I'm still learning git, so I'm not positive, but just a guess. (Might need to replace blah with [email protected] in the commands above too.)

网友答案:

If you have a local repo (with its working directory), you shouldn't need to 'git init' anything.

git remote add origin [email protected]
git pull

should be enough.

If you have made a git init, that should be in an empty repository, where you then imported the master content of 'origin'.


I didn't have a local repo, just the local files.

Then you need to add them first (see r-mercado's answer).

From the git pull man page:

Warning: Running git pull (actually, the underlying git merge) with uncommitted changes is discouraged: while possible, it leaves you in a state that is hard to back out of in the case of a conflict.

分享给朋友:
您可能感兴趣的文章:
随机阅读: