Skip to content

imbmishra/Git-GitHub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 

Repository files navigation

Git Commands to learn and use

Author: Bidyanand Mishra

defination

Git - Version Control System (tools) which helps to track changes in the code.
GitHub - Website / Repository that allows developers to store and manage code using Git.

check git version

git --version

list files

ls

list hidden files

ls -a

present woking directory

pwd

config username and email

git config --global user.name "Name"
git config --global user.email "Email-ID"

list details

git config --list

Clone and Status -->

local - laptop/PC
remote - github repisoritory

Clone: Cloning a repository on our local machine

git clone <- link ->

Status: display the state of the code

git status

change: modified
new file: untracked
add: staged
after add, commit happens (unchanged)

untracked: new files that git does not yet tracked.
modified: changed
staged: file is ready to be commited
unmodified: unchanged

Add & Commit

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

Commit

It is record of change
git commit -m "some message"

Push Command

Transmit local branch commits to the remote repository branch
git push origin main
git push [alias] [branch]

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 -M main (to rename branch)
git push origin main

-u is written to specify upstrem. That meanswe will only going to to push on main branch. Now only git push should be written instead of git push origin main

git push -u origin main
git push

Branch Commands

git branch (to check branch) git branch -M main (to rename branch)
git checkout <-branch name-> (to navigate)
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 & more)
git merge <-branch name-> (to merge 2 branches)

way 2

create a PR (Pull Request - It lets you tell others about changes you have pushed to a branch in a repository on GitHub)

Pull Command

used to fetch and download content from a remote repo and immediately update the local repo to match that content.
git pull origin main

Resolving Merge Conflicts

An event that take place when Git is usable to immediately resolve differences in code between two commits.

Undoing Changes

Case 1:

staged changes
git reset <-file name->
git reset

Case 2:

Commited changes (for 1 commit) git reset HEAD~1

Case 3:

commited changes (for many commits)
git reset <-commit hash->
git reset --hard <-commit hash->

Fork

a fork is a new repository that shares code and visibility settings with the original "upstream" repository.
Fork is a rough copy.

Get log file of commit

git log

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published