Git Basic Commands 101

This post is just a basic listing of simple git commands. These are the basics commands to start using Git, this is mostly for my own
reference.  You can download git here: https://git-scm.com/. For a complete guide on git, check out https://git-scm.com/book/en/v2

Local Repo Git Commands

 

Command

 

 

Description

 

 

Example

 

 

git init

 

 

Used to set up a directory as a Git
Repo

 

 

git init

 

 

git status

 

 

Check
the status of the existing repo branch

 

 

git
status

 

 

git branch
<branch>

 

 

Creates a branch off current
branch

 

 

git branch MyBranch

 

 

git checkout
<branch>

 

 

Switches
your repo to another branch

 

 

git
checkout MyBranch

 

 

git add
<filename>

 

 

Adds a single for to the staging
area

 

 

git add MyFile.cpp

 

 

git add .

 

 

Adds
all files in the current repo branch to staging
area

 

 

git
add .

 

 

Git commit

 

 

Commits a change to the
repo

 

 

git commit

 

 

git commit -m
‘<message>’

 

 

Commits
a change using an inline comment

 

 

git
commit -m ‘Change 3’

 

 

git commit -a -m
‘<message>’

 

 

Stages and Commits all change using inline
comment

 

 

git commit -a -m ‘Change
3’

 

 

touch
<filename>

 

 

Creates
a blank file

 

 

touch
.gitignore

 

 

git stash

 

 

Places all committed changes into a working directory
for later use.

 

 

git stash

 

 

git stash apply

 

 

Recovers
the stash back to the branch

 

 

Git
stash apply

 

 

Git Ignore file can be used to exclude files from the repo. Use pattern or file name in the “.gitignore” file. I.e. *.log.

Remote Repo Git Commands

 

Command

 

 

Description

 

 

Example

 

 

git remote

 

 

Displays the currently available remote
repos

 

 

git remote

 

 

git clone
<url>

 

 

Clones
a remote repo to your local repo

 

 

git
clone https://github.com/account/repo.git

 

 

git remote -v

 

 

Displays the repo URL

 

 

git remote -v

 

 

git fetch
<remoterepo>

 

 

Will
fetch any changes made in the remote repo since the last close or fetch. This
will not perform a merge.

 

 

git
fetch origin

 

 

git pull origin

 

 

Will fetch and merge the changes from a remote repo
into your local

 

 

git pull origin

 

 

git push <remoterepo>
<branch>

 

 

Pushes
changes from the local repo to the remote
repo

 

 

git
push origin master

 

 

git remote add <repoalias>
<cloneurl>

 

 

Creates a new local repo from a remote with an
alias

 

 

git remote add myrepo
https://github.com/account/repo.git

 

 

 

Advertisement

All Dreams Are Now Welcome, Imagine Cup 2013

IC2013_Hero_Web_Banners-4

“I’m John Scott Tynes, your new Imagine Cup Competition Manager, and it’s my very great pleasure to announce the start of our new season. Today we take our first steps on the road to St. Petersburg, Russia, where all of our efforts will culminate in our Worldwide Finals in July, 2013. To get started, I’m excited to share some great news!”

Read the full blog on the Imagine Cup site here.

Windows Phone 8 at Windows Phone Summit

Today Microsoft released information about the new Windows Phone 8 platform.

The new Windows Phone 8 will use the same core of Windows 8.

Features will include;

  • Dual Core/Multi Core
  • Increased Screen resolution
  • Micro SD card support
    • Pictures
    • Video
    • Install Apps
    • Transfer content between phones and PC
  • Existing App from Windows Phone 7 will run on Windows Phone 8 (No sure if they will need to be recompiled or resubmitted to the market place)
  • Internet Explorer 10 (Same rendering between PC and Phone)
  • Extending support and performance for HTLM 5 and Jscript
  • Native Code Support
  • Native Code for Game Development!
  • Native support for NFC
  • Much much more!

Check out the following blog posts and video links to see more about the new Windows Phone 8

http://create.msdn.com/en-us/news/windows-phone-summit-recap

Today Microsoft gave a sneak preview of Windows Phone 8, highlighting the core OS elements shared with Windows 8, and the opportunities this release will create for developers, IT professionals and consumers.

Windows Phone 8 brings new hardware capabilities like multi-core chips, new screen resolutions, SD card support and NFC. Windows Phone 8 additionally delivers new features including a great new Start Screen, IE 10 and Wallet, as well as support for native development, and enterprise capabilities such as device encryption and management, and Company Hub. Existing Windows Phone customers will receive an update including new features in Windows Phone 8 like Start Screen and more.

We also announced growth in the number, variety and quality of apps in Marketplace, with 100,000 apps including new apps like Words with Friends, Draw Something, Audible, Chase and PayPal, and games including Asphalt 7: Heat, N.O.V.A. 3: Near Orbit Vanguard Alliance, and Batman: The Dark Knight Rises.

Joe Belfiore’s blog post.

http://windowsteamblog.com/windows_phone/b/windowsphone/archive/2012/06/20/announcing-windows-phone-8.aspx

Windows Phone Summit

http://channel9.msdn.com/Events/Windows-Phone/Summit