58 questions
2
votes
1
answer
109
views
How to do `git clean -X -e` with overlapping ignores?
I have a curious case with git clean -X. I want to delete all ignored files in a clone, except the .vs folder (which is ignored but should not be deleted).
This works with git clean -Xnd -e !.vs - ...
0
votes
1
answer
299
views
Delete sensitive string from all Git commits
I have internal github in our organization. There is a particular git repo where I need to replace a sensitive string from all commits. There are around 2000 commits and the sensitive string is there ...
0
votes
0
answers
19
views
git and github i have a problem i hope you will help me [duplicate]
please help me i delete all files on my macbook by command ( git clean -fd )
i dont know what i do all files had deleted
i hope you help me
i dont have any idea how to fix it
the command ( git ...
0
votes
0
answers
113
views
I did the git clean -fd command and deleted everything
Please help me! I just f***ed up everything! I was working on a angular crash course project in visual studio and then wanted to commit my changes to git so i first wanted to add my git repo to the ...
3
votes
1
answer
1k
views
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 ...
0
votes
0
answers
3k
views
How can I recover files after running "git clean -df" by accident?
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 ...
1
vote
2
answers
110
views
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 ...
0
votes
0
answers
433
views
can't delete ".git" using git clean -xdff
git clean with the -ffxd option does not clean directories called .git - how can I do this?
Using git 2.32.0
mkdir myrepo && cd myrepo
git init .
mkdir src && cd src
touch code.cpp
git ...
1
vote
2
answers
887
views
git clean -fd not removing a folder
I have a GIT repository in a ~/foo folder. Now, created a bar/ folder there with some contents, under ~/foo/public/bar/. It is correctly recognized by GIT as untracked:
~/foo git status -s
?? public/...
1
vote
3
answers
791
views
clean untracked directories only
If I rename some directories, then commit and push to the origin, and later pull from another computer I will find both the old an new directories. In the old directories there will be some ignored ...
1
vote
3
answers
2k
views
Rejected refs in repo-cleaning
I am cleaning a git repository's pull requests (PR). There was one PR created to merge a branch B, which was later considered deprecated and removed before being merged. As a result, branch B was ...
4
votes
0
answers
6k
views
How to reverse 'git clean -xdf' [duplicate]
I accidentaly run:
git clean -xdf
And deleted all the files I needed locally, how can I revert it?
0
votes
1
answer
206
views
Chaining git clean (Porcelain) command
I was trying to perform git clean for some untracked files. I typed the following, unintentionally right, command:
git clean -dn | grep -v <files_to_exclude> | git clean -df
Note that the line ...
-1
votes
3
answers
4k
views
How can i remove untracked changes and deleted files showing on my git terminal
I have been trying to get rid of the untracked files showing up when I run git status on my Git Bash terminal. This has also affected my whole computer system as I usually see different files as well ...
0
votes
0
answers
1k
views
How to restore the files that removed with the git command 'git clean -fdx'
I was so stipud run that command git clean -fdx, and lots of my untracked files had been removed. I searched google again and again for any solutions, but it seems there is no way to get back those ...
0
votes
1
answer
279
views
remove untracked file but not delete it from hard disk
In my branch A, I created a new directory myDir. I commited all changes on that branch by git add . and commit. I don't see any untracked file or directory.
Then I switch to branch B, I see untracked ...
-1
votes
1
answer
806
views
Git Opposite of git clean -f -d -x command
We have done shelv in intelljIDEA and after that we performed git clean -f -d -x and we lost all the changes. How to retrieve my lost files.
0
votes
2
answers
6k
views
Undo a git clean
I have been having problems with pulling from git to my server for a few days with it saying one file was untracked, after reading github i ran git clean -d -f and its basically removed a whole ton of ...
7
votes
3
answers
6k
views
Why does git checkout not delete new files?
Suppose I create (but do not commit) a file file.txt, and then type git checkout HEAD or git checkout HEAD .. I thought git checkout basically overwrote your current working files with the snapshot at ...
27
votes
7
answers
30k
views
Git clean is not cleaning untracked files
I'm getting the "The following untracked working tree files would be overwritten by checkout...please move or remove them before you switch branches" error.
The common fix appears to be git clean
...
2
votes
2
answers
384
views
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 ...
0
votes
1
answer
794
views
Can i get back which was git cleaned?
I just cleaned a file while exploring cleaning option in git.
How can i get that file back ?
I used below command:
git clean path/file_01.py -i
Then i selected:
4: ask each
Finally, presseed 'y'...
1
vote
1
answer
308
views
Removing files which are not tracked will be marked as deleted
I have the following state in a git repo:
git status
On branch whatever
Your branch is ahead of 'origin/whatever' by 1 commit.
(use "git push" to publish your local commits)
Untracked files:
(...
1
vote
1
answer
725
views
git clean deletes files in gitignore, db/production.sqlite3 is lost
I was trying to remove an untracked file from a branch that I deleted, and instead I accidentally deleted untracked and tracked files... including apparently the dev and production databases!!!
What ...
1
vote
2
answers
1k
views
Understanding .gitignore masking and git clean
I really have hard time to understand how .gitignore file works...
This is how my file looks like:
custom/history
cache
*.log
custom/modules/*/Ext
upload
sugar-cron*
custom/application/Ext
custom/...
0
votes
2
answers
11k
views
How to revert git clean [duplicate]
I have a git flow question.
I've worked in my code on a local 'developer' branch in git. Then after work was finished I did an add of all changed files and after that I committed it on my local ...
11
votes
1
answer
11k
views
What is the difference between "git checkout -- ." and "git reset HEAD --hard"?
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 ...
1
vote
1
answer
521
views
Cannot rebuild/deploy service fabric project after git clean with empty .gitignore file
I am testing Service Fabric along with a friend. We started with a .Net Core ASP MVC site Service (scaffolded out of the box). Then we added this .gitignore file.
I built/deployed and tested the ...
104
votes
7
answers
317k
views
Git pull - Please move or remove them before you can merge
I am trying to do a git pull origin master from my server but keep getting the error:
Please move or remove them before you can merge.
There are no untracked files, but it seems like it has issues ...
1
vote
1
answer
1k
views
Git Clean or Reset Fails on Windows 10
How do I just checkout a branch into an existing folder in a pristine state?
I am working in Windows 10. switched to a new branch of my project, and noticed that some existing (untracked) folders ...
0
votes
1
answer
448
views
Git clean removed files not shown in git status
First I ran git status
[user@dev config]$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# app1-core/
# app1/...
3
votes
2
answers
4k
views
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
...
11
votes
1
answer
9k
views
How to use git clean remove all file list in .gitignore?
mkdir repo
cd repo
git init
mkdir temp
touch temp/in.tmp
touch out.tmp
echo '*tmp' > .gitignore
when use git clean -Xn it show Would remove out.tmp
but I want to remove temp/in.tmp together
git ...
4
votes
1
answer
1k
views
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 ...
32
votes
2
answers
16k
views
Difference between git reset --hard and git clean
Hi I am curious about the difference between these two commands. When they introduce here: https://www.atlassian.com/git/tutorials/undoing-changes
Looks like git reset --hard also sets both the ...
2
votes
1
answer
1k
views
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 (...
10
votes
1
answer
4k
views
git-clean with GitPython
Is there any way to do something like git clean -d -x -f using GitPython?
I need to reset working directories and want to get rid of all unversioned files without deleting the whole folder (except ...
1
vote
2
answers
464
views
Git: clean empty directories after checkout
I'm on my "devel" branch and git status says "working directory clean".
I want to look at a past release and so checkout a tag: git checkout tags/v1.0.0. After this some directories which were ...
5
votes
3
answers
315
views
Convert a Git working directory to a bare-like repository?
Our development environment uses multiple repositories as part of an overall build system. The build dynamically adapts depending on which repositories you have checked out: if you don't need to ...
5
votes
1
answer
3k
views
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 ...
4
votes
1
answer
4k
views
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 ...
1
vote
4
answers
596
views
git clean directories in untracked files
How can I remove directories from untracked files that aren't appearing in git clean -n? Here are my steps:
git status
...gives me:
Untracked files:
(use "git add <file>..." to include in ...
8
votes
3
answers
6k
views
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 ...
0
votes
1
answer
2k
views
Is "git clean" followed by "git stash clear" redundant when creating a pristine checkout?
I would like to write a script that guarantees a successful Git checkout without intervention from the user. I don't mind dumping anything that cannot be solved without user intervention: for example, ...
6
votes
1
answer
3k
views
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 ...
41
votes
3
answers
13k
views
How to preserve all ignored files in git clean -fd?
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 ...
2
votes
1
answer
118
views
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 ...
2
votes
1
answer
782
views
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 ...
6
votes
3
answers
1k
views
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. ...
3
votes
2
answers
12k
views
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 ...