B
B
Brew2022-04-06 23:22:29
git
Brew, 2022-04-06 23:22:29

How to clean up a git repository?

Hello everyone and thank you in advance for your replies! I started to study git and have not yet found information for myself that will answer my question. I made a repository on gitlab and pushed the project there (git push), but before that I did not make a .gitignore file, now I thought of making it, but adding a line there so that it ignores *.DS_Store
1. It does not ignore it
2. How delete this file in the repository so that later it does not swear that there are different versions on the computer and in the repository on gitlab?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Kuznetsov, 2022-04-06
@Brew

Here are some facts to help you understand how Git works. You can write in a notebook.

  • The .gitignore file is meant to describe what we don't want to RANDOMLY add to the repository.
  • We can FORCE ANY file to be added to the repository, even if it is described in .gitignore .
  • Adding a file to .gitignore will not remove the file itself from the repository. If the file is ALREADY in the repository, then it will continue to be tracked, regardless of the presence of .gitignore .
  • If you no longer want to track a file, then simply remove it from the repository.
  • The key --cachedwill allow you to leave the file in the working directory if you need it.
git rm --cached -- '.DS_Store'
git commit

L
Linuxoid, 2022-04-18
@orahorn

I advise you to learn about the topic:
man git-gc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question