.gitignore and remove cached makes it so I can't see the file on the server al all?

試著忘記壹切 提交于 2019-12-13 12:33:32

问题


I want to ignore a few files that need to be different, or do not need to be tracked- I edit my gitignore to skip swp files, the entire tmp dir and a few of the log files inside log/.

I them removed the cached versions from my local install- all seemed well here

then I ran git add . (was this supposed to be a git add -u?)

And then pushed to my remote repository.

The app worked fine still, but I noticed that I couldn't find or access the files on my remote repository I had ignored locally- my log file was gone, as was my database.yml file (again, on remote).

I could still start up the application, so it seems like the file is still there (unless I'm wrong about needing database.yml), but I can't see those files.

If I wanted to always ignore those files (as does the other dev who will pull them), how can I do that without having those files dissapear on the remote?

Thanks

Edit- it seems like what I might be looking for is actually

git update-index --assume-unchanged example.txt

which seems like it will allow for the file to continue existing in both environments, without monitoring it for any changes.

Am I on the right track?


回答1:


 git update-index --assume-unchanged example.txt

is a possible solution, but beware of any git reset you might need to do: those "ignored" files will we reset as well.

 git update-index --skip-worktree example.txt

is another way of ignoring those files, making sure any local modification won't be reset.
See also:

  • "How to make changes that only i can see?"
  • "Undo git update-index --skip-worktree")


来源:https://stackoverflow.com/questions/13922918/gitignore-and-remove-cached-makes-it-so-i-cant-see-the-file-on-the-server-al-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!