My Git commandline Cheat-sheet

Creating a new repository

mkdir project

cd project

git init

git remote add origin git@github.com:yourlogin/your-repo.git

git add .

git commit -am “new repository”

git push -u origin master

Cloning existing repository

git clone https://github.com/username/your-repo.git

Creating branch

git checkout -b feature-1

# you are now in a branch, you can edit and create new files

git add .

git commit -am “new feature”

Merging branch to master

git checkout master

git merge feature-1

git push

Deleting branch

git branch -d feature-x

List all branches

git branch -a

Switch branch

git checkout feature-x

Switch to master branch

git checkout master

Listing Remote repositories

git remote -v

Replacing remote repository

# in case your remote repository changes, or you want to switch from HTTPS->SSH or SSH->HTTPS

git remote remove origin

git remote add origin git@github.com:yourlogin/your-repo.git

Advertisements

About Divyashree - The GNULINUX Guy

I am a Linux and Opensource enthusiast. I started working on Linux early in 2007 while I was doing my Masters in Computer Science and passed out in 2010. Currently working as a DevOps in in Public/Private cloud domain. my @github : https://github.com/kumarprd my @nagiosexchange : https://exchange.nagios.org/directory/Owner/divyaimca/1 my @linkedin : https://www.linkedin.com/in/priyadarshee-kumar-☁-a9415615
This entry was posted in HOWTO, Programming, TIPS & T RICS, Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s