Git fatal: cannot simplify commit - linux

I have a repo that I have been committing for 2 months. I do not seem to get any error when I commit daily. However I was looking at git logs and I see that first ever git log (or maybe git can't see beyond that log point) has an error message like this
:100755 100755 1948ac6... 2af905e... M document.doc"
error: Could not read 190d54eb3278746a4e35fd4be82689eb4b1d20a8
fatal: cannot simplify commit cb0c2a3bf0a4ad665eb376b818bdcb0652a06eec (because of 190d54eb3278746a4e35fd4be82689eb4b1d20a8)
I tried the recommendation on: https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F
But I did not get what I was trying to achieve, whatever was recommended did not help my case.

This solution could help you:
Make a backup of your .git directory in case you corrupt things more in this process. Then, put back the best version of the packfiles you have available.
For each of the corrupt packfiles, run:
mv .git/objects/pack/pack-**yourpack**.pack oldpack
git-unpack-objects -r < oldpack
Run git fsck --full and git checkout again, give us the output.
Looks like now you should be able to check out, but you will have to run git checkout -f yourbranch, as you have changes in your working dir that are not yet committed. These changes will get lost when you run git checkout -f, though.
Note: This solution was sugested by #Chronial

Related

"commit or discard the untracked or modified content in submodules"

Since this morning I have a problem for committing my work :
I tried several commands to clean up my local repo but I still have the same problem, I have searched well in other topics where the problems encountered were similar to mine but the solutions differ without me being able to adapt anything ...
I await your answers
PS : Sorry for my lack of courtesy but obviously Stack Overflow does not want me to greet you ...
Actually it's not clear what you want to achieve exactly but to add the open change for committing just use
git add conFusion
Then you can commit again.
git commit -m "your description"
And finally push with
git push origin master
wheras origin master never seems to be required in your situation, so just git push will likely be enough.
I'm not sure why git commit -a didn't work, but the reason might be that the message with the parameter -m was missing.
Here you can find documentation about
git add
git commit
git push

GitLab projects failed their last repository check

I have received a gitlab alert mail stating that "One project failed its last repository check".
I did check the error in Gitlab admin panel as "Last repository check (just now) failed. See the 'repocheck.log' file for error messages." As suggested in Admin Panel in Gitlab, i have checked the repocheck.log file and the error is as below.
"Could not fsck repository: error: Could not read 0f188244898707e6090498bc03aafd8ac25e776e
failed to parse commit 0f188244898707e6090498bc03aafd8ac25e776e from object database for commit-graph
error: Could not read 4ab7111f3f8f1083cee8e33ec033c18edfefb0e9"
This happened the same with another repo last week. Even that had similar error message and it is not resolved yet. Tried to clone the same repo in another gitlab instance to recreate the issue but the repo check there seems to be fine.
Unable to find proper solution for that. Could any one please help on this.
It seems to be an active issue: https://gitlab.com/gitlab-org/gitaly/-/issues/2359#note_966195929 The issue is a couple of years old, but the note I link to, has updates from today, including info on fixes and workarounds.
In any case: The commit-graph is a relatively new feature and since it is a form of index into packed data, it can be recreated. So the corrupted repo can be easily fixed without loss of data.
It can be reproduced like this:
Visit a commit graph: Project sidebar / Repository / Graph
Delete one of the visible commits by rewriting history:
git checkout <branch>
git reset head~1
git commit -am "Replace last commit with a new one"
git push --force
Refresh the page of step 1
Now GitLab will send you "A commit graph at GitLab projects failed their last repository check" when it runs the repository check on a scheduled interval.
I'd consider it a bug that admins and maintainers get a warning about this, since nothing is wrong really. See the GitLab issues linked by Anders Bandholm for more details.
I've now come across and fixed this twice, I found the fix on the forum:
Find all your failed repos at your instance's admin panel: https://your-gitlab-instance/admin/projects?last_repository_check_failed=1
Open the repo from that page and copy down its Gitaly relative path, it should look like #hashed/d4/73/c530f048efdf2711df6fa15198ff48003583303624f8b97c174fadc2cab5e582.git
NOTE! The following commands should be run with the user that gitlab runs as. You can do this with sudo su [username], in my case the username was git. They will work with sudo, but it may create files or folders that the gitlab user won't be able to access.
Run the fsck command using the repo's relative path (This should output the same text as your /var/log/gitlab/gitlab-rails/repocheck.log file):
/opt/gitlab/embedded/bin/git -C /var/opt/gitlab/git-data/repositories/[Gitlab relative path] fsck
# example
/opt/gitlab/embedded/bin/git -C /var/opt/gitlab/git-data/repositories/\#hashed/d4/73/c530f048efdf2711df6fa15198ff48003583303624f8b97c174fadc2cab5e582.git fsck
Run the gc command using the repo's relative path. This may take a minute to complete.
/opt/gitlab/embedded/bin/git -C /var/opt/gitlab/git-data/repositories/[Gitlab relative path] gc
# example
/opt/gitlab/embedded/bin/git -C /var/opt/gitlab/git-data/repositories/\#hashed/d4/73/c530f048efdf2711df6fa15198ff48003583303624f8b97c174fadc2cab5e582.git gc
Run the fsck command again from step 3 to check that the command was successful
On the repo's page from step 2, click the blue Trigger repository check button

The "git fetch" does nothing on repo

I noticed with git log origin/master that new a commit is up.
So I want to "see" this commit on my local repo.
I do this
$ git fetch -v
From xxx.xxx:proj/test
= [up to date] master -> origin/master
Everything seems fine... But nothing has changed on my local repo !?
To update your branches (as opposed to your Git's memory of some other Git's branches—git fetch updates this memory only), you must run a second Git command.
The second command to run is sometimes git merge and sometimes git rebase, depending on how you prefer to work. If you have no preference yet, use either one until you do have a preference.
There is a convenience command spelled git pull, that runs both git fetch and then the second command. The second command it runs is the one you tell it to. You must configure it based on your choice of second command to use. I recommend avoiding this until you really understand what the second command is and does, because eventually something will go wrong when running the second command. If you do not know that git pull is running this second command, you will not only not know what to do about this failure ... you won't even know that you need to look for how to fix problems with the other command!

Pull not working - TortoiseGIT / Windows 7 / GIT on Debian + gitolite

i have a weird issue. Im using TortoiseGIT (Win7) and my repositories are placed on a vritual server (Debian), where im using gitolite and SSH keys.
I can clone the repository to my PC, i can run Fetch, Push, Commit, Sync .. everything, but when trying to Pull the changes from server Pushed by other contributor, the following error appears:
git.exe pull -v --progress "origin"
fatal: 'pull' appears to be a git command, but we were not
able to execute it. Maybe git-pull is broken?
git did not exit cleanly (exit code 128)
I don't understand, why just the pull command is not working .. thanks for any help.
I can make a clone of the repository, with the contributed changes .. but can not Pull the changes to created repository on my PC.
I encountered this same issue after changing the git Bash executable sh.exe to be always run as administrator (to get round another problem). It then left git unable to access it under certain scenarios and caused various "Maybe git-* is broken?" errors. Perhaps this might help someone...
Uninstalling old Git and reinstalling the latest build fixed this issue for me.
Here's a link to the installers
Link to get installers
My exact error message was
C:\Program Files (x86)\Git/libexec/git-core\git-pull: line 304: exec: git-merge: not found
fatal: 'pull' appears to be a git command, but we were not
able to execute it. Maybe git-pull is broken?
The error message is very much linked to Git, and comes from help.c:
static const char bad_interpreter_advice[] =
N_("'%s' appears to be a git command, but we were not\n"
"able to execute it. Maybe git-%s is broken?");
That is similar to issue 40 (of another GUI, here terminal-ide).
In that case, it was due to the remote Git installation, which was incomplete
(Comments 3 of issue 19)
git-merge was also missing from install, can be fixed with
$> ln -s git git-merge
in system/bin/
The resolution might not be exactly the same in your case, but it could be related to a faulty Git installation.
I see that you're able to run "git fetch". If you can also run "git merge", running the sequence "git fetch" followed by "git merge" will accomplish the same thing as "git pull".
Source:
http://git-scm.com/docs/git-pull

How can I remove last two commits in git and get my commit 1 as changes in working directory?

Here is the scenario:
On a smallish Ubuntu web server I have a git server running. The website is checked out from git repository. I had a bulk of changes that I added and committed. Git diff showed 50+ code files updated and 20000+ image files. I did not paid much attention to this thinking these should be ignored, my fault. A bit stupid but I thought it was quickest to just commit all changes as a bulk. Let's call it commit A
# Commit A
git add .
git commit -m "Changes so far in this year"
I discovered that I forgot to exclude working/output files (huge number of generated images). Other than these files (around 20000) I had about 50+ files with code changes.
After reading online and git manual I understood that best bet was to update .gitignore and generate a list of files to remove and remove cached. This should remove from commit but not the local folder. Let this be commit B
# Commit B
vi .gitignore
git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
git add .
git commit -m "Cleanup of generated files from commit history"
Trouble is that now my git push fails with following error
git push origin master
Counting objects: 19219, done.
error: pack-objects died of signal 9
error: pack-objects died with strange error
error: child process died of signal 9
error: died of signal 9
error: failed to push some refs to '/srv/gitrepositories/xxxx.git'
Answers on this question about error 9 suggests it might be due to git running out of memory.
My options?
Is commit A & commit B made up of huge
number of objects, which looking at the count above it seems?
Is there a better way to clean this mess up with possible option to remove commit A & commit B altogether from history and get my changes intact?
Idealy I want to go back to stage where my git diff reports only the 50+ code files. Images are now ignored by .gitignore
Can I delete a git commit but keep the changes? Is this what it sounds like? Can I do it twice for both commit A and commit B?
Yes, you can use git reset HEAD~2 to clear the last 2 commit from history permanently while keeping the changes in the working directory, then git push -f to force push your changed history to the remote.
If your repo is shared with others it's not advisable to change your commit history.

Resources