GithubHelp home page GithubHelp logo

nitin025 / gitcheatsheet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ravening/gitcheatsheet

0.0 1.0 0.0 17 KB

This repository, created for contribution to HacktoberFest 2019, is a collection of useful Git commands. Open a pull request so that you too can add Git Commands.

gitcheatsheet's Introduction

GitCheatSheet

Please adhere to the below mentioned format while opening pull requests, else your pull requests shall be marked as spam.

Usage of command - Command on Git Bash (Optional Description)

Git Installation On Linux OS - sudo apt install git-all

Configuring Username And EMail Id:-

git config --global user.name "John Doe"

git config --global user.email [email protected]

Check Configuartion Settings - git config --list

Checking Specific Configurations - git config user.name



Initializing A Git Repository - git init

Add Files to the staging area - git add

Adding a particular file - git add fileName followed by extension

Cloning a repository from GitHub - git clone https://github.com/userName/repoName

If you want the repository to be named something else on your local computer,

git clone https://github.com/userName/repoName repoNameOnYourSystem

Checking the status of the repository - git status



Adding a .gitignore file ignores certain file extensions for tracking

Ignore all .a files - *.a

Track lib.a, even though you're ignoring .a files above - !lib.a

Only ignore the TODO file in the current directory, not subdir/TODO - /TODO

Ignore all files in any directory named build - build/

Ignore doc/notes.txt, but not doc/server/arch.txt - doc/*.txt



See the differences between the edits - git diff

Difference in files after the staging process - git diff --staged

Commiting a file - git commit -m "Type in your commit"

Committing and staging the file in one command - git commit -a -m "Type in your commit"

Staging the removal of a file - git rm <fileName>

Staging the renaming of a file - git mv <oldFileName> <newFileName>

Viewing the Commit History of A Dierectory - git log

To view the changes in the file in the commit history - git log -p

To view the last n changes only - git log -n

To view the statistics of each commit change - git log -stat

Amending a commit - git commit --amend (Effectively, this is as if the previous commit never occured)

Unstaging a file - git reset HEAD <fileName>

Unmodifying a modified file - git checkout --<fileName>



Listing the name of your remote repository - git remote -v

Adding a remote - git remote add <remoteName> <repositoryURL>

Fetching from a remote - git fetch <remoteName>

Fetching and merging at the same time - git pull <remoteName>

Pushing to a remote server - git push <remoteName> <branchName>

Get information about a remote branch - git remote show <remoteName>

Renaming a remote server - git remote rename <oldName> <newName>

Removing a remote server - git remote remove <remoteName>



Creates new branch - git branch [branch_name]

Switches to existing branch - git checkout [branch_name]

Creates and switches new branch - git checkout -b [branch_name]]

Delete fully merged branch - git branch -d [branch_name]

Delete branch (even if not merged) - git branch -D [branch_name]

Rename the current branch name to new branch name - git branch -m [new_branch_name]

Merges other branch specified to current branch - git merge [branch_name]

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.