Getting Started with Git

1. Install Git

First, you need to install Git on your computer. You can download it from the official Git website.

2. Configure Git

After installation, configure your Git settings:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

3. Initialize a Repository

Navigate to your project directory and initialize a Git repository:

cd your-project-directory
git init

4. Add Files to the Repository

Add files to your repository to start tracking them:

git add .

5. Commit Changes

Commit your changes with a message describing what you've done:

git commit -m "Initial commit"

6. Connect to a Remote Repository

If you want to push your code to a remote repository (e.g., GitHub), you need to add the remote URL:

7. Push Changes to the Remote Repository

Push your changes to the remote repository:

8. Pull Changes from the Remote Repository

To update your local repository with changes from the remote repository:

9. Branching and Merging

Create a new branch to work on a feature:

After making changes, commit them and switch back to the main branch:

Merge the new feature branch into the main branch:

10. Viewing the Commit History

To see the commit history of your project:

This guide covers the basics to get you started with Git. If you need more detailed information, you can refer to the Git documentation or the GitHub Docs.

Last updated