Gitignore, Ignore a file without deleting it from versioning

Asked

Viewed 236 times

2

I need to ignore any modification in certain files, but when modifying anything (in those files), it recognizes the change and stays to commit, follows my . gitignore


#Arquivos Diversos
*.log
*.yml
#rubocop-result.json

#coverage/
public/assets/

tmp/pids/
tmp/cache/
#!base_upload/contractual_instrument/.gitignore
base_upload/contractual_instrument/*

I hope I have been specific, if necessary I am available. Thanks in advance.

EDIT: the file . gitignore this at the root of the project..

/home/thiago/Documentos/mt/app#
.                        Dockerfile    public
..                       files         Rakefile
app                      Gemfile       README.md
base_upload              Gemfile.lock  README.rdoc
bitbucket-pipelines.yml  .git          script
config                   **.gitignore**    sonar-project.properties
config.ru                lib           spec
db                       log           start.sh
doc                      newrelic.yml  tmp
docker-compose.yml       photos        vendor
              Rakefile      vendor



Some *.yml startup files cannot be deleted, but need to be modified according to the local dev database... So it can’t be deleted or changed in the commit.. sorry if I wasn’t very specific, I just started using the platform.Thank you.

  • You want to keep the file in Git, but you don’t want to see the changes? Why?

  • I updated the question

  • 1

    In this case the easiest is to work with two different files. You keep versioned a file foo.yml.example, for example, and does not versionate the foo.yml. Locally it will be enough for the developer to copy the foo.yml.example for foo.yml and make any changes you wish.

1 answer

4


This is because you are already versioning this file, and it is already in your remote repository. What you can do is:

  • Save the contents of this file to a notepad.
  • Delete this file from your project locally.
  • Commit modifications and push to remote repository.
  • Include the name of such a file in gitignore.
  • Finally, create this file again.

From now on modifications in it will not be tracked in versioning.

  • This way the file will not disappear from the remote repository either?

  • Yes, it will disappear from the remote repository.

  • So.. But I wish it wasn’t deleted from the remote repository,?

  • Then I guess that’s not what he wants. From what I understand he wants to keep an original file in the repository, but without changing these files.

  • @Thiagovaz, this procedure will actually make it disappear from your remote repository.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.