git commit -a / nano - ruby-on-rails

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

Related

latexdiff-vc file names

I am using git with a latex project but it seems that I am not using latexdiff in an efficient way.
In order to run latexdiff to compare the current version with the previous revision, I learned to use:
latexdiff-vc -r HEAD~1 main.tex
Further info here: www.mankier.com/1/latexdiff-vc
The HEAD~1 above picks the previous git revision, which is something that I find useful.
However, the generated diff file has the following name main-diffHEAD~1.tex, which I find a terrible name: both for clarity and since my tex editor has issues with the ~.
Due to the issue, my questions are:
Am I properly using -r HEAD~1, or is there another more natural way to do the same comparison?
Is there a simple way to control the file name output instead of renaming it? Say, main-diff1.tex would be better.
To ensure the hash in is the filename you can run this:
$ latexdiff-vc --git -r `git rev-parse --short HEAD~1` main.tex
where HEAD~1 can be replaced with any of the alternatives mentioned by #torek in the question comments.
I personally use this quite often so have the sub-command as an alias in my ~/.gitconfig, like so:
[alias]
shash = "!git rev-parse --short HEAD"
and then actually run the same command from above as:
$ latexdiff-vc --git -r `git shash HEAD~1` main.tex

Error message git push from my local rails app , log/development.log too large

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.

Github pulling does not work in - Rails 5

I'm trying to pull last commit that I made on github, and though I get no errors, I see no changes in the code. I messed up my schema file, but after I pull the code it does not change at all.
I searched here on stack and the solution that worked for others didn't work for me, and this is also my first time that I'm pulling code from github, so I could've probably done something wrong.
I used this code:
git fetch origin controller-generator
git git reset --hard FETCH_HEAD
This is what I get as the output
HEAD is now at 1fb8c97 Integrated friendly routes gem
'Integrated friendly routes gem' is my last commit that I want to pull, but nothing changes. I don't know if I need one more step or whatever it goes with it.
This is what I have in commit db file
And when I pull this, I get this
The last one should not be there.
This is output
equalsign:~/workspace/BlogAndPort/db/migrate (controller-generator) $ git reset --hard 1fb8c97d64f389904b3048fb2850fcfd8425cd36
HEAD is now at 1fb8c97 Integrated friendly routes gem
equalsign:~/workspace/BlogAndPort/db/migrate (controller-generator) $ git push -f origin HEAD
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Everything up-to-date
The problem is still the same as shown in the pictures. db files did not change
If I understood, you are asking to reset your local/master with origin/master.
$ git fetch
$ git reset --hard origin/master
You can back (hard reset) to a commit that was working for you.
$ git reflog # copy the commit-sha where you want to back/reset
$ git reset --hard <commit-sha> # reset to the commit
Now, if all things are ok. Then Force (-f) Push to remote.
$ git push -f origin HEAD # update remote branch

Cleaning Git Repository: Rails Project, added Gems to Repo by mistake

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.

Rails - removing folder from root

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.

Resources