I'm using Git (from the GitHub for Windows distro) and trying to pull from my repo and I get the following error:
D:\Code\dopey-weaver [master]> git fetch
error: cannot open .git/FETCH_HEAD: Invalid argument
D:\Code\dopey-weaver [master]> git fetch --verbose
error: cannot open .git/FETCH_HEAD: Invalid argument
This isn't the "Permission denied" of many other questions, so it seems like I'm a special snowflake... I can open .git/FETCH_HEAD and it looks fine(?):
010779f14f5bdf1d2d806a0ce0ac4c5e50314186 branch 'master' of https://github.com/nicktimko/dopey-weaver
I think I have some conflict with what's on the remote so I should be pulling/merging, but I can't even fetch to start... The error message on push does look a little long (is this the equivalent of hg saying "this would create multiple heads" in not so many words?)
D:\Code\dopey-weaver [master]> git push
To https://github.com/nicktimko/dopey-weaver.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/nicktimko/dopey-weaver.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
The problem appeared to be because the volume (an exFAT drive) was dirty, thus read-only, and needed to be run through chkdsk. So, to solve:
Launch PowerShell/CMD in elevated mode (easy way being to right-click on the short-cut in the Start menu and pick "Run as administrator")
Run chkdsk on the desired volume, e.g. chkdsk D: /X (/X forces a dismount)
If you're having this problem on the primary partition (C:), you'll probably have to do chkdsk at startup...somehow.
Related
I'm working on some CI automation involving pushing to a git branch, using git on Windows (Git 2.34.1).
My problem is whenever I push to my upstream branch, and the push fails because since starting my CI job, that branch has been updated by something else, and so I need to rebase.
I run git pull --rebase -Xtheirs, yet the pull command fails, and I see lots of these errors, for every branch in the repository (i've just included a couple here, because we have hundreds of branches):
error: cannot lock ref 'refs/remotes/origin/custom-branch/test?': Unable to create 'C:/r/w/cover/CF/SpringProject/.git/refs/remotes/origin/custom-branch/test?.lock': Invalid argument
error: could not remove reference refs/remotes/origin/custom-branch/test?
error: cannot lock ref 'refs/remotes/origin/custom-branch?': Unable to create 'C:/r/w/cover/CF/SpringProject/.git/refs/remotes/origin/custom-branch?.lock': Invalid argument
error: could not remove reference refs/remotes/origin/custom-branch?
To me, it looks like it's trying to create a branchname?.lock file for every branch, yet because ? is an invalid character in Windows, it's unable to do this and thus doesn't get anywhere.
Have people seen anything this before? I've upgraded from Windows Server 2019 to Windows Server 2022, but I don't see how that could make any difference to this?
I set up a Debian server that uses SSH for shell access and git repos. I created a bare repo on it and using ssh was able to clone it to my Windows 8 workstation, however when trying to push changes back to the Debian server I get the error depicted here:
Read from remote host 174.52.5.192: Connection reset by peer
fatal: sha1 file '<stdout>' write error: invalid argument
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git#174.52.5.192:/home/git/repos/space-junk.git/'
I use this work station regularly for shell access to the same server via SSH so I know inability to access SSH isn't the problem.
Does anyone have any idea what's going wrong?
Actually, the first push should be:
git push -u origin master
That will link the local branch master to its remote tracking one origin/master
Then, after that first push, you will be able (for all the subsequent push) to do a simple:
git push
See more at "Why do I need to explicitly push a new branch?".
I got it working! It turns out the proper command was
git push origin master
The Windows version didn't have a descriptive enough error message but I got it working by switching over to Linux, which told me my command was wrong.
I had an issue where I accidentally copied a directory into a subdirectory of itself thus creating thousands of git transactions. After unsuccessfully trying to clean that up, I decided to create a new project and copy the files over from the old one. Somehow I think I've messed git up, but I'm not sure where the problem is. Here are my current symptoms.
I thought I initialized the git repository correctly. However, none of the files exist on github.
https://github.com/victorengel/matchismo2
... except what I created there.
The project itself is an iOS single view application that I created with git enabled. I copied over all the files I needed from the old project to the new project area, confirmed that it ran, and then tried a commit. The commit seemed to work, but the push didn't.
If I tried a push, I got a message that the working copy is out of date and that I should do a pull. If I tried a pull, it said there were uncommitted changes and I should abandon them or commit them. After some rooting around, I figured out that the change triggering this was a user data change that should have been ignored in .gitignore.
I finally have the .gitignore set up the way it needs to be. I think the repository is set up right on github.com, but I'm still getting errors.
I can commit but not push. If I try to push I get the message "Working copy out of date. Try pulling from the remote to get the latest changes, then push again."
If I try a pull, I get the message "matchismo2/master" is not a valid remote branch to pull from. Please choose a different remote branch.
Looking around at github.com, there is only one branch, master under victorengel/matchismo2. To me it looks like everything is set up properly, but apparently I'm missing something. What is it?
In Xcode, in the organizer, if I click on Branches, there is one item listed: master.
If I click on Remotes, there is one item, matchismo2, and if I expand it, master is listed.
I've been assuming this matchismo2 with master underneath it is what is supposed to match the "matchismo2/master" that's in the error message. Looks like a match to me, so why isn't it working?
EDIT:
If I try pulling from the GitHub application, I get an error message "There aren't any remote branches on the server yet." If I try publishing from GitHub, I get the following:
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
2013-03-05 16:32:43.680 GitHub for Mac Login[68518:707] AskPass with arguments: (
"/Users/brillig/Downloads/GitHub.app/Contents/MacOS/GitHub for Mac Login",
"Password for 'https://victorengel#github.com': "
)
2013-03-05 16:32:43.763 GitHub for Mac Login[68518:707] Error reading attributes: OSStatus -2033889429
2013-03-05 16:32:43.764 GitHub for Mac Login[68518:707] Error reading attributes: OSStatus -2033889429
2013-03-05 16:32:43.919 GitHub for Mac Login[68518:707] Error reading attributes for password: OSStatus 840183217
git: 'credential-osxkeychain' is not a git command. See 'git --help'.
To https://victorengel#github.com/victorengel/matchismo2.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://victorengel#github.com/victorengel/matchismo2.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
(256)
How about ensuring all your files are in order, renaming your branch, and pushing to the new (renamed branch) ? Then once you determine everything you need is actually there and your new code works, you can force update the master. Not an ideal way to do it, but it might work for you.
Using Windows 7, we have a bare GIT repository set up on a network drive so that multiple users can pull/push from it. I am able to create a new working repo on my local and multiple other networked drives. However, when I try to clone a new working repository on the same network drive (different folder) , it fails.
Using TortoiseGIT, after I right-click and choose "GIT Clone", put in all of the necessary paths to my bare repo (the new working repo is already filled in) and hit ok, I get the following error:
Cloning into 'R:\path\to\new\repo'... done.
error: refs/remotes/origin/master does not point to a valid object!
error: Trying to write ref refs/heads/master with nonexistent object 5d2164db2c61efc7a5598f6ff75ed3fbbb12456e
fatal: Cannot update the ref 'HEAD'.
fatal: The remote end hung up unexpectedly git did not exit cleanly (exit code 128)
and it fails to create the repo. It does however build the new folder & ".git" subfolder structure.
It's not a r/w permissions issue because I can r/w any other files, but just cannot seem to create this newly cloned repo. My co-worker cannot either. Even if I got to another folder on the network drive, I still cannot clone the repo successfully. Surprisingly, if I just copy/paste a repo I created in another location, then manually do a "pull", it works and updates successfully.
Any ideas on what to try next? Obviously I've Googled "exit code 128" and "cannot update the ref 'HEAD'" but cannot find a solution to my issue. It's probably something really simple that we are overlooking, but we're just getting started with GIT and this is really causing us headaches...
UPDATE: I just noticed that when I do a manual pull from GIT to my "copy", it is doing a Fast-Forward. Maybe this provides some additional clues?
From R:/path/to/repo
* branch master -> FETCH_HEAD
Updating 5d2164d..d75bdb7
Fast-forward
Files.py | 3 +++
1 file changed, 3 insertions(+)
Success
Git might be trying to do some smart stuff with hardlinks that fails on the network drive. Try using git clone --no-hardlinks /r/path/to/my/repo or git clone file:///r/path/to/my/repo
Please do this via command line in msysgit
git clone /r/path/to/my/repo /r/some/other/path
Further, I would recommend using git from the command line as it is a tool that was designed to be used from the command line. You will be able to find more help, faster, with any issues that come up for you.
So to make a long story short, I've been working on a web app for the past few months. Recently I had to get a new laptop and cloned the repository from github onto my new machine... However whenever I commit changes to my app and attempt to use git push -u in the app's root directory i get the following message:
To git#github.com:acc/etc.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#github.com:acc/etc.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
but when I try git pull git#github.com:acc/etc.git master I get a message telling me that the pull was aborted.
From github.com:acc/etc
* branch master -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
config/routes.rb
test/fixtures/users.yml
Please, commit your changes or stash them before you can merge.
Aborting
so then i commit my changes using git commit -m 'fixing' and then attempt git pull again.
however this time I got messages stating that practically all my files had an "Auto-Merging CONFLICT"
am i totally screwed with this particular repository? I'm not really sure what to do since git is still somewhat new to me....
am i totally screwed with this particular repository?
No, but you will have to do a manual merge, since Git can't figure it out. git status will tell you which files need editing. The files themselves contain markers indicating where you should edit. When that's done, git push should work again.
If the changes aren't that big, consider making a copy of the entire folder/project in a different directory outside of the project, then git reset --hard HEAD will wipe out, erase and delete your recent changes.
You can then apply them again individually using your save3d copies for refernce.
Make sure sure you git add before git commit of course.
Finally if you get auto commit merge issues you can always just edit the files manually to resolve.