Unable to Git-add with force
Solution 1
The problem can be solved by renaming the folder and adding the folder with a new name to Git.
This suggests me that there must be some file manipulating the folder name dev
.
Solution 2
You should not need '--force
' or '-f
' option: see git add:
-f
--force
:
Allow adding otherwise ignored files.
In your case, you may not want to add all files, included ignored files under screen/dev directory.
git add screen/dev
should be enough (without options or ending '/')
Solution 3
Is that a typo on cut paste?
If not, it should be
git add --force screen/dev
Solution 4
Try doing:
git add -A .
Also, if you have a .gitignore file it's also possible that you are unintentionally ignoring something (ie: possibly the files you are trying to add).
Solution 5
If nothing works...
- Move the stubborn directory to a temp location outside the repo
- Remove any remaining traces of the stubborn directory in the repo
- Push and make sure that local is synced with remote
- Move the stubborn directory from the temp location back to the repo (You don't have to rename)
git add -A
- Commit and push
Comments
-
Michal aka Miki almost 4 years
I get git-status at ~/bin:
# Untracked files: # (use "git add <file>..." to include in what will be committed) # # screen/dev/
I run
git add --force screen/dev/
I get the same git-status as before. I add each file in the folder independently, but I get the same git-status.
There is no .git in screen/dev/. The folder seems not to be a sumbodule.
How can you add a folder and its content with force to my git at ~/bin?
-
Michal aka Miki almost 15 yearsThe same problem occurs also without
/
. -
Michal aka Miki almost 15 yearsThe same problem occurs also after running your command. I do not have the folder at the .gitignore -files.
-
solidak over 6 yearsThis command doesn't make sense.
-A
and.
do the same thing. No reason to combine both. See here: stackoverflow.com/questions/572549/… -
Guillermo Prandi about 4 yearsThe title of the post is "with force" and the user said they've used
--force
already. -
VonC about 4 years@GuillermoPrandi I understand. I thought (10 years ago) that
--force
was not needed in this case.