I accidentally unpacked a gem (paperclip) in my root folder. Now I can't get rid of it to save my life. I add it, remove, add it, stash it, try to check it out...nothing works. I know I'm not providing much detail, but has anyone run into this issue before? Rails env is 2.3.11.
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# paperclip-2.3.16/
nothing added to commit but untracked files present (use "git add" to track)
Try to do:
git rm -r --cached paperclip-2.3.16/*
You could also throw a -f on there before the --cached if you want, to try to force it.
I'm referring to this source:
http://www.kernel.org/pub/software/scm/git/docs/git-rm.html
Since is not tracked yet, you can just do a rm -rf paperclip-2.3.16 and it should remove it with no problems.
Related
I have a question , I want to push my app on git but when I try to but I received a message "log/development file exceds 100MB".
So I try cmd :
- rake log:clear => Nothing changes
- git rm --cached => Nothing changes
- git filter-branch --index-filter 'git rm --cached --ignore-unmatch log/development.log' --tag-name-filter cat -- --all
- echo log >> .gitignore
-git rm log/development.log
git commit -m "removed log file"
But when I do git status then git add . then git commit -m then push I still have this error message , so I check my log/development file and is empty
My question is why git still display this error message??
Please Heeeeeelp
Thank you
You don't need push log file that's why you need to ignore this file for git push like below
If you initialize repsitory then automatically added a file which name .gitignore like
$ git init
$ git add .
$ git commit -m "Initialize repo"
#=> if you not added before
$ git remote add origin git#github.com:User/UserRepo.git #=> example user
$ git push
That's it, but in case if .gitignore file setup missing something then you can get it manually like below
#=> project/.gitignore
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
Hope to help.
The best I could do is remove the file from the repo's history:
bfg --delete-files development.log
Hopefully that's useful to you.
Warning: Extremely destructive.
Part of my .gitignore looks like below:
## Ignore logs
/log/
/log/development.log
Yet development.log is always in modified files when commiting.
I tried to remove --cached and remove file altogether. No luck.
Also I have recently pushed it to remote (by mistake).
Any idea how to solve that bugger once and for all?
Try
log/*
(without leading slash)
And probably
git rm --cached log/development.log
to remove the file from index.
You may also check this question How to make Git "forget" about a file that was tracked but is now in .gitignore? to remove accidentally commited log file.
I was trying to solve an issue with some gem conflicts, and I added all of my gems to vendor/cache, I have since removed them, but now I have a 40M pack file where it used to be less than 1M.
I have tried to filter the branch
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch vendor/cache' --prune-empty -- --all
This goes through a list of rm commands, for example:
rm 'vendor/cache/sass-3.2.8.gem'
and then at the end
Rewrite 9c90286ba515f46919e82e73e2c01a5db1762668 (202/202)
Ref 'refs/heads/master' was rewritten
Ref 'refs/remotes/origin/master' was rewritten
WARNING: Ref 'refs/remotes/origin/master' is unchanged
Finally I run
git gc --aggressive --expire=now
But I still have the same huge number of objects, and the pack file is still 40M. I even try forcing a push when this was complete with no change. Any idea how I can clean up my repository following this mistake?
I think you'll find the answer at the bottom of the question or in the accepted answer here:
Remove file from git repository (history)
The key is in that warning line you have:
WARNING: Ref 'refs/remotes/origin/master' is unchanged
The solution discusses how to get rid of that so that the other steps accomplish what you want and reduce the size back down.
I am using Ruby on Rails, the Capistrano gem and git. I would like to do not put anymore under version control some directories that until now I was tracking.
For my application I have a file system structure like the following:
...
.gitignore
/public/aaa/000/001
/public/aaa/000/002
/public/aaa/000/003
/public/aaa/000/...
To accomplish that I aim, I changed the .gitignore file and added to it the following lines:
# Ignoring "/public/aaa/*" directories
public/aaa/
However, if I check what directories are under version control, I see that those I would like to ignore are still tracked. So, when I deploy with Capistrano to the remote server the content of those directories is still changing.
How can I definitely ignore those directories?
In few words, what I would like to do is to do not change public/aaa directories and files on the remote machine (and, thus, to do not track those with git on my local machine) so that when I deploy with Capistrano those folders (on the remote machine) are untouched.
You'll need to remove them before they'll disappear from source control. They're still part of your git repo, so git is going to continue paying attention to them.
git rm -r --cached public/aaa
The -r tells git to remove the directory (just like rm -r in the console) and --cached tells git to leave the file(s), just remove it from the repo.
You could use git update-index --assume-unchanged <filename>. This will keep the files around, but will no longer track their changes.
You can do this recursively with
find ./folder/ -type f | xargs git update-index --assume-unchanged
For some reason when I try to run git commit -a I don't receive the usual controls at the bottom of nano and cannot save my edited commit message. The output is something like this:
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: app/controllers/photos_controller.rb
# deleted: app/views/comments/edit.js.erb
# deleted: app/views/facets/_old_menu.html.haml
# modified: app/views/photos/uploaded_photo.html.haml
# deleted: config/initializers/delayed_job_config.rb
# deleted: public/images/blue_panel_column.png
# deleted: public/images/embed/add_feature_button.png
~
~
~
~
".git/COMMIT_EDITMSG" 39L, 1947C
I've looked all over for this. I have had to manually remove .git/index.lock if this might explain it. Thanks in advance for any advice.
Hi just a couple of thoughts
Are you sure you are in nano? have
you tried vi style commands to see
if git has reverted back to using
vi? [Esc :x]
if your commit message is small and simple, like your commit, you can use
git commit -a -m "Your message goes here"
Hope that is of some help.
this seems to be an issue of the Mac OS X Terminal. Some but not all people using nano encountered it.
You can trick your terminal into thinking it is another one by typing:
TERM=VT100
export TERM
...or exploring the settings of your terminal (or use another one, like xterm or iTerm).
Other editors like Textmate, vim, BBedit, [...] work well. Do you have to stick with nano?
If your commit message is quite short, you can manually append it with the -m flag:
git commit -am "my commit message."