GIT AND GITHUB:
Presented By : Abdur Rehman Shah.
GIT:
• Git is a version control system. It is :
Popular
Free and open source
Fast and scalable
• Version control system is a tools that helps to track changes in code.
GITHUB:
• GitHub is a platform for hosting and sharing Git repositories online.
• It provides collaboration features like issue tracking, pull requests, and code
review.
• It's a place where developers can contribute to open source projects and
collaborate with others.
PURPOSE OF GIT:
• Keeps track of changes: Git helps you remember every change you make to
your code, like a history book for your project.
• Makes teamwork easier: It lets multiple people work on the same project at
the same time without messing things up for each other.
• Acts as a safety net: If something goes wrong with your code, Git allows you
to go back to an earlier, safer version.
PURPOSE OF GITHUB:
• Provides a home for your code: GitHub is like a house where you can store
your project's code safely.
• Encourages teamwork: It helps people collaborate on projects by providing
tools for discussion, sharing ideas, and working together.
• Supports open source: GitHub is a hub for open source projects, allowing
anyone to contribute to or use code for free.
CONFIGURING GIT:
• Git config - -global user.name “My Name”
• Git config - -global user.email “email”
GIT COMMANDS:
GIT INIT:
• Initializes a new Git repository in your current
directory.
• git init
• .git repository
• git remote add origin <link>
GIT CLONE[URL]
• Copies an existing Git repository from a remote server
to your local machine.
GIT STATUS:
• Shows the current status of your working directory and
staging area.
GIT STATUS:
• Shows the current status of your working directory and
staging area.
Untracked.
Modified.
Staged.
Unmodified.
GIT ADD:
• Adds changes in a file to the staging area, preparing
them to be committed.
GIT COMMIT:
• Commits the changes in the staging area to the
repository with a descriptive message.
GIT PUSH:
• Uploads local repository content to a remote
repository.
• git push origin main
GIT BRANCHES
• git branch
• git branch –M main (to rename branch)
• git checkout <branch name>
• git checkout –b <new branch name>(to create new
branch)
• git branch –d <branch name> (to delete branch)
MERGING CODE
• Way 1 :
• git diff <branch name> (to compare commits, branches , files and more)
• git merge <branch name> (to merge two branches)
• Way 2 :
• Create a PR.
RESOLVING MERGE CONFLICTS:
• An event that takes place when Git is unable to automatically resolve
differences in code between two commits .
GIT PULL:
• Fetches changes from a remote repository and merges
them into your local branch.
• git pull origin main
UNDOING CHANGES:
• Case 1 : staged changes
• git reset <file name>
• git reset
• Case 2 : committed changes(for one commit)
• git reset HEAD-1
• Case 3 : committed changes(for many commits)
• git reset <commit hash>
• git log
FORK:
• A fork is a new repository that shares code and visibility settings with the
original upstream.
• Fork is a rough copy.
THANK YOU