0% found this document useful (0 votes)
8 views

Git & GitHub Study Notes

Git is a distributed version control system that allows multiple developers to track changes in source code, while GitHub is a web-based platform for collaboration and storage of Git repositories. Key concepts include repositories, branches, commits, and pull requests, which facilitate project management and code reviews. Best practices emphasize frequent commits, clean main branches, and the use of branches for feature development.

Uploaded by

abrahamsamuel898
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Git & GitHub Study Notes

Git is a distributed version control system that allows multiple developers to track changes in source code, while GitHub is a web-based platform for collaboration and storage of Git repositories. Key concepts include repositories, branches, commits, and pull requests, which facilitate project management and code reviews. Best practices emphasize frequent commits, clean main branches, and the use of branches for feature development.

Uploaded by

abrahamsamuel898
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Git & GitHub Study Notes

Introduction to Git & GitHub


What is Git?

●​ Git is a distributed version control system used to track changes in source code during
software development.
●​ Created by Linus Torvalds in 2005.
●​ Allows multiple developers to work on a project simultaneously.
●​ Provides features like branching, merging, and history tracking.

What is GitHub?

●​ GitHub is a web-based platform that uses Git for version control and collaboration.
●​ Offers cloud-based storage for Git repositories.
●​ Provides features like pull requests, issue tracking, and project management.

Basic GitHub Terms


Repository

●​ A storage space where your project files and version history are kept.
●​ Can be local (on your computer) or remote (on GitHub).

Branch

●​ A parallel version of a repository.


●​ Used to develop features separately from the main codebase.
●​ The default branch is usually main or master.

Commit

●​ A snapshot of changes made to a file or set of files.


●​ Helps track the progress of a project.

Stage
●​ The process of adding changes to the staging area before committing.
●​ Prepares changes to be committed to the repository.

Merge

●​ Combines changes from one branch into another.


●​ Often used to integrate feature branches into the main branch.

Clone

●​ A copy of an existing repository that is downloaded to your local system.

Pull Request (PR)

●​ A request to merge changes from one branch or fork into another repository.
●​ Allows for code review and collaboration before merging.

Fork

●​ A copy of someone else's repository that is stored in your GitHub account.


●​ Allows you to make changes independently of the original repository.

Remote

●​ A connection to a repository hosted on a server like GitHub.


●​ Allows pushing and pulling changes to and from remote repositories.

Conflict

●​ Occurs when changes from different sources overlap and Git cannot automatically
resolve them.
●​ Requires manual resolution.

Installing Git
Windows:

1.​ Download from https://git-scm.com/


2.​ Install and configure with default options.
3.​ Verify installation: git --version
Basic Git Commands
Configuration

●​ git config --global user.name "Your Name"


●​ git config --global user.email "your.email@example.com"
●​ git config --list

Creating a Repository

●​ git init: Initializes a new Git repository in the current directory.

Cloning a Repository

●​ git clone <repository_url> : Copies an existing repository to your local machine.

Staging and Committing Changes

●​ git add <filename>


●​ git add .
○​ Stages changes for commit.
●​ git commit -m "Commit message"
○​ Saves changes with a descriptive message.

Checking Status and Logs

●​ git status
●​ git log

●​ Shows working directory status and commit history.

Branching and Merging

●​ git branch <branch_name>


●​ git checkout <branch_name>
●​ git merge <branch_name>
○​ Creates, switches, and merges branches.

Pushing and Pulling Changes


●​ git push origin <branch_name>
●​ git pull origin <branch_name>
○​ Sends or retrieves changes from a remote repository.

Resolving Merge Conflicts

●​ Conflicts occur when changes overlap.


●​ Use git status to check conflict files.
●​ Manually edit files to resolve conflicts.
●​ Stage and commit resolved files.

Working with GitHub


Creating a GitHub Repository

1.​ Go to GitHub and log in.


2.​ Click on New Repository.
3.​ Initialize with README (optional).
4.​ Copy the repository URL.

Connecting Local Repository to GitHub

●​ git remote add origin <repository_url>


●​ git push -u origin main

Forking a Repository

●​ Copies a repository to your GitHub account for personal development.

Pull Requests

1.​ Commit changes to your forked repository.


2.​ Navigate to the original repository.
3.​ Click New Pull Request.

Issues and Collaboration

●​ Use the Issues tab to report bugs or request features.


●​ Collaborate by assigning tasks and discussing improvements.
Useful Git Commands Summary

Command Description

git init Initialize a new Git


repository

git clone Clone a repository

git add . Stage all changes

git commit -m Commit changes


with a message

git push Push changes to


remote

git pull Pull changes from


remote

git status Show current status

git log View commit history

git branch Manage branches


git merge Merge branches

Best Practices
●​ Commit frequently with meaningful messages.
●​ Use .gitignore to exclude unnecessary files.
●​ Keep your main branch clean and stable.
●​ Use branches for feature development.
●​ Always pull before making new changes.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy