![]() Similarly, for removing untracked folders and files immediately, you may also use this command: This command displays the untracked files and directories to be removed (so giving you chance for reviewing). You can see, the interactive option did not display the test_dir, so it will not be removed if you press “c”.įor removing a directory, you may use the –d option in the clean command. What if you have untracked files in sub-folders?įirst, have a look at the clean command with –i option as we have two untracked text files in the current directory and a subfolder ( test_dir) in our local repository. The simple clean command with -f or –i options enable deleting the files in current directory. ![]() If you press c, it will remove the untracked file while q quits the operation. You can see, the Git is asking “what now>” and with each option, you may see the colored letter to perform the action. Suppose, we have tst3.txt and tst4.txt files in our repository folder. The clear command with –i / –interactive option lets you view files before actually deleting them from the file system. ![]() If you look at the folder again, it should not display the text files anymore. For immediately deleting both files, run this command: The tst1.txt and tst2.txt files are untracked that we want o delete. You can see, the ls-files command displayed the files in the working tree/index. This can be confirmed by running the following command: Out of these, the footer.php, haeder.php and README.md are added in the repository or being tracked. To understand that, consider we have following files in our local directory that acts as the Git repository: As mentioned earlier, using the –f option immediately removes the untracked files: In the first example, I will use –f option in the clear command for removing a file. help.doc, 123.txt) for some reason that you do not want to control by Git and ultimately wanted to remove.Īn example of removing the untracked file by clear command Similarly, you may create any other file yourself (e.g. For example, if your C++ project contains a few files that you added into Git work tree:ĭuring a build, it may generate these files: The untracked files may be created as a result of compiling the code file or some other reason. On the other hand, untracked files are not controlled by the version control system. The next section takes you through step by step for removing the untracked files and directors, but before that let us look briefly at what actually untracked files are.Ī file is tracked if it is under the Git (or any other VCS) or exists in the Git index. Maybe, you want to double check before permanently deleting the files. It is useful if you are unsure about the file/directories that are untracked. Only displays what will be removed by the clean command. The above command displays the files that will be removed and gives options to choose (see examples in the next section). The Git clean command can be used for removing the untracked files as follows:įorcefully deleting untracked files command:įor interactively deleting files, use the -i option:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |