GitHub | Guia Completo do Iniciante

3 min read 4 months ago
Published on Aug 11, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial is designed for beginners looking to master the basics of Git and GitHub. It covers essential routines, processes, and commands that are fundamental to using these tools effectively. By following this guide, you'll gain a solid understanding of version control and collaboration through GitHub.

Step 1: Setting Up Git and GitHub

  • Create a GitHub Account

    • Visit GitHub's website and click on "Sign up".
    • Fill in your details, choose a username, and set a password.
    • Confirm your email address.
  • Install Git

    • Download Git from the official Git website.
    • Follow the installation instructions for your operating system (Windows, macOS, or Linux).
    • Once installed, verify the installation by running the command:
      git --version
      

Step 2: Configuring Git

  • Set Your Username and Email

    • Open your terminal or command prompt.
    • Configure your Git username and email with the following commands:
      git config --global user.name "Your Name"
      git config --global user.email "your.email@example.com"
      
  • Check Your Configuration

    • Verify your settings by running:
      git config --list
      

Step 3: Creating a New Repository

  • Initialize a Repository

    • Navigate to your project folder in the terminal:
      cd path/to/your/project
      
    • Initialize a new Git repository:
      git init
      
  • Create a Repository on GitHub

    • Go to your GitHub account and click "New Repository".
    • Enter a name for your repository and choose its visibility (public or private).
    • Click "Create repository".

Step 4: Adding Files and Making Commit

  • Add Files to Your Repository

    • Move your project files into the initialized folder.
    • Stage the files for commit:
      git add .
      
  • Commit Your Changes

    • Commit the staged files with a descriptive message:
      git commit -m "Initial commit"
      

Step 5: Pushing Changes to GitHub

  • Connect Local Repository to GitHub

    • Link your local repository to the remote GitHub repository:
      git remote add origin https://github.com/YourUsername/YourRepository.git
      
  • Push Your Changes

    • Push your commits to GitHub:
      git push -u origin master
      

Step 6: Cloning a Repository

  • Clone an Existing Repository
    • To clone a repository from GitHub, use:
      git clone https://github.com/YourUsername/YourRepository.git
      

Step 7: Updating and Managing Changes

  • Pulling Changes from GitHub

    • To update your local repository with changes from GitHub:
      git pull origin master
      
  • Handling Merge Conflicts

    • If there are conflicts, Git will notify you. Open the files to resolve conflicts and commit the resolved files.

Conclusion

In this tutorial, you learned how to set up Git and GitHub, create and manage repositories, and collaborate with others through version control. As you practice these steps, consider exploring additional features such as branches, pull requests, and issues on GitHub to enhance your workflow. Continue building on this foundation to become proficient in version control and collaborative software development.