What does the Refspec HEAD:refs/for/refs/heads/master generated by eGit/ZendStudio 9 mean? - eclipse

Is set up a Project from Git in ZendStudio 9. (basing on eclipse with eGit)
It generates a quiet normal fetch refspec:
Remote Fetch Specification +refs/heads/*:refs/remotes/original/*
But a very mysique push refspec:
Remote Push Specification HEAD:refs/for/refs/heads/master
In the remote i can see by "git ls-remote" the following:
8db575549dea67a45cea04358f902993c940c4d8 HEAD
16f0939153e6ef12b4596f0d4fb43fa5b8b0246b refs/for/refs/heads/master
8db575549dea67a45cea04358f902993c940c4d8 refs/heads/master
And i have on local machine the message by "git status":
On branch master
Your branch is ahead of 'original/master' by 5 commits.
So, please pay Attention, because my Question is not "What does it means"...
My Question is:
What does this workflow means? What is the Sense?
What is this generated Ref on the Server "refs/for.." for?
Isn't it better to work on a local branch instead of having a ref on the server to push?
Thanks in advance.

One, a usual Gerrit related refspec should be (as commented by jszakmeister in "Gerrit Code Review - Uploading Changes")
HEAD:refs/for/branchname
So, if anything, it should have been
HEAD:refs/for/master
But in your case, you don't need that kind of refspec (since you don't have Gerrit)
Is this a usual way to commit,
No, it is not.
is it a bad default, worth nothing?
In your case, yes, it isn't useful.
This could be a side effect of what this thread mentions:
Indeed, Gerrit is integrated and shipped together with EGit feature. Currently there is no way to disable Gerrit from within Zend Studio.
The bug 347077 "Make Gerrit features Optional" is still open.
the OP tweini comments:
To go out of this trap, iI had to realize, that this ref is creating a branch on remote without a remote tracking branch associated with it.
But to get rid of it is pretty easy:
Change push refspec in .git/config to push = refs/heads/master:refs/heads/master,
Push your local repo to remote git push
Delete the branch on remote git push --delete origin refs/for/refs/heads/master

Related

EGIT Can't connect to any repository - Missing unknown

I just created a new repository on GitHub and trying to initially push my local Java project.
I added the ssh key in my GitHub account, and it's referenced correctly by Eclipse, I assume.
I only get this error message when I'm trying to push:
Can't connect to any repository:
git#github.com:MaximStein/MyProject.git
(git#github.com:MaximStein/MyProject.git: Missing unknown
366362as232d670123a2267b4879bbd01d142426)
Any ideas?
Your Git repository seems to be broken or at least in an invalid state.
The root cause seems to be Missing unknown 366362as232d670123a2267b4879bbd01d142426 which means something (probably the HEAD) points to the object with the hash 366362as232d670123a2267b4879bbd01d142426 (which will be stored in the file .git/objects/36/6362as232d670123a2267b4879bbd01d142426) that does not exist.
In the Git History you might right-click the last commit and choose Reset > Soft (HEAD Only). If commits are missing, you might be able to recover them via the Git Reflog view.
Make also sure your Eclipse and EGit/JGit is up to date (for instance, there was an issue causing a Missing unknown error that has been fixed more than four years ago) and that you do a refresh (F5) in Eclipse after you have executed Git operations on the command line.
Try first if the push would succeed from command line (which means you need in to install Git first):
check you are correctly identified with ssh -Tv git#github.com
check your remote origin URL: git remote -v
check your local status (git status: to make sure you are on a branch, here I assume main, and that you have made at least one commit)
check your initial push: git push -u origin main
Check also if you have declared any submodules (.gitmodules file), or look for any nested Git repository (.git subfolder anywhere beside your repository root folder)
It is helpful to rule out (or not) a git-core issue, before investigation an Egit/JGit one.
And the OP Maxim confirms in the comments:
It's a good idea to try it in the command line first.
It says "fatal: bad object HEAD" when I do git status.
I think I've only made one local commit for that project.
Indeed, making local commits, in a branch, is a prerequisite to pushing anything.
In your case, do a git branch -avv to check if there are any.
If you already pushed that missing commit, assuming your main branch is main (not master):
git fetch origin
git reset --soft origin/main

Can't to push commits from local branch to github repository

I was committing and pushing in ordinary for my repository.
but once i used command of git checkout for change to the previous version of my repository.
after that i tried to commit and push, then it can not completed.
i try to use the --no-verify command to push the commit but it also not success.
error: failed to push some refs to 'https://github.com/ruwanliyanage123/Hair-4-U-Hospital.git'
i want to push my commit into github repository
Since you switched to a previous version of your repository, your head is most probably detached. You can't just go back anywhere in your history and make commits.
Consider making a branch from there and then commit to it.
Try to first check in which branch you are working do git branch, check is the one you are working. Then I sometimes do git pull to just make sure that the connection is working this should not delete your progress the you should be able to do git push. If you are afraid youll mess up first do a local back up of all project files except for the .git one which are hidden by default in windows.Lastly I would suggest never posting the actual link to your github repository in case whatever you are working is important, you can just replace with
https://github.com/user/projectname.git

How can collaborators push their changes to my repo in GitHub

First I have created one project in Eclipse and committed to my GitHub using below commands:git init
git add .
git commit -m "first commit"
git remote add origin URI of my repo
git push -u origin master
Then I modified one file in Eclipse and committed to GitHub from Eclipse through creating remote and giving the remote URI of the repo.
I added my team member through add collaborator.
Then he downloaded my project and made a change in a file in Eclipse.
Now, how can he push that modified file to my GitHub repository from within Eclipse?
We have done one thing. He created a remote and gave the URI of my repo. But still we are unable to commit that file.
You need to add your colleague as a collaborator. This can be done in the desired GitHub repo via Settings > Collaborators (you need to type in your password again). Afterwards they have those permissions.
UPDATE
Sorry and good morning ;)
I overlooked that you already added your partner as a collaborator. Another possible reason for your situation could be in the Temporary interaction limits where you can, amongst others, limit the interaction with your repo to prior contributors.
If that doesn't help. Please add some more informations about your colleague's git logs.
UPDATE 2
#Rahul K regarding your comment (which you better add to your question, for faster recognition), your colleague first needs to integrate the remote changes via git pull origin master in order to be able to push his or her changes afterwards. But be aware that he or she might need to migrate any conflicts to files both of you applied changes to.
Best regards, David
I have resolved the issue by cloning the repo in my local folder, adding the project to eclipse and changing the file committed.
Before that you have to add that person as a collaborator. So that he/she can clone your repo using the command below:
git clone "Path to the repository"
This is an old question but I'll like to say this to help others that might still be facing this same issue.
I also faced this issue with a friend. I already made him a collaborator but he couldn't push. What we did to solve it was to clone the repo using the ssh url instead. Then we set up authentication in git with ssh. And we were able push successfully.
If you already cloned the repo with the usual HTTPS url, you can change the remote origin url using the git remote set-url origin <url> command but url here will be the ssh url.

Github - merging fork into master (locally)

So i have the following problem:
Back when i started programming, i FORKED a repository (using github for windows) for a browser-game. For some time now, i made stuff, did git commit and issued a pull request using the webpage.
The original author did authorize my pull request and my changes went live.
Recently, i have become an "official" author on the original repository.
So i dont want to work on my "fork" any longer but instead dev on the original.
Using github for windows, i decided to "clone" the original repo.
My github now shows my forked (AncientSion/FieryVoid) repository and the original (Aatu/FieryVoid).
Now what i would like to do is somehow "merge" my forked repo into my local clone of the original repo and from there commit to the master repo directly, that way deploying my local, not yet commited changes from my fork to the live version while at the same time getting rid of fork repository.
However, i have no idea if that works and if it does, how.
Can someone please advise ?
I don't think that the Github for Windows interface supports this, but this can definitely be done via the git bash console. This is untested, but the steps ought to be correct, since I've done something similar (identical, in fact) before. This assumes that your clone, AncientSion/FieryVoid, is up-to-date with Aatu/FieryVoid, which can be done with a pull followed by a merge, or, to avoid merge commits, with a git pull --rebase. So now you have AncientSion/FieryVoid and Aatu/FieryVoid, both present locally, with AncientSion/FieryVoid ahead of Aatu/FieryVoid by a few commits. What you need to do is pull in those commits into Aatu/FieryVoid by running the following:
cd path/to/local/clone/of/Aatu/FieryVoid
git remote add local_pull path/to/local/clone/of/AncientSion/FieryVoid
git pull local_pull master
git push origin master
Couple of assumptions:
You were working on the master branch of AncientSion/FieryVoid. If not, replace master in line 3 with your branch name.
origin is a remote that tracks the online repo Aatu/FieryVoid

can't push upstream using EGit

I use EGit in eclipse to pull and push.
my config is:
[remote "origin"]
fetch = refs/heads/*:refs/remotes/origin/*
push = refs/heads/*:refs/remotes/origin/*
local branch is master
Remote Tracking branch is origin/master
when I do push, it comes out "origin/master:master[up to date]". Actually the remote branch is not up to date. I wander if I configure the wrong way.
Sometimes I change different configure, I will get either "create a new branch"(which is wrong, as I just push some commits) or "reject-no fast forward"(which is strange, as I am the only user of the remote repository and I have already fetch before push)
Check with Egit if you aren't in a detached HEAD mode:
If HEAD is "detached", i.e. is not pointing to the tip of a local branch but to a commit or tag, then none or several "checked-out" markers may appear in the tree, since any number of remote branch or tags may point to the currently checked out commit.
The state you are in while your HEAD is detached is not recorded by any branch (which is natural --- you are not on any branch).
(See "Why did git detach my head?" for probable cause, and "Git: How can I reconcile detached HEAD with master/origin?" for reconciliation).
That is a common cause for an "up to date" message when pushing to a remote repo.
After I push to upstream successfully, like version 0.3.9, I continue to change my codes locally and submit a version 0.5.0. This submit should based on version 0.3.9. I don't know why. That's why I have to do merge every time, and sometimes merge make my codes messy.