0% found this document useful (0 votes)
20 views3 pages

Git Docs

This document is a Git tutorial covering essential commands and concepts for using Git, including configuration, cloning repositories, adding and committing changes, branching, merging, and resolving conflicts. It also explains how to create pull requests and the concept of forking a repository. Each topic includes specific Git commands and examples to illustrate their usage.

Uploaded by

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

Git Docs

This document is a Git tutorial covering essential commands and concepts for using Git, including configuration, cloning repositories, adding and committing changes, branching, merging, and resolving conflicts. It also explains how to create pull requests and the concept of forking a repository. Each topic includes specific Git commands and examples to illustrate their usage.

Uploaded by

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

ChpN: Git Tutorial.

Full Tutorial:

Batch Scripting Tutorial:

https://www.youtube.com/playlist?list=PL8WTXLSrtyWrQ5Tl50zkTeRc3bATyHRbX

Topic 1: Configuring Git

Set Username:
git config –-global user.name "My Name"

Set User Email:


git config –-global user.name "[email protected]"

List Configuration:
git config –list

Topic 2: Clone & Status

Clone – Cloning a repository on our local machine:


git clone <-link-of-repo->
Eg.:
git clone https://github.com/maazshaikh2079/practice_repo.git

Status – display the state of the code:


git status

Topic 3: Add, Commit & Push

add – adds new or changed files in your working directory to the Git staging area:
git add <-file-name->
OR
git add .

commit – it is the record of change:


git commit -m "some message"

push – upload local repository content to remote repository:


git push origin main

Topic 4: Init command

init – used to create a new git repo

git init

git remote add origin <-link->

git remote -v (to verify remote)

git branch (to check branch)


git branch (to check branch)

git branch -M main (to rename branch)

git push origin main

Topic 5: Branch Commands

To check branch:
git branch

To rename branch:
git branch -M main

To navigate:
git checkout <-branch-name->

To create new branch:


git checkout -b <-new-branch-name->

To delete branch:
git branch -d <-branch-name->

Topic 6: Merging Code

Way 1:

To compare commits, branches, files & more:


git diff <-branch-name->

To merge 2 branches:
git merge <-branch-name->

Way 2:

Create a Pull Request

Topic 7: Pull Request & Pull Command

Pull Request:
It lets you tell others about changes you’ve pushed to a branch in a repository on GitHub.

Pull Command:
git pull origin main
- Used to fetch and download content from a remote repository and immediately update the local
repository to match that content.

Topic 8: Resolving Merge Conflicts

An event that takes place when Git is unable to automatically resolve difference in code between two
commits.

Topic 9: Undoing Changes

Case 1: staged chnages


git reset <-file-name->
git reset

Case 2: commited chnages (for one commit)

git reset HEAD~1

Case 3: commited changes (for many commits)

git reset <-commit-hash->

git reset --hard <-commit-hash->

Topic 10: Fork

Fork: A fork is a new repository that shares code and visibility setting with the original "upstream"
repository.

Fork is a rough copy.

You might also like