Code Monkey home page Code Monkey logo

git-cheatsheet's Introduction

Git CheatSheet

Installation

On Linux
#Debain Distro
sudo apt-get install git

# Fedora Distro
yum -y install git

On windows and Mac

Download github desktop and shell from here

Getting Started

  	#to initialize git in a local directory
    git init
    
    #to clone a repo from github
    git clone url

Configuring your name and email

	#set up user name
    git config --global user.name "Insert your name here"
    
    #set up user  email
    git config --global user.email "Insert your email here"

Commiting files

Check file status
	git status
how to add files to the staging area
  #add a specific file
  git add filename
 
  #add a specific file type
  git add *.extention
 
  #add all files 
 
  git add .
     or 
  git add *
  
  #this command will unstage the files which are not commited
  git reset filename
How to commit Changes
git commit -m "Insert Commit message here"
See commit history
#detailed commit history
git log
Go back to a previous commit
git reset --hard sha

sha is the alphanumeric you find when using git log

Branches

	# check current branch names
    git branch

	# add a new branch
    git branch branchname
    
    # switch to a different branch
    git checkout branch name
    
    # add a new branch and switch to that branch
   git checkout -b branchname   
   
   # merge a branch to the current branch
   git merge  branchname
Contributing to an Online Repo Workflow

Workflow

Remotes

Manage the set of repositories ("remotes") whose branches you track.

	#check available remotes
    git remote 
    
    #Add a new remote 
    git remote add url
    

Pull and Push

	#pull all the branches from your main repo 
    git pull 
    
    #pull specific branch from a specific repo
    git pull remote-name  branch-name 

	# push all the branches to the main repo
    git push 
    
    #push specific branch to a specific repo
	git push remote-name branch-name    

Resources

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.