I simply want to edit some commits with git rebase -i HEAD~2 inside the current branch.
I use Ubuntu 10.10 and had to install gvim first to make the command work.
Afterwards, the command opens a gvim window with the normal rebase content.
But when I want to save the file gvim says
“.git/rebase-merge/git-rebase-todo” E212
[Cannot open file to write]
Also the rebase command finishes right after starting (with Successfully rebased and updated refs/heads/master.).
-
When doing the same command with
sudothe rebase works, but afterwards it occurs that files are owned by root and I have no write permissions anymore. -
On my ArchLinux system gvim is opened directly in the terminal where I run
git rebase -iand everything works. - I tried different terminals (Gnome terminal, LXTerminal, XTerm) – always the same problem
What is the problem here and how to solve it? It should work without sudo.
Edit 1
- Some files in
.git/...are owned by root and are read-only. All directories and files in the first level of.git/are owned by me. Withls -l --recursive .git/ | grep rootI tried to detect which files that are but the output does not give the paths of the files… - Should all files in
.git/belong to the user? May this be the reason for the problem?
EDIT 2
- Even after changing ownership and write permissions of all files inside
.gitto user withsudo chown -R user:user .git/andchmod u+w -R .git/(ls -lnow shows sth. like-rw-r--r-- 1 user user) the problem stays the same.
My solution was:
Run
First, I thought it was because my repository was on an ntfs drive so the file permissions wouldn´t work correctly. But even after mounting the drive with correct file permissions the problem stayed the same. Starting vim with the
-foption helps (I read about other people solving it the same way), but I don´t know why.