Introduction to Git and GitHub
Introduction to Git and GitHub
What is Git?
Git is a free, open-source version control tool designed to manage changes in code
efficiently. It is fast, scalable, and widely used by developers to track and collaborate on
projects.
What is GitHub?
GitHub is a platform that allows users to store, manage, and collaborate on code using Git. It
provides a centralized location for repositories and additional features like pull requests and
issue tracking.
● Website: https://github.com
●
Key Terms:
○ Repository (Repo): A folder containing project files and their version history.
○
Commit: A snapshot of changes made to files in a repository.
●
Setting Up Git
3.
Configure Git: Open Git Bash or Terminal and run:
Basic Workflow
5.
Link to GitHub:
7.
Make Changes:
8.
9.
Stage and Commit:
11.
Push to GitHub:
Git Commands
Git Branches
Merging Code
3.
Pull Request (PR): Use GitHub’s web interface for safer merging.
Pulling Changes
A merge conflict occurs when Git cannot automatically reconcile differences between two
commits. Resolve manually by editing the conflicting files, then:
Undoing Changes
● Unstage Changes:
●
Undo Last Commit: git reset HEAD~1
●
Revert to Specific Commit:
●
View Commit History: git log (Press q to exit)
Forking
A fork is a copy of a repository under your GitHub account, linked to the original (upstream)
repo. Fork via GitHub’s website to contribute to projects.