Skip to content

Installation and Guide to GIT

August 24, 2012

Installation

Linux

  1. Install Dependencies (curl, zlib, openssl, expat, and libiconv)
    • Debian, Ubuntu:
      sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
    • Red Hat:
      sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
  1. Install Git
    • Debian, Ubuntu:
      sudo apt-get install git-core
    • Red Hat:
      sudo yum install git

Windows

  1. Download and Run the necessary Windows Executable here

Mac

Note you will need HomeBrew. Here’s a link to install it if you need to.

$ brew install mysql

Using GIT

Clone


$ git clone {url_to_git_repo} {name_of_folder_content_is_to_be_saved_in}

Create Branch


$ git clone {url_to_git_repo} {name_of_folder_content_is_to_be_saved_in}
$ cd {name_of_folder_content_is_to_be_saved_in}
$ git branch {new_branch_name}
$ git push origin {new_branch_name}
$ git checkout {new_branch_name}

Show Branches


$ cd {directory_where_git_project_is}
$ git branch

Switch to Branch


$ git clone {url_to_git_repo} {name_of_folder_content_is_to_be_saved_in}
$ cd {name_of_folder_content_is_to_be_saved_in}
$ git checkout {branch_name}

Merging Branches


# Merge changes from {target-branch} into {current-branch}:
# checkout {current-branch}
$ git merge {target-branch}
$ git push

Add file or directory

Add all new files and directories


$ git add .

Add all new files and directories


$ git add {file_or_directory_name}

Remove file or directory

To remove a single file:


$ git rm {file_name}
$ git commit -m "{message}"

$ git push

To remove a directory:


$ git rm -r {directory_name}
$ git commit -m "{message}"
$ git push

Commit


#After making some change to your code base
$ git commit -m "message about what you are committing"
$ git push

 

Revert

To Revert last commit and push to repo

$ git reset --hard HEAD~1
$ git push -f

To Revert to and older version of the code in the repo

$ git checkout {revision hash} .   #remember the dot at the end
$ git commit -m "Message"
$ git push

Useful Links

http://git-scm.com/book/en/Getting-Started-Installing-Git

Advertisements

From → Guide, Installation

Leave a Comment

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

%d bloggers like this: