Git Basics:

1. Installation:

  1. Install Git on your machine. You can download it from [Git's official website](https://git-scm.com/).

2. Configuring Git:

  1. Set your username and email address, which will be associated with your Git commits.

```bash

   git config --global user.name "Your Name"
   git config --global user.email "your.email@example.com"
   ```

3. Initializing a Repository:

  1. Create a new Git repository or initialize an existing directory as a Git repository.

```bash

   git init
   ```

4. Adding Files:

  1. Add files to the staging area before committing them.

```bash

   git add filename
   ```

5. Committing Changes:

  1. Commit the changes in the staging area to the repository.

```bash

   git commit -m "Your commit message"
   ```

Working with Branches:

6. Creating Branches:

  1. Create a new branch to work on a feature or bug fix.

```bash

   git branch branch_name
   ```

7. Switching Branches:

  1. Switch to a different branch.

```bash

   git checkout branch_name
   ```

8. Merging Branches:

  1. Merge changes from one branch into another.

```bash

   git merge branch_name
   ```

9. Checking Repository Status:

  1. View the status of your repository, showing changes and untracked files.

```bash

   git status
   ```

Remote Repositories:

10. Cloning a Repository:

  1. Clone a remote repository to your local machine.

```bash

    git clone remote_repository_url
    ```

11. Pushing Changes:

  1. Push your local changes to a remote repository.

```bash

    git push origin branch_name
    ```

12. Pulling Changes:

  1. Fetch and merge changes from a remote repository.

```bash

    git pull origin branch_name
    ```

13. Adding Remote:

  1. Add a remote repository to your local repository.

```bash

    git remote add origin remote_repository_url
    ```

Handling Conflicts:

14. Resolving Conflicts:

  1. When merging branches, conflicts may arise. Resolve them manually and commit the changes.

```bash

    git mergetool  # Opens a visual merge tool
    git commit -m "Merge conflict resolution"
    ```

15. Viewing Commit History:

  1. View the commit history of your repository.

```bash

    git log
    ```
We use cookies to personalize and enhance your experience on our site. By using our site, you agree to our use of cookies.
  More information about cookies