How can I update or synchronize my existing GitHub repository from IntelliJ idea - github

I created a project called Spring-Web-App in IntelliJ Idea and push it to GitHub on the main branch.
now, I have updated a bit of code and locally created a new branch called CreatingViews (from the main branch) in IntelliJ Idea and also added these updated codes to this new Branch (CreatingViews).
I have tried to push it on GitHub by clicking on Git -> GitHub -> Share Project on GitHub and afterward received this error: Project already exists on GitHub
My problem now is updating this new branch on GitHub from IntelliJ Idea so these changes can be synchronized and reflected.
I have tried to update my existing repository on GitHub from my local project in IntelliJ Idea.
I am expecting the repo on GitHub to be updated or synchronized with the local one that is in IntelliJ Idea instead of creating a new repository on GitHub.

A push to remote repository is done via Git | Push.
Share project on a GitHub does an "initial push" in order to publish a project on a GitHub.
All further commits should be pushed with a Push action that can be found either in Git menu or on a toolbar.
Please see here:
https://www.jetbrains.com/help/idea/commit-and-push-changes.html#push

Related

How to fix the structure of the project on GitLab?

I have a problem with my project in Eclipse IDE.
For the first time, I worked on an old version and made several changes.
I tried to upload the project on GitLab for the first time I configured Git on Eclipse IDE and I tried to commit and push "but I could do that only after doing a 'Fetch' from the remote branch and commit the 'Merge' change in my local repository.
Because I got this error:
rejected non-fast-forward
I followed this link Egit rejected non-fast-forward to fix it.
The fetch downloaded all the git project files in my project on Eclipse. Until now in my project, I have a subfolder like this: myProject/myProject.
I made several commits and push and it works normally. I figured out that a subdirectory in gitLab docroot is created with every push I make.
This is the local project structure:
This is the project structure on GitLab:
I want to delete docroot/WEB-INF/classes from GitLab.
How to delete this commit from GitLab using git plugin in Eclipse and how to correct my local project structure?
docroot/WEB-INF/classes is a folder. Git does not track folders, only files:
To delete a folder, you have to delete all the files in it.
In the Git Staging view, commit the deletions.
Make sure your current local branch is configured as When pulling: Rebase (in the Git Repositories view right-click the branch and choose Configure Branch...)
Git > Pull to make sure your commit is the latest commit in the upstream branch. If there are conflicts, you have to resolve them in the Git Staging view
Git > Push to Upstream
For details see the EGit User Guide and be aware that old Stack Overflow answers refer to outdated version of EGit.

Correct process to merge fork changes into GitHub

I am new to GitHub. I don't know the correct process to merge my changes with the upstream. I followed following steps using EGit (I like to use it because I find it simple). Please help me.
On GitHub I created a fork.
For my fork I cloned a repository in Eclipse and imported respective projects.
In remotes, I added one more for the main project say Upstream(from where I forked) on GitHub.
I added some changes into my local repository.
How can I do the following part? -
Now in the meantime other people added some changes to the upstream. Now I want to integrate my changes(in the fork I created) to the latest changes(upstream) using EGit and push it to my repository and send a pull request.
Please help me.
create another remote corresponding to your fork in Eclipse
publish (push) your changes into your fork repo on github
create a merge request from the web interface in the original github repo, pointing to your changes on github
There is the procedure, how I do it.
GitHub browser UI
delete your fork with too much mess, if exists - this is in your Settings -> Danger Zone, the button is in upper menu bar in the root of fork
fork for you a new one on the foreign page, where I have access
open newly created fork and copy URI to the clipboard
Git perspective in Eclipse
create clone of your fork in my GUI Eclipse
Create a new branch in local branches and activate it
Import project from working tree in Eclipse as general project from Git perspective to actual workspace
do changes, integrate your important files to the general project (add to index etc.)
commit, push
GitHub browser UI
create Pull request from your fork directly from actual branch (recommended) or after merge in master branch
Notice, that in the picture is merge branch selected. In our real case is better to use the name, which is more descriptive.

Egit can't fetch README changes

I'm using Eclipse 4.2.1 and EGIT. I've done the following:
Created an account on Github.
Created a Repo and initialized it with a readMe from Github at the time I created it.
Cloned the repo using EGIT.
Created a Java project in Eclipse, a single class with a main method.
Share the project with GIT. Team-> Share Project-> GIT
In the Configure GIT repo dialog: Selected the repo I just cloned from Github.
Do a commit.
Push to remote origin.
Go back to Github and make a change to the readMe. (This shows in the commits on Github)
Fetch the changes with EGIT.
The changed readMe is shown in the remote tracking branch in EGIT but not in my local master branch. I tried refreshing but it still doesn't work. After doing this my local master is one behind and I can't push. I get rejected non-fast forward.
I can fix this by creating a new local branch based on HEAD then merging it into my local master. But why is this happening? Is anyone else experiencing this?
Fetching only gets the changes from github into the remote tracking branch (imagine this as a kind of index) on your local machine, but not into your working directory (the real files you edit). You still have to merge the remote changes into your local branch (which you can do by expanding the repository node Branches -> Remote Tracking -> origin/master and selecting "Merge" in the context menu).
If you always just want to fetch and immediately merge the remote changes, use the "Pull" command instead of the "Fetch" command, it is a combination of fetch and merge.

Eclipse Egit: Update a github fork to merge changes of master repo?

I have forked a github repo. Now my worked repo is out of sync with the original repo.
I understand that I need to do a merge, but how to do this with Eclipse git is a bit unclear to me.
Question: How do I update my fork to include changes made to the original repo made by the owner?
Edit 1: I've added another remote. But I don't see any Pull buttons on the context menu:
You do the merge on your local machine and then push the result from your local machine to your own github repo. There is no way to update your github repo directly on the server.
To do that, add that original github repo as a new remote. This is described in the egit user manual. Choose "configure for fetch" instead and give it the URI of the original repo. Afterwards you can simply use the context menu "Pull" on that new remote node to fetch and merge all the new stuff. After finishing the merge, you "Push to upstream", which is your own github repo.
Try the second url under upstream to push your changes. The first one ist just for fetching (see the green/red arrows ;-)

How do I get my new eclipse branch to show up as a new project in my github repository?

I am working through a programming book and I want to branch off of master for each chapter, then merge back to master once the chapter is completed, but have the chapter specific branch show up in my github permanently. What is the best way to do this through the eclipse gui? I have already created the branch in eclipse, but I can't get it to create the duplicate project branch in github.
Github repository
-master
-chapter1
-chapter2
If your "Team => Push to Upstream" is grayed, you need to specify the upstream address of your local Git repo in your Eclipse Egit configuration: see "Eclipse/Egit, Push to Remote menu choice is grayed out".
Check also your SSH2 config in the same EGit.
Finally, click on "Add all branches spec" in order to push all your local branches to the upstream repo:
Did you push the branch?
git push origin chapter1
git push origin chapter2
...etc...
(Note: If you're using a graphical interface for git in eclipse you might consider adding that information to the question.)