How to forcefully commit a file to Git even if the file is ruled as unchanged

0 votes
Let’s say I have two files with similar size and same creation date but different content and if I try to replace one file with the other, git does not recognize this file as changed

How can I solve this?
Jul 11, 2018 in Git & GitHub by Tyrion anex
• 8,660 points
1,719 views

1 answer to this question.

0 votes

This is simple, just follow the below commands:

git rm --cached <yourfile>

git add <yourfile>

This should add the new file into the index regardless of what was there previously.

answered Jul 11, 2018 by Sophie may
• 10,550 points

Related Questions In Git & GitHub

0 votes
1 answer

How to solve the ‘Git commit -a error’?

This happens when no editor is set. ...READ MORE

answered Jul 5, 2018 in Git & GitHub by Tyrion anex
• 8,660 points
774 views
0 votes
1 answer

How to force git to completely forget about a file that is present in .gitignore folder?

Hi@akhtar, gitignore file is a text file that tells Git which files or ...READ MORE

answered Dec 22, 2020 in Git & GitHub by MD
• 95,140 points
56 views
+1 vote
1 answer

How to view the change history of a file using Git versioning?

Hi@akhtar, You can use gitk for this task. ...READ MORE

answered Dec 22, 2020 in Git & GitHub by MD
• 95,140 points
56 views
0 votes
1 answer

How to list all the files in a commit in Git?

Hi@akhtar, Using git diff-tree is considered as a preferred way ...READ MORE

answered Dec 22, 2020 in Git & GitHub by MD
• 95,140 points
92 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,025 views
+2 votes
1 answer
0 votes
2 answers

How to view the nested workflow of a local git repository?

The closest way to view branches in ...READ MORE

answered Aug 2, 2019 in Git & GitHub by Sirajul
• 59,010 points
372 views
0 votes
1 answer