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,700 points
12,585 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,610 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,700 points
2,046 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,440 points
3,228 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,440 points
733 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,440 points
764 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,526 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,230 points
1,326 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP