所以,我有一个本地目录,这是一个非常简单的例子:
repo/
foo/
bar.txt (newer version)
somefile.txt
...
anotherfile.txt
同时我还有一个远程代码仓库,就像这样
repo/
foo/
bar.txt (older version)
importantfile.txt
这些文件夹从未同步过。
我想同步已存在于远程仓库的文件(如上例中的 bar.txt 和 importantfile.txt)。
因此,问题在于如果我执行以下操作:
git init
git git remote add origin [url]
git fetch origin
git add .
然后使用git add命令提交所有本地文件,但我想跟踪已经存在于远程的文件。
已经尝试在其他主题中找到任何解决方案,但没有成功。
请帮忙。 P.S. 我是一个git新手。
git fetch
会自动完成此操作。还需要什么? - phdgit fetch
后,本地文件夹foo
仍然处于“未跟踪”状态。@phd - igolka97