Giter Club home page Giter Club logo

gitcheatsheet's Introduction

Git Cheatsheet By Bishworaj Poudel

For Config:

=> git config --global user.name "Bishworaj Poudel" => git config --global user.email "[email protected]"

To View user.name and email

git config --list

To Get Help:

=> git help => git help

Initialize a Repository

=> git init

To Add File To Staging Area

=> git add filename => git add filename1 filename2 => git add . [To Add All Files In Directory]

To Commit Change

=> git commit -m 'Short and Sweet Message' => git commit -am 'Staging and Comit Directly'

Clone Existing Repository

=> git clone <project_url>

Checking the Status Files

=> git status => git status -s [Short Status]

View Difference

=> git diff [ Find difference between commited and unstaged files ] => git diff --staged [difference in staged files]

To Remove File From git

=> git rm filename

To Move File

=> git mv file_from file_to [If we rename the file]

To Move staged file to not staged

=> git reset HEAD => git reset HEAD file1.txt

To Unmodifying a Modified File

=> git checkout filename

To View Commit History

=> git log => git log --oneline [Oneline Easy and Fast] => git log --stat [More History] => git log --pretty=oneline [Show SHA1 Value] => git log --pretty=format:"%h %s" --graph => git log --pretty=format:"%h - %an, %ar : %s" => git log --since=2.weeks => git log --after=2.weeks => git log --author "Bishworaj Poudel" => git log --oneline --decorate --graph --all

To ignore files:

=> create .gitignore file => then add filename/foldername line by line => *.c => ignore al .c files => !main.c => not ignore main.c file => node_modules/ => Directory node_modules and all files inside it.

To Unstaging a Staged File with git restore

=> git restore => git restore --staged file1.txt

To Work With Remote Repository

=> git remote show origin [To View Remote Origin Details] => git remote -v => git remote add origin : => git push origin master => git pull => pull data with current head => git fetch => only download the data to local repository => git fetch origin mod => To retrive remote branch => git remote rename pb paul => git remote remove paul => git push origin --delete bad-branch-name

Git Tag

=> git tag -l => git tag --list => git tag -a v1.4 -m "my version 1.4" => git show v1.4 => git tag v1.4-lw [Lightweigt] => git tag -d v1.4-lw => git checkout v2.0.0

To Transfer Tag to Remote

=> git push origin .

Working With Branch

=> git branch testing [To Creating Testing Branch] => git checkout testing [Switch Branch] => git commit -am 'made a change' => git checkout master [To Move to Master Branch] => git checkout -b .[Creating branch and switching to it] => git branch --merged => git branch --no-merged => git branch --move bad-branch-name corrected-branch-name

Redo Commit

=> git reset => git reset SHA1 => git reset -hard SHA1

Git Stash

=> git stash save => git stash list => git stash pop => git stash apply stash{0} => git stash clear => git stash grop stash

Merge

git merge branchname git merge --no-ff branch name

Rebase

git rebase branchname

gitcheatsheet's People

Contributors

bishworajpoudelofficial avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.