Here’s a guide to installing Git and setting up your GitHub account:
i. For Linux using Package Manager:
- Open Terminal.
- For Debian-based distributions (e.g., Ubuntu):
sudo apt-get update
sudo apt-get install git -y
- For Red Hat-based distributions (e.g., Fedora):
sudo dnf update
sudo dnf install git -y
ii. Verifying Git Installation:
- Open Terminal and type the following command and press Enter:
git --version
- We should see the installed version of Git displayed.
iii. Configuring Git for the first time:
- Setting up Git with our identity:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
iv. Verifying the configuration:
git config --list
V. Setting Up Your GitHub Account
V. Setting Up Your GitHub Account
i. Visit GitHub:
ii. Sign Up:
- Click on the Sign up button located at the top right corner of the page.
iii. Create Account:
- Enter your email address, create a password, and choose a username.
- Verify your email address by clicking the link sent to your email.
iv. Personalize Account:
- Optionally, fill out additional information like whether you want to receive updates from GitHub, and set your preferences.
v. Finish Setup:
- Complete the CAPTCHA to verify you’re not a robot.
- Click on Create account.
vi. Choose a Plan:
- Select the free plan unless you need the features of a paid plan.
vii. Setup:
- Follow the on-screen instructions to set up your profile and preferences.
VI. Create Your First GitHub Repository
VI. Create Your First GitHub Repository
i. Create GitHub Repository:
- Log in to GitHub
- Click on the + icon in the top right corner / select Create Repository.
- Fill in the repository details (name, description, visibility, README) and click Create repository.
ii. Clone the Repository to Your Local Machine:
- Open Command Prompt or Terminal.
- Clone the repository using:
git clone https://github.com/your-username/my-first-repo.git
- Navigate to the repository directory:
cd my-first-repo
iii. Create and Add a New File:
- Create a new file in the repository directory:
echo "Hello, World!" > hello_world.txt
- Add the file to the staging area:
git add hello_world.txt
iv. Commit Your Changes:
- Commit the changes with a descriptive message:
git commit -m "Add hello_world.txt"
v. Push Your Changes to GitHub:
- Push the committed changes to your GitHub repository:
git push origin main
Git – GitHub: How it works
Git – GitHub: How it works
Key Concepts:
Working Directory: The local directory where you make changes to your files.
Staging Area: An intermediate area where you prepare changes before committing them.
Local Repository: The versioned history of your project stored on your local machine.
Remote Repository: A versioned history of your project stored on a server, accessible over the internet.
Git Commands
git add: Adds changes from the working directory to the staging area.
git commit: Records the staged changes in the local repository with a descriptive message.
git push: Sends committed changes from your local repository to a remote repository.
git fetch: Retrieves updates from the remote repository without merging them into your local branch.
git merge: Combines changes from different branches into your current branch.
git pull: Fetches updates from the remote repository and merges them into your local branch.
git clone: Creates a local copy of an existing remote repository.
git checkout: Switches to a different branch or restores files to a previous state.
Additional resources and references for further learning.
Git Documentation Here
GitHub Documentation Here
Source link
lol