Skip to content

kjsce-codecell/Git-CheatSheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

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 sha hash 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

Releases

No releases published

Packages

No packages published