avatarBhavana

Summary

The website provides a detailed guide on how to push an existing local project to a GitHub repository, including creating a new repository, branching, and using Git commands.

Abstract

The content outlines a step-by-step process for uploading an existing project to GitHub. It begins with creating a new GitHub repository with a README file and instructs users to clone the repository locally, transfer their project files into the new local folder, and commit changes using Git. It emphasizes the importance of branching, demonstrating how to create and work within a new branch called allureReport/bhavana within the Allure-Report-Generation repository. The guide also includes visual aids for each step, from setting up the repository to executing Git commands like git add, git commit, and git push. It concludes by highlighting the benefits of branching for collaborative development without affecting the main codebase.

Opinions

  • The author believes that pushing project code to GitHub is straightforward, effective, and without drawbacks when following the correct steps.
  • Visual aids are considered helpful for users to follow the instructions more easily.
  • The guide promotes the use of branches for project development, suggesting it as a best practice to avoid impacting the main codebase.
  • The process of using Git commands is presented as a standard and reliable method for managing version control and project updates.
  • Creating a README file during repository setup is seen as a useful practice for providing essential project documentation from the outset.
  • The guide encourages learning repository setup and management as a valuable skill for developers.

How to push an existing project to GitHub

Step by step, you’ll get there.

Pushing project code to GitHub requires a few steps, assuming you already have a GitHub account and also learn how to do repository setup. Nevertheless, unlike a lengthy copy and paste, it’s simple, effective, and has no drawbacks.

Follow these instructions to add your project to an existing GitHub repository quickly:

  1. Please make a new GitHub repository with a README file inside of it.

2. To clone the GitHub repository locally, use Git.

3. Transfer your project files to the folder that the clone created.

4. Execute a git add. a git commit, too.

Here demonstrate How to push code to GitHub

You must first build a GitHub repository before you can push an existing local project to GitHub. Simply click the green “Create repository” button in GitHub’s online dashboard.

Create new repository

Create the branch allureReport/bhavana in Allure-Report-Generation repository.

Create a branch in the repository

After you’ve created the branch in the Allure-Report-Generation repository, click the green “Code” button. The GitHub URL is revealed for HTTPS connections. This value should be copied and saved for further use.

URL of GitHub repository

Export the project from Git

Export project from Git

Select Clone the URL and click on the next button

Clone URL

Paste the URL in the highlighted box and click on next button

Source of Git repository

While creating a new repository Allure-Report-Generation with a new branch there are 02 branches shown here the main branch is by default. but we need to select the highlighted branch allureReport/bhavana that we created to push the code. and then click on the next button.

Branch selection

Local git folder source path and Click on the next

Local git directory

Select import existing eclipse project click on the next button and

Import the existing project

then select the project name and click on the finish button. Here we are done with cloning the project with the repository Allure-Report-Generation and to a specific branch allureReport/bhavana

Now copy your project into the local git folder where the Allure-Report-Generation local repository is created.

File explorer of a local git repository

now click on the highlighted area and type cmd, press the enter key. Command Prompt opens with the git path of the project. For example, C:\Users\bhava\git\Allure-Report-Generation

Now here we will see how to push the project code with the help of git commands.

  1. git status: It assists developers in tracking uncommitted changes and understanding how their project files are tracked. so, in the below, I see the folder structure of my project and also know on which branch I am working.
Git status command

2. git add: The git add command adds a modification to the staging location from the working directory. It informs Git that it wishes to include changes to a specific file in the next commit. However, git add has little effect on the repository — changes are not actually recorded until we run git commit.

Git add command

3. git commit: The git commit command saves an instantaneous record of the current staged changes in the project. here is the syntax of the command

git commit -m “Message”

Git commit command

4. git push: The git push command is used to transfer local repository content to a remote repository (Git repository) means content will upload into the Allure-Report-Generation in branch allureReport/bhavana.

syntax of this command is git push origin branch name

Suppose we do not create the branch then commands will go git push origin ( Here origin means main branch )

Git push command

After pushing the code go to the remote repository i.e. git repository Allure-Report-Generation in branch allureReport/bhavana. you will see the project-related files and codes in GitHub

Git repository Allure-Report-Generation in branch allureReport/bhavana

5. git branch: This command simply returns the current branch name.

Git branch command

Branching enables development teams to easily interact within a single core code base. When a developer creates a branch, the system for managing version control produces a copy of the current code base. Changes to the branch have no impact on other team members.

This is how we can push the existing code in the remote repository i.e. in the Git repository.

Happy Learning !!!

Git
Github
Technology
Code Newbie
Codelikeagirl
Recommended from ReadMedium