git-clean

What is the difference between “git checkout — .” and “git reset HEAD --hard”?

匆匆过客 提交于 2019-11-30 12:21:11
问题 This is not a general question about what '--' does, as in the marked duplicate. This is a git-specific question asking for clarity on what the operational differences are between the mentioned commands. If I want to clean out my current directory without stashing or committing, I usually use these commands: git reset HEAD --hard git clean -fd A co-worker also mentioned using this command: git checkout -- . It's a difficult command to google, and it's not clear to me from the git

Git: Exclude a file with git clean

白昼怎懂夜的黑 提交于 2019-11-30 06:07:55
i'm working on a big python project, and i'm really sick if .pyc and *~ files. I'd like to remove them. I've seen that the -X flag of git clean would remove untracked files. As you can imagine, i'm not tracking .pyc nor *~ files. And that would make the trick. The problem is that i've a local_settings.py file that I'd like to keep after the git clean. So, this is what I've got. .gitignore: *.pyc *~ local_settings.py When I execute this command: git clean -X -n -e local_settings.py I get this list of results: Would remove local_settings.py Would remove requirements.txt~ Would remove (other

How to preserve all ignored files in git clean -fd?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 06:04:32
When I have .gitignore data/* and run git clean -fd , the data folder and all its content files are deleted. What I want is to delete all unrevisioned files in a git repo while excluding all ignored files (i.e. DON'T delete gitignored files). What could I do? talles Git normally doesn't clean ignored files unless the -x flag is specified, but strangely it cleans out when configured as you did ( folder/* ). As @VonC pointed out, you should change your .gitignore -file to ignore the directory ( data/ ) rather than its contents ( data/* ). It's a subtle difference, but it matters to git. I've

What is the difference between “git checkout — .” and “git reset HEAD --hard”?

会有一股神秘感。 提交于 2019-11-30 02:31:53
This is not a general question about what '--' does, as in the marked duplicate. This is a git-specific question asking for clarity on what the operational differences are between the mentioned commands. If I want to clean out my current directory without stashing or committing, I usually use these commands: git reset HEAD --hard git clean -fd A co-worker also mentioned using this command: git checkout -- . It's a difficult command to google, and it's not clear to me from the git documentation what this command actually does. It seems to be one of the later-mentioned usages in the manual. At a

How to preserve all ignored files in git clean -fd?

断了今生、忘了曾经 提交于 2019-11-29 04:40:02
问题 When I have .gitignore data/* and run git clean -fd , the data folder and all its content files are deleted. What I want is to delete all unrevisioned files in a git repo while excluding all ignored files (i.e. DON'T delete gitignored files). What could I do? 回答1: Git normally doesn't clean ignored files unless the -x flag is specified, but strangely it cleans out when configured as you did ( folder/* ). As @VonC pointed out, you should change your .gitignore -file to ignore the directory (

Git checkout/pull doesn't remove directories?

拥有回忆 提交于 2019-11-27 06:04:42
I've got my repo @ github. I did some work at home and pushed it to github. It involved some deleting of files and directories. Now I'm on my work box, which had a copy of the code before deleting the files and directories. I issued the following: git remote update git checkout HEAD git pull origin HEAD It deleted all of the files it should have, but not the directories the files were in. Two questions: Why did it not remove the directories? Is there a git command I can issue in the current state to remove them? Git doesn't track directories, so it won't remove ones that become empty as a

Can I restore deleted files (undo a `git clean -fdx`)?

爱⌒轻易说出口 提交于 2019-11-26 16:24:25
I was following the instructions on making github pages , and forgot to move down into my git sub directory. As a result, I just nuked an entire directory of documents with git clean -fdx . Is there any way I can undo this terrible mistake? Mat No. Those files are gone. (Just checked on Linux: git clean calls unlink() , and does not backup up anything beforehand.) git clean -fdxn Will do a dry run , and show you what files would be deleted if you ran git clean -fdx (of course this is only helpful if you know this ahead of time, but for next time) No. "git clean -fdx" will delete all files and

Git checkout/pull doesn't remove directories?

耗尽温柔 提交于 2019-11-26 11:51:50
问题 I\'ve got my repo @ github. I did some work at home and pushed it to github. It involved some deleting of files and directories. Now I\'m on my work box, which had a copy of the code before deleting the files and directories. I issued the following: git remote update git checkout HEAD git pull origin HEAD It deleted all of the files it should have, but not the directories the files were in. Two questions: Why did it not remove the directories? Is there a git command I can issue in the current

How to revert uncommitted changes including files and folders?

断了今生、忘了曾经 提交于 2019-11-26 09:14:28
问题 Is there a git command to revert all uncommitted changes in a working tree and index and to also remove newly created files and folders? 回答1: You can run these two commands: # Revert changes to modified files. git reset --hard # Remove all untracked files and directories. # '-f' is force, '-d' is remove directories. git clean -fd 回答2: If you want to revert the changes only in current working directory, use git checkout -- . And before that, you can list the files that will be reverted without

Can I restore deleted files (undo a `git clean -fdx`)?

試著忘記壹切 提交于 2019-11-26 04:47:06
问题 I was following the instructions on making github pages, and forgot to move down into my git sub directory. As a result, I just nuked an entire directory of documents with git clean -fdx . Is there any way I can undo this terrible mistake? 回答1: No. Those files are gone. (Just checked on Linux: git clean calls unlink(), and does not backup up anything beforehand.) 回答2: git clean -fdxn Will do a dry run, and show you what files would be deleted if you ran git clean -fdx (of course this is only