What is eclipse?
One of the integrated development environments (IDE)
Not only can you write the source code as an editor, but it also includes server software and executes the program in a form closer to the actual production, which is a very amazing guy.
What is github?
Click here for github
I won't explain it here, so let's check it out (throw it from the beginning)
Premise of this article
--I am creating an empty repository on github (How to create it)
--Eclipse is installed (this article uses eclipse for Java)
Now, let's upload the project created with eclipse, which is the purpose of this article, to github.
Share your eclipse project on github
First, create a project for uploading
- Click File → New → Other
- Web → Dynamic Web Project → Click Next
- Enter "GitTest" in the project name (any name you like)
- Click Finish
- Right-click on the created project
- Click Team → Share Project
- Git → Click Next
- Check Use or create repository in the project's parent folder
- Click "Git Test"
- Click Create Repository
- Click Finish
- Right click on "Git Test"
- Click Team → Commit
|![git_eclipse07.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/570931/862fbb01-4def-1cac-49d7-b651d7204d67.png)
- Click the green ++ mark
- Enter "1" in the commit message (anything is fine)
- Click Commit and Push
- Enter the clone URL that you copied to the URI (See this article as a bonus)
- Enter your github user ID and password
- Click Next
- Click Next
- Make sure the expected push result is rejected
- Click Finish
- Confirm that the push result is rejected
- Click Close
Let's get rid of the reason for being rejected
The push was rejected, so I checked the github repository and the data was not uploaded
Even if I'm investigating, there are many cases where there is no description on how to break through here, so I will continue to describe how to do it.
- Right click on "Git Test"
- Click Team → Pull
- Click Close
- Right click on "Git Test"
- Click Team → Push Branch
- Click preview
- Make sure the expected push result is not a rejection
- Click push
- Make sure the push result is not rejected
- Click Close
- Sign in to github and make sure it's uploaded successfully
-** If you can confirm it, sharing to github is completed **
What are commits, pushes, and pulls?
――Commit is to save data in the repository of the local PC. In the game, save function to the main unit
--Push is to upload the repository of your local PC to github on the Internet. Sending cloud saves in games
--Pull means to download a repository saved on github on the Internet. In terms of games, receiving cloud saves
Why was the first push rejected?
** Briefly, to ensure data integrity **
At the stage of the first push, the state of the empty repository on github was not received, and if you push it as it is, it may overwrite all the data, so it was rejected
By pulling and receiving the status of the repository on github, the repository and the data I created are consistent, and uploading is now possible.
Original way
If you do not create new file when creating an empty repository and perform this procedure as it is created, the first push will not be rejected (If you do not create a new file, there is no evidence that you have operated the repository, so save it by overwriting No problem)
However, I came to write this article because there was a beginner who was stuck for about 3 days because he shared it on the second and subsequent PCs and accidentally created or messed up a file.