Gitlab : fetching works but not pushing - push

I forked a project and fetch from amain project, but when i try to push into a my forked project i get
"can't connect to any repository..."
-I use Egit in eclipse-
the location of the destination repository, is defenetly right, because in the next step I can chose the target ref Name and there I can chose my branch.
Did i miss any read and write permissions or whats wrong there?

Goto the GIT Repositories View(Window -> Show View -> Others->(in the text filter) GIT Repositories ).
Check the Remotes -> Origin
If this Push and Fetch are missing
Right click on the Remote -> Add origin and configure
Check for the .gitignore file in your working directory which might sometimes help my friend.

Related

Push to main instead of master from eclipse to git

I have been searching and I found git commands to change the repository but I'm new on github and I don't know how to make that from eclipse, everytime I push I make the changes on the master branch instead of the default main, when I try to push the main it says non fast forward and I can't do it, thanks.
Select Team > Advanced > Rename Branch
Rename local as main
Rename remote to main
when you first commit your project in eclipse and then you click on push
after filling the information of the repository you get this
you will write main here insted of master and your project will be pushed directly to the default main
my solution is only when you first upload your project to GitHub

How do I get a new branch to show up in Eclipse Git Remote Tracking?

I have an existing Eclipse git project, with a master and development branch present in both local, and remote tracking. I have just added a new branch in my git repository, but I can't figure out how to get it to show up in Eclipse.
I have tried to read up on the subject, but it seems like it is just expected to automatically show up. I have found a lot of similar questions, but they all seem to deal with the issues of a completely empty remote tracking folder, instead of my problem of only a single new branch missing. I already have Master and Develop present.
Here is what does not work:
Clicking refresh in the Git repositories window.
Any kind of synchronize, pull or other update I can find
Here is what would work:
Right clicking the remote tracking folder, and selecting "Paste repository path or URI". If I do that, and select the exact same path as is already there, I can see my new branch. This action does require that I completely clone the whole repository to an empty folder again, and that can't be how this is intended to work.
I believe it might work to use some kind of command line tool, but I really want an Eclipse solution to this, as I feel sure it exists, and I am just missing something.
In the Git Repositories view:
Right-click the repository and choose Fetch from Upstream
If the new branch will not shown up below Branches/Remote Tracking, you have to configure fetch:
Right-click the fetch node below Remotes/origin and choose Configure Fetch...
In the Configure Fetch make sure there is only the single Ref mapping (assuming the remote is named origin) +refs/heads/*:refs/remotes/origin/*:
In case you do not see Fetch from Upstream after right-click the repository, you may look for Fetch from origin.
For me the solution was almost what Joshua suggested, however it did not work as described. For me the solution was to configure the [remote "origin"] property as follows:
[remote "origin"]
url = your_git_url.git
fetch = refs/heads/*:refs/remotes/origin/*
Alternatively, you can do it from the Eclipse UI too:
Fetch from origin... then hit Configure... and in the configuration window hit Advanced... and there you have the option to Add predefined specification where you can selec Add All Branches Spec. This will result in the same configuration as above:
Maybe you have to remove your original entry which will be pointed out as a duplicate by Eclipse.
You need to modify the "config" file in your local git repository folder. For example, you cloned a remote branch Project into c:\git\MyProject local folder. In this folder there is a hidden folder ".git" that has a "config" file. There is a section in this file resembling the below
[remote "origin"]
url http://xxxxxxxxxxxxxxxx
fetch = +refs/heads/Project:refs/remotes/origin/Project
You need to modify this section as below
[remote "origin"]
url http://xxxxxxxxxxxxxxxx
fetch = +refs/heads/:refs/remotes/origin/
Then go back to Eclipse IDE, right click on the repository and do a "fetch from origin". Now all the branches will show up.
What I did:
1: disconnected.
2. refresh and pull. Then, it shows the new branch
3. create local and pull.

Eclipse Git (egit) pull and push to upstream option not available some times.?

Right click on Project -> Team -> push and pull not available(EGIT)
Eclipse pull and push to upstream option not available some times.?
i am able to see commit every time but push ,pull,remote are missing some times
How to make appear them always
Basically your eclipse is disconnected with git.
Right click on project -> Team -> share Project -> Select Repository type as git -> Next -> chose your project and finish.
For me this disappeared as well, while the .git/config is unchanged and good.
Refresh did not help.
But Eclipse restart did the trick.
The options disappear sometime if the EGIT is not able to find the path from which it should Fetch, Pull and Push.
Check if the origin is deleted.
Goto the GIT Repositories View
See for the Remotes -> origin
If the Push and Pull in origin are deleted. You will have to add the URI by right click on the origin, add origin and configuring the Push and Fetch URI.
I hope this will be helpful.
Yes, this is a frequent annoyance. If Refresh doesn't work, I use "Close Project" followed by opening it again.

EGIT rejected non-fast forward

I'm on Eclipse 4.2.1 (Java) and trying to use EGIT. My account is all set up on Github. No one else is working on it so there are no changes. I have a very simply project containing a single file with one print statement.
I created my local repo and added the project. (project explorer shows: [gitrepo1 master])
In project explorer:
right click on project -> team -> remote -> push
But I get: master: HEAD [rejected - non-fast-forward]
I've configured the push:
Branch -> master
URI -> ssh.git#github....
Ref mappings -> HEAD:/refs/heads/master
What am I doing wrong?
We had this problem, because we amended a commit after pushing it.
The solution was to merge origin/master (in Branches > Remote tracking), then push.
egit works by using jgit which is an implementation of git that is using java. the best thing to do is verify that the repo works with the normal git client. From your question it is not possible to know exactly how things ore configured.
When you get the error message that you could not do a push because it is not a fast forward, it means you need to do a pull first then, do the push, so try that.
Same cause as BernĂ¡t: I amended a commit after pushing it. Merge failed because of conflicts.
My way out: Context menu 'Team/Reset' selection 'Remote Tracking'/'origin master' option 'Mixed'. After that all my changes since last push were marked and I could commit and push.

How do I set up Eclipse/EGit with GitHub?

I've never used Git before and would like to learn.
I have a private repository with GitHub.
I've installed the EGit plugin for Eclipse.
I have a workspace where I do my work, generally: ~/Documents/workspace.
I am able to add my GitHub repository and download it, but in doing so it creates ~/MyRepository.
When I create a project, do I need to point it to ~/MyRepository?
Also, how come when I make an edit and I say push to upstream it says up to date?
Make sure your refs for pushing are correct. This tutorial is pretty great, right from the documentation:
http://wiki.eclipse.org/EGit/User_Guide#GitHub_Tutorial
You can clone directly from GitHub, you choose where you clone that repository. And when you import that repository to Eclipse, you choose what refspec to push into upstream.
Click on the Git Repository workspace view, and make sure your remote refs are valid. Make sure you are pointing to the right local branch and pushing to the correct remote branch.
In Eclipse, go to Help -> Install New Software -> Add -> Name: any name like egit; Location: http://download.eclipse.org/egit/updates -> Okay. Now Search for egit in Work with and select all the check boxes and press Next till finish.
File -> Import -> search Git and select "Projects from Git" -> Clone URI.
In the URI, paste the HTTPS URL of the repository (the one with .git extension). -> Next ->It will show all the branches "Next" -> Local Destination "Next" -> "Import as a general project" -> Next till finish.
You can refer to this Youtube tutorial: https://www.youtube.com/watch?v=ptK9-CNms98
Install Mylyn connector for GitHub from this update site, it provides great integration: you can directly import your repositories using Import > Projects from Git > GitHub. You can set the default repository folder in Preferences > Git.