search

Home  >  Q&A  >  body text

Issues with git using .gitignore

The local warehouse has a.txt file, and the remote warehouse also has a.txt file.
When .gitignore writes a.txt, why does it delete the remote repository? ?
How can I save two different versions locally and remotely, and ignore a.txt when submitting locally or remotely? ? ?

为情所困为情所困2790 days ago703

reply all(3)I'll reply

  • 滿天的星座

    滿天的星座2017-05-02 09:54:12

    git rm a.txt --cached
    

    Also add a.txt to .gitignore

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-02 09:54:12

    1. git update-index --assume-unchanged

    2. git filter: see How to make Git ignore single/multiple lines in a file

    reply
    0
  • ringa_lee

    ringa_lee2017-05-02 09:54:12

    Local and remote are meant to be synchronized. It’s not impossible for you to use this method, but what is your X requirement?

    The most common is to deal with local configuration files. In this case, just let the program choose the correct configuration file to load, such as through command line options or environment variables. A better approach is to keep the configuration file out of version control (just put an example or template in it). Configuration files are managed manually or through means such as Salt.

    reply
    0
  • Cancelreply