Skip to content

Git errors

Lars Vilhuber edited this page Jan 25, 2022 · 5 revisions

Git push fails

refspec error

  • Solution: You failed to add a commit message. You should try the commit again, or amend the commit.

Git commit or add fails (on CISER shared systems)

  1. There's a bug with Git on Shared filesystems. While you can run software on the shared drive across all CISER nodes, including this instance (i.e., the U: drive), any Git action will fail using the command line tools.

git commit error

  1. As a workaround, you can do one of two things:
  • on the instance, go into "This PC" -> "C" -> "Users" -> (NetID) -> "Documents" and clone the repository there. However, BEWARE that this will be wiped if you delete the instance! Be sure to commit everything again before leaving.
  • on the instance, copy the existing git clone (the entire directory) to "This PC" -> "C" -> "Users" -> (NetID) -> "Documents". Then git add/commit/push from there.

Git commit fails (remote end hung up unexpectedly)

This typically happens when you accidentally added very large files to the repository. You will need to roll back some changes, and that's not easy. The solution is a bit complicated.

First, verify how many commits are pending (how many did you make). You can usually see this at the top of git status

$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
...

Second, try and remember WHICH of the commits might have made the big adds. Or verify in the git log:

git log --name-status

If you have a LOT of files, this might be a bit difficult, so try to do this other version of the command:

git log --name-status > logstatus.txt

and open up logstatus.txt in your editor (VS Code).

Third, if some of the earlier commits are fine (only small files added), you may want to get them up to the server, by pushing only THOSE small commits. See [https://miteshshah.github.io/linux/git/how-to-push-single-commit-with-git/](how to do that here).

If you get a "hung up" error with that "small" commit, it might not be so small...

So now we have what is needed on the Bitbucket server. So let's fix it.

  • Git clone the repository AGAIN, into a different directory (and in a separate terminal window)
cd ..../Workspace
git clone (URL) aearep-NNNN-clean
cd aearep-NNNN-clean
  • Edit the dot-gitignore (.gitignore) file to exclude problematic directories or file types. For instance, if the .gitignore does not have an entry for a Database File (.dbf) and those are big, add it. It might look like this:
*.dta
*.dat
*.txt
*.shp
*.dbf    <=== just added this entry!
  • Save it, and commit it.
git commit -m 'Edit to the gitignore to exclude (BLA BLA) files`
git push
  • Now let's move over all changes from the messed up repository. We're going to move the ICPSR directory (12345). Don't commit anything until you are sure the git status looks normal
\rm -rf 12345
mv ../aearep-NNNN/12345 12345
git status

This should now show any changes you might have made to your code, but NOT the big data files (those should now be excluded by the dot-gitignore.

  • If all looks fine, then go ahead and try the commit again
git add 12345/code
git add 12345/results
git commit -m 'Updated changes (or whatever you wanted to say)'
git push

If that all goes through, then I suggest renaming the directories to more "normal" names:

cd ..
ls
mv aearep-NNNN aearep-NNNN-messed-up
mv aearep-NNNN-clean aearep-NNNN

and if you are REALLY sure you no longer need any files from the "messed up" one, delete it.

Clone this wiki locally