What are the steps to permanently remove a committed file from the repository

0 votes
Nov 26, 2019 in DevOps Tools by anonymous
• 19,610 points
1,812 views

1 answer to this question.

0 votes
  • To remove a file for example 'myfile.txt'; which is already committed and a part of repository, the first step is to 'staging' this file deletion using 'git rm myfile.txt' command.

  • After this command if we use 'git status' it'll show message 

e.g.'deleted: myfile.txt' 

  • Now as second step to make it permanently we have to commit this staging using 'git commit -m ' command.

  • Another way is if we remove the file 'myfile.txt' from the working directory manually for example using terminal rm command or using menu as we delete file normally using operating system's GUI. post manual removal the 'git status' command will display the message 'Changes not staged for commit:' and file information like 'deleted: myfile.txt'.

  • To stage these manual changes(we will say same behaviour as working directory changes of add/remove/update files) we've to use -u (recursively update) option with add 

e.g. 'git add -u'(pre git 2.0 version) or 'git add .'(git 2.0 and above version) command.

  • Use git commit command to make them permanent.

answered Nov 26, 2019 by Sirajul
• 59,230 points

Related Questions In DevOps Tools

0 votes
1 answer

Is it a good choice to go for DevOps from a system admin? What are the basic tools one should know?

Changing one's career from System Administration to ...READ MORE

answered Oct 29 in DevOps Tools by Gagana
• 1,880 points
72 views
0 votes
0 answers
0 votes
1 answer

How to filter IP from a log file using Logstash?

Hi@akhtar, You can use the filter plugin in Logstash. It ...READ MORE

answered Jun 18, 2020 in DevOps Tools by MD
• 95,460 points
1,444 views
0 votes
1 answer

How to remove minishift cluster from the windows system?

Hi@akhtar, It is possible that Minishift config contains ...READ MORE

answered Aug 18, 2020 in DevOps Tools by MD
• 95,460 points
2,034 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
4,024 views
+2 votes
1 answer
0 votes
1 answer

What are the steps to unstage files and discard changes in the working directory?

If the git status command displays 'myfile.txt' ...READ MORE

answered Nov 26, 2019 in DevOps Tools by Sirajul
• 59,230 points
1,997 views
0 votes
1 answer

How to get the current status of a local repository in Git?

Using 'git status' command in the repository ...READ MORE

answered Nov 26, 2019 in DevOps Tools by Sirajul
• 59,230 points
727 views
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