Unable to Git-add with force

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?

Upvotes: 16

Views: 59296

Answers (7)

Leo
Leo

Reputation: 1

Just git add .

Take a break Have a KitKat Make a cup of coffee

and when you come back after a while it should be done

Upvotes: -1

Deiu
Deiu

Reputation: 517

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.

Upvotes: 0

solidak
solidak

Reputation: 5081

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

Upvotes: 3

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.

Upvotes: 9

Fake Code Monkey Rashid
Fake Code Monkey Rashid

Reputation: 14547

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).

Upvotes: 3

VonC
VonC

Reputation: 1323793

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

Upvotes: 10

Tyrone Slothrop
Tyrone Slothrop

Reputation: 42417

Is that a typo on cut paste?

If not, it should be

git add --force screen/dev

Upvotes: 6

Related Questions