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

0 votes
Nov 26, 2019 in DevOps Tools by anonymous
• 10,310 points
57 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
• 53,970 points

Related Questions In DevOps Tools

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 in DevOps Tools by MD
• 31,350 points
16 views
0 votes
3 answers
0 votes
1 answer
0 votes
1 answer
+13 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,420 points
533 views
0 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
• 53,970 points
74 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
• 53,970 points
52 views