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

0 votes
Nov 26 in DevOps Tools by anonymous
• 6,650 points
10 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 by Sirajul
• 40,980 points

Related Questions In DevOps Tools

0 votes
3 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

What are the different services provided by Nagios?

Nagios provides multiple services and I've listed ...READ MORE

answered Mar 1 in DevOps Tools by Isha
43 views
+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,380 points
245 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 in DevOps Tools by Sirajul
• 40,980 points
14 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 in DevOps Tools by Sirajul
• 40,980 points
11 views