Solve the git management problem of IDEA: the .gitignore file does not take effect after submitting first

Table of contents

reference

process


Referring to the experience articles of many predecessors, summed up the operation of a thorough solution

reference

Article 1 icon-default.png?t=N2N8http://t.csdn.cn/6lT09 Article 2 When working on a new project recently, I found that the project's build/ .idea/ gradle/ .gradle/ will be submitted to gitl... icon-default.png?t=N2N8https://cloud.tencent.com/developer/article/1620746?sharedUid=10092113&shareByChannel=link#4.1         I saw that some people in the comment area of ​​the article said that these articles are a headache. I think it should be that the understanding and operation are not in place. It is my solution process, and my .gitignore file configuration is attached.

Tucao: Why can't set the text format of the code block. . .

# ignore the checked file
/target/
/.idea/
.idea

*.iml
/.mvn/
/mvnw.cmd
/mvnw

 

Refer to the picture of the article, it may not be clear:

Reason: .gitignore can only ignore untracked files, while git caches locally. If some files have been included in version management, modifying .gitignore is invalid .

Solution: delete the local cache first (change to untracked state), and then submit.

process

1. Directly enter the root directory of the project managed by git in idea, pull up Terminal (terminal), and enter the following commands in order

1. git rm -r --cached . //删除所有提交到本地仓库的文件,不敢用慎用蛤
2. git add .  //重新加入所有文件
3. git commit -m 'update .gitignore' //引号里是修改描述,自定义也可以

Note: The .gitignore file can be created at any time before step 2 after you encounter the problem, but when step 2 is not performed, do not choose to automatically commit to git, or you will have to do it all over again.

After finishing this, you can click this thing to get your remote warehouse.

 It should be ok, but if it doesn’t work, I will post another article when I solve the problem with git next time hahaha. Or rely on yourself, as the saying goes: rely on parents at home, rely on Baidu when going out, hahaha.

I wish you excellent and better, always on the road!

 

Guess you like

Origin blog.csdn.net/Ccc67ol/article/details/129903814