GitHub | Guia Completo do Iniciante
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
- Verify your settings by running:
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
- Navigate to your project folder in the terminal:
-
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"
- Commit the staged files with a descriptive message:
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
- Link your local repository to the remote GitHub repository:
-
Push Your Changes
- Push your commits to GitHub:
git push -u origin master
- Push your commits to GitHub:
Step 6: Cloning a Repository
- Clone an Existing Repository
- To clone a repository from GitHub, use:
git clone https://github.com/YourUsername/YourRepository.git
- To clone a repository from GitHub, use:
Step 7: Updating and Managing Changes
-
Pulling Changes from GitHub
- To update your local repository with changes from GitHub:
git pull origin master
- To update your local repository with changes from GitHub:
-
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.