[go: up one dir, main page]

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

Git Guide

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)
20 views4 pages

Git Guide

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/ 4

Installation:

GitHub for Windows https://windows.github.com

GitHub for Mac https://mac.github.com

Configuring git with local system:


[run on GitBash for windows & cmd for mac]

Git config - - global user.name “My-name”

Git config - - global user.email “someone@emailid”

Git config - - list //will give all credentials of configured git account

Create a repo on Github:

Clone & Status:

Clone : cloning a repo on local machine

Git clone <repo-link>

Status: displays current state of code

Git status

4 types of Status:
● Untracked - new files that git doesnt track yet
● Modified - changed
● Staged - file is ready to be committed [ after git add .]
● Unmodified - unchanged

Add & Commit:

Add- add new or changed files in your working directory to the git staging area

Git add <filename>

Commit - It is the record of changes

Git commit -m “some message”

Push:
Push : upload local repo content to remote repo

Git push origin name

Start a local repo & Connect to remote Github:

Init command:

To connect to github from local machine:

git init

Git remote add origin <link>

To check which remote github we are connected to:

Git remote -v

To push back to remote github:

Git push -u origin main

To check which branch

Git branch

Git branches

To check which branch we are currently in:


[list your branches. a * will appear next to the currently active branch]

Git branch

To rename a branch:

Git branch -M <newname>


To navigate to another existing branch:

Git checkout <branch-name>

To create new branch:

Git branch -b <new-branch-name>

To delete a branch:

Git branch -d <branch-name>

After adding new branches :

1. Git add .
2. Git commit -m “<message>”

To push changes made in a branch

Git push origin <branch-name>

Merging Branches

To compare commits/branches/files in two branches:

Git diff <branch-name>

Merge a branch with current branch:

Git merge <branch-name>

Inspect & Compare:

show the commit history for the currently active branch

Git log

show the commits on branchA that are not on branchB

git log branchB..branchA

show the diff of what is in branchA that is not in branchB

git diff branchB...branchA

You might also like