GIT and GIT Hub - Configuration Command

Git and GitHub Configuration Commands

1. Installation and Setup

Before you start, ensure that Git is installed on your system. If you haven't already, create a GitHub account to access the platform's features.

2. Initializing a Local Repository

To begin working on your project, navigate to your project folder. Right-click in the folder and select "Git Bash Here" to open the terminal.

3. Basic Git Commands

  • Initialize a Local Repository:
    bash
    git init
    This command creates a new Git repository in your current directory.
  • Check Status:
    bash
    git status
    This command displays the current branch, commit details, and any files that are not yet staged.
  • Clone an Existing Repository:
    bash
    git clone <repositoryName>
    Use this command to copy an existing repository to your local machine.
  • Stage Changes:
    • To add a specific file:
      bash
      git add <fileName>
      For example:
      bash
      git add pom.xml
    • To stage all files in the project:
      bash
      git add -A
  • Commit Changes:
    bash
    git commit -m "Your commit message"
    This command commits the staged changes to your local repository.

4. Working with GitHub

  • Login to GitHub: Access your GitHub account.
  • Create a New Repository: Click on "Create Repository" and fill in the required details, including the repository name and visibility (select "Public" for free accounts).
  • Connect Your Local Repository to GitHub:
    • Copy the SSH URL of the newly created repository.
    • Add the remote repository using:
      bash
      git remote add origin <repository URL>
  • Push Local Changes to GitHub:
    bash
    git push origin <branchName>
    This command uploads your local commits to the specified branch on GitHub. You may be prompted to enter your GitHub username and password.

Summary of Workflow With Command

  • Push:
    • Working Directory → git add → Staging Area → git commit → Local Repository → git push → Remote Repository
  • Pull:
    • Remote Repository → git pull → Local Repository → git checkout → Working Directory
By following this structured approach, you can effectively manage your projects using Git and GitHub, ensuring a seamless workflow from local development to remote collaboration. Whether you're a beginner or looking to refresh your skills, mastering these commands will enhance your coding experience.


Post a Comment

0 Comments