Questions tagged [git-clean]

a git command that removes untracked files from a repository's working tree

git clean is a command that removes untracked files from a repository's working tree, starting in the directory from which it was called.

Resources

56 questions
7
votes
3 answers

Does git clean support moving to Recycle Bin?

I would feel much more comfortable using git clean if I knew I could undo the deletion in case something goes wrong. Does it support Recycle Bin in any way, shape or form? If no, are there any workarounds that anyone knows of, such as an external…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
6
votes
3 answers

git clean -f -d removed files from my local directory

git clean -f -d removed files from my local directory as well How do I retreive them? I used it to remove untracked directories and files and found that it also deleted it from my local file system. Is this possible? What did i do wrong and is there…
tan
  • 1,569
  • 5
  • 14
  • 30
5
votes
1 answer

git clean does nothing

I am trying to clean my working tree, however, when I enter git clean --force nothing happens. $ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) Untracked files: …
BanksySan
  • 27,362
  • 33
  • 117
  • 216
5
votes
1 answer

Exclude files from git clean by default

In a project I am working on I am using git and eclipse, eclipse creates a .project file in the project root. When I do a git clean I do not want to remove this file as I have to create this again. I do want git clean to remove excluded files and…
siebz0r
  • 18,867
  • 14
  • 64
  • 107
4
votes
0 answers

How to reverse 'git clean -xdf'

I accidentaly run: git clean -xdf And deleted all the files I needed locally, how can I revert it?
Mati
  • 61
  • 1
  • 3
4
votes
1 answer

git clean exclude with regex

I'd like to find a regex-way of using git clean. Without regex: git clean -dfx --exclude=".idea/" With regex (tried; not working): git clean -dfx --exclude='(.*\/)*(\.idea\/.*)(.*)' git clean -dfx --exclude="(.*\/)*(\.idea\/.*)(.*)" git clean -dfx…
melvynkim
  • 1,655
  • 3
  • 25
  • 38
4
votes
1 answer

How can I recover files after accidentally running "git clean -df"?

I have accidentally run git clean -df. It removed my files from my current commit, which I had yet to push. Now, in git status, those files are marked with D, which means "deleted". Is there any way to get those files back?
Java Developer
  • 133
  • 2
  • 10
3
votes
2 answers

Undo a git clean command?

I just used a "git clean" command and managed to delete my Documents, Music, and other directories. Is there a way to undo this and somehow get those files back? I did this via Terminal on Mac. Time Machine isn't setup either.
James Brown
  • 919
  • 3
  • 13
  • 22
2
votes
2 answers

Preserve some gitignored files while running git clean -X

I'm working with a repository where you often want to do a clean build. This causes the build script to issue a git clean -Xdff which will remove all files that match patterns in .gitignore. I want some files that are ignored by Git (e.g. .project…
turbulencetoo
  • 3,447
  • 1
  • 27
  • 50
2
votes
2 answers

Why git clean -f does not remove all the untracked files?

I hit this today: % git checkout another_branch error: The following untracked working tree files would be overwritten by checkout: __version__.txt alembic.ini alembic/README alembic/env.py …
LetMeSOThat4U
  • 6,470
  • 10
  • 53
  • 93
2
votes
1 answer

How do I make git clean (or smudge) modify files in my local repository

I'm using git filters (specifically clean) to sort some xml files before checking them into the repository. However, the local files remain as they were - even a smudge filter doesn't do anything (presumably since they haven't been checked…
karlos
  • 3,965
  • 3
  • 16
  • 19
2
votes
1 answer

git clean -d -f removes directories containing files which are ignored. Can I keep the ignored files and still run git clean -d

git clean -d -f removes directories containing files which are ignored. Can I keep the ignored files and still run git clean -d? Example: dir\dir2\file1 .gitignore: dir\dir2 git clean -d -f removes dir and all it's contents. I would expect it to…
Coder
  • 1,375
  • 2
  • 20
  • 45
2
votes
1 answer

Why does git clean -dX not remove my ignored directory?

I would like git to clean up all untracked files that I have ignored. I thought that git clean -dX was the obvious solution, but it does nothing: # Set up test directory mkdir git-test && cd git-test git init && touch x && git add x && git commit -m…
nh2
  • 24,526
  • 11
  • 79
  • 128
1
vote
1 answer

Any way to avoid git checkout -f "warning directory is not empty"?

I have a git repository that contains multiple branch that diverged a lot. When I say diverged it means that each branch can contain new folder or submodule and a lot of diffs between files. When you checkout a branch that doesn't have the same…
CyDevos
  • 395
  • 4
  • 11
1
vote
2 answers

How to print X month ago time before branch name?

Below code I am trying and the output should contain the branch name with x month ago. Any suggestion in this logic would be greatly appreciated. Here the main aim of the code is to fetch list all branch name before 4 month…
rowoc
  • 239
  • 2
  • 12