Creating Social Network on Ruby on Rails – Day 8 – Source Control on GIT

Yeah it was high time I set up Source Control for Socialbeam so its easy for you folks now to fetch the CodeBase directly with updates.

So I went forward with setting up my GIT repo.

https://github.com/raycoding/socialbeam-dev.git

I would not be going into much details of GIT setup as you can get all documentation on Official Guides of GIT, so a brief jist on how you can setup your GIT in your System

What is GIT? Git is a distributed version control system (dvcs) written in the programming language C.

A version control system allows the creation of a history for a collection of files and includes the functionality to revert the collection of files to another state. Another state might be a different collection of files or different content in the files. The collection of files is usually called source code.

Git keeps track of all versions. Therefore you can revert to any point in your source code history.

On Ubuntu you – Install Git command line tool via the following:


sudo apt-get install git-core
# Configure the user which will be used by git
# Of course you should use your name
git config --global user.name "Example Surname"
# Same for the email address
git config --global user.email "your.email@gmail.com"

The following will create a Git repository, add the files to the repository’s index and commit the changes.


# Initialize the local Git repository in your App folder

git init

# Add all (files and directories) to the Git repository

git add .

# Make a commit of your file to the local repository

git commit -m "Initial commit"

# Show the log file

git log

Okay that was a very small briedf, for more details on git you can see the Official Documentation in Github for all commands and help.

I have added a GITCONFIG file with few git shortcuts, you can save it at .gitconfig in your HOME directory, I like having few git shortcuts instead of typing long commands in git. You can check the file in github socialbeam-dev link above , the contents are

</pre>
[core]
 whitespace = nowarn
 pager = less
 edito = vim
 editor = vim
[user]
 name = Your Name
 email = email@your.com
[color]
 ui = auto
 diff = auto
 status = auto
 branch = auto
[alias]
 spull = !git checkout master && git-svn fetch && git-svn rebase
 spush = !git checkout master && git-svn dcommit
 send = !git spull && git spush
 co = checkout
 ci = commit
 ca = commit -a
 br = branch
 st = status
 lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
 df = diff
 dfs = diff --cached
 whitespace = nowarn
 pager = less -FRSX
 changes=diff --name-status -r
 diffstat=diff --stat -r
 serve = daemon --reuseaddr --verbose --base-path=. --export-all ./.git
 whois = "!sh -c 'git log -i -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1\"' -"
 whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
 edit-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; gedit `f`"
 add-unmerged = "!f() { git ls-files --unmerged | cut -f2 | sort -u ; }; git add `f`"
<pre>

==============================================================

Now coming back to SocialBeam I created a repo in GIT named socialbeam-dev

Opened System Terminal and entered socialbeam directory,


git init

git add .

git ci -m "Initial Commit on SocialBeam"

git remote add origin https://github.com/raycoding/socialbeam-dev.git

git push origin master

BINGO I had my GIT setup in minutes! :) Now we will do our work on local system and end of each lesson we will push our changes to git, so that you ca rebase your system repo with the most updated changes, if required I will also create separate branches for few specific things, right now I will work on master branch.

So go ahead and clone the SocialBeam Project from the link given, and whenever you see your local codebase is old , just do a pull request,it will update with all changes “git pull –rebase”

Also if you like to fork ahead and make branches feel free to do it.