[英]How can I add and track files in git without tracking the directories they are in?
As you can see from the picture, I have some files nested in some directories. 从图片中可以看到,我在某些目录中嵌套了一些文件。 For example in the '../../roadTrip/' directory I have a file called 'main.cpp'.
例如,在“ ../../roadTrip/”目录中,我有一个名为“ main.cpp”的文件。 I want to track ONLY this file and not the directories it is in, because that is the only file I want to push to my remote repo.
我只想跟踪此文件,而不是它所在的目录,因为这是我要推送到远程仓库的唯一文件。 I tried ignoring the directories the file was in, in the .gitignore file by using wildcards, but it ignores the file also.
我尝试使用通配符忽略.gitignore文件中文件所在的目录,但它也忽略该文件。 Is there any way I can achieve this effect without having to literally take out the file from the nested directories and then push it?
有什么方法可以实现这种效果,而不必从嵌套目录中实际删除文件然后将其推送?
--UPDATE! --update! Below is a screenshot of my github remote repo.
下面是我的github远程仓库的屏幕截图。 It shows the whole directory, and when I open it, the file is inside.
它显示了整个目录,当我打开它时,文件就在里面。 This means the file was successfully pushed, but I don't want that.
这意味着文件已成功推送,但我不希望这样。 I want the file to be pushed alone without the directories it is in.
我希望文件被单独推送而没有目录。
Something along the lines of this: 与此类似:
You write 你写
I want the file to be pushed alone without the directories it is in.
我希望文件被单独推送而没有目录。
That is not possible with Git. 这是不可能的使用Git。 Your remote repository will have the same structure the your working tree of your local repository.
您的远程存储库将具有与本地存储库的工作树相同的结构。 Nothing you can do about that.
您无能为力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.