I would like to write about the significant challenges and difficulties that my team members and friends encountered when trying to upload the maven project to GitHub.
Let me start with what is GitHub? In simple terms, it is a web-based platform for storing, managing, and sharing code, software projects, and other collaborative work. It’s a place where individuals and teams can work on software development, track changes to their code, and collaborate with others.
Maven is a powerful build and project management tool that simplifies project setup, dependencies, and build processes.Helps to manage the build lifecycle of a project, which includes chores like compilation, testing, packaging, and deployment. Additionally, it manages project dependencies, which simplifies the handling of third-party frameworks and libraries.
Here is the sample maven project in eclipse IDE with screenshot attached below
Login to GitHub repository and create a new Repository to store the project. A repository is like a folder that contains all the files, code, and resources for a project. You keep your work there. When the repository is first created, it appears as shown in the screenshot below.
GitHub Repository Initial View
Create a personal access token for your project by going to Settings->Developer settings->. Then, select No Expiration from the drop-down menu and enter the name of your token.Give access to “repo” under the Select Scopes option so that you can use the token rather than the login and password that it always requests. To utilise the token in the project, click the “Generate Token” button and copy it.The screenshot for reference is provided below.
Copy the GitHub address as seen in Step 1 Screenshot, Example:https://github.com/VidhyaM09/Sample.git
Go to Eclipse workspace > Window > show view > others > Git > Git Repositories > open
Click on “Clone a Git repository” > clone URI > Observe in the window the URI, the token we copied will be automatically filled in there. click Next->Next->The Local folder will be created under git folder in your system.Finally click Finish button.We will be able to see the locally generated repository in the local system, as seen in the screenshot below.
Sample Repository at Eclipse Workspace
Right click on the Maven project > Team > share project. A window will appear where you will select the repository location to place your project.If you observe, you can see the current project location and the target location.Click Finish.You will see the project has been connected to Git,but it will not be shown in Github repository. So we need to push the changes.
Pushing the changes to the GitHub repository is done by selecting Window > Show View > Git Staging > Open.Mvn clean should always be performed before committing any code.There are numerous files in the unstaged changes.Drag and drop the files to the staged changes after choosing the ones that are needed for the project. The files’ screenshot after being dropped under staged changes is shown below using the phrase say(“Helloworld.java”).
Enter the commit message say “First commit” in the opened Git staging window and click Commit and Push.
Here you go, you can see the screenshot as below
Code Pushed Confirmation
Close the window and go to Github repository where you want to place the project. The code that has been committed will be visible if you reload the page or navigate to the project’s directory, as shown in the screenshot below.
GitHub with added Project
Sample Java Program in GitHub
Changed code in Eclipse and pushing the code changes to Github
Click Commit and Push and you will get the Confirmation Pop up Window.click "Close" button.
Final code changes has been reflected in GitHub
Uploading your Maven project to GitHub is a valuable skill that can enhance your development workflow and open doors to collaboration with fellow developers. It's a versatile platform for modern software development, helping teams and individual developers manage their projects more efficiently.You will be fully aware of the sharing your work with Github by following the instructions provided in this guide. If you have any questions or want to share your experiences, feel free to connect with me on Twitter(@VidhyaAkshu) or visit my blog (https://medium.com/@vidhyamanickaraj ). Happy coding and happy collaborating!