Reputation: 2608
I have been working on an iPhone project in Xcode, and decided I wanted to put it up on github. I created a repo on github, cloned it, and moved all my files into the directory. Then I attempted to
git add Directory .
I committed and pushed, and found that the only thing in the repo now was this directory. There is nothing in it - I can't even click it to open it in the github file viewer for the repo. It is a picture of a folder and the folder's name. I've tried
git add Directory .
git add Directory -A
git commit -a
Nothing will add these files to the directory. What am I doing wrong?
Upvotes: 3
Views: 6655
Reputation: 535
Another repository may be present.
This was happening to me with plugin directories in my vimfiles. Reproduce like this:
vim-easymotion
) somewhere into your repository (in my case into vimfiles\bundle
)git add .
, then git status
will show that all that's been achieved is that the folder name (in this case bundle\vim-easymotion
) has been added as a new file
git commit
, then git push origin master
(pushing changes to GitHub)I only realised what was going on when, from my vimfiles\bundle\vim-easymotion
directory in Git Bash, I issued git config -l, and noticed a reference to Lokaltog
, the owner of the vim-easymotion
repository. So I issued git remote -v
, and sure enough, in that directory the Git alias was origin https://github.com/Lokaltog/vim-easymotion.git
, which is not my repository's remote address, but that of the plugin. Stunned at my ignorance, I navigated to the plugin directory with FreeCommander, showing hidden files and of course the plugin creator's .git
files were there.
The cure, assuming you have cloned someone else's repository into yours, as I did:
find . | grep /.git | xargs rm -rf
to remove all of the unwanted .git
filesgit remote -v
to check that you're back to your own remote's aliasgit status
will now report that a file has been deleted (in my case vim-easymotion
)git add -A
to stage that deletion, then git commit
, and git push origin master
to remove that daft filename from your remote at GitHubUpvotes: 8
Reputation: 10886
I'm surprised to hear that git add . ; git commit
is not working for you. Are you sure you're running those commands from the topmost directory in your repo? Here's a summary of what you would normally expect to happen:
cd ~/Directory # or whatever the path is in your case
git status # shows lots of "Untracked files" because this is a new repo
git add . # adds everything to your index
git status # now shows lots of "Changes to be committed"
git commit # fires up the editor and finishes the commit
git show # shows the commit you just made
At what point does this break down for you?
Upvotes: 1
Reputation: 9948
git add .
while in the Directory should add everything inside, unless it is ignored by your .gitignore file...
Upvotes: 2
Reputation: 33203
Try git add .
or perhaps use git gui and select the files in that by clicking the icons to stage them then commit.
git doesn't track directories - it tracks the files and directories get to come along for the ride. If you add the files explicitly the directory will be included as part of the file path. To add a directories contents git add Directory/*
would do the job.
Upvotes: 1