16

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?

Mononess
  • 312
  • 1
  • 6
Léo Léopold Hertz 준영
  • 126,923
  • 172
  • 430
  • 675
  • 2
    Can you reproduce this with a fresh Git repository, starting from "git init"? – Greg Hewgill Jul 15 '09 at 06:50
  • @Greg: I cannot reproduce the problem with a fresh Git repository, although I keep exactly the same names in the file structure. --- This suggests me that there must be some file in my repo which manipulates the folder screen/dev – Léo Léopold Hertz 준영 Jul 15 '09 at 22:10

6 Answers6

10

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 '/')

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
9

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.

Léo Léopold Hertz 준영
  • 126,923
  • 172
  • 430
  • 675
6

Is that a typo on cut paste?

If not, it should be

git add --force screen/dev
Tyrone Slothrop
  • 37,031
  • 3
  • 15
  • 8
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).

Fake Code Monkey Rashid
  • 12,963
  • 5
  • 31
  • 40
  • The same problem occurs also after running your command. I do not have the folder at the .gitignore -files. – Léo Léopold Hertz 준영 Jul 15 '09 at 16:35
  • 1
    This command doesn't make sense. `-A` and `.` do the same thing. No reason to combine both. See here: https://stackoverflow.com/questions/572549/difference-between-git-add-a-and-git-add?rq=1 – solidak Sep 26 '17 at 14:32
3

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
solidak
  • 4,945
  • 3
  • 27
  • 32
0

I've also found that you have to have at least a file in that dir in order to be picked up by git. git add screen/dev won't work if there are no files inside.

Deiu
  • 477
  • 4
  • 4