Getting started with Github
Github is the most important tool we use for code sharing, collaboration and back ups. Uploading code on github daily is of utter importance if you want to avoid ‘data loss’ and to keep track of code changes.
Now here I want to share a much more reliable and faster method of committing & syncing code on github.
This tutorial includes guidelines for using git command line tool for interaction with github.
STEP 1 is, installing git tool on your mac (if not already installed). go to http://git-scm.com/downloads and download the setup and install it.
STEP 2 is, writing commands on terminal. To start with:
#Run these commands to configure git color scheme in terminal.
git config –global color.branch auto
git config –global color.diff auto
git config –global color.status auto
git config –global color.ui auto
# Sets the default user name for git to use when you commit
git config –global user.name “Your UserName Here”
# Sets the default email for git to use when you commit
git config –global user.email “your_email@example.com”
STEP 3 is, to clone your repository to your local machine (if not done already).
#Changes path to a folder named ‘github’ in ‘Documents’ (I recommend creating a ‘github’ folder in ‘Documents’ and follow these steps without much change, and also it keeps your github repos organized)
cd ~/Documents
mkdir github
cd github
#Clone repository.
#Remember you have to clone your repository to local machine only once, after that you just have to commit and push it to github, which I’ll be explaining in STEP 4.
## ‘my-repo-name’ is the name of the project repository you are added to, and it is CASE SENSITIVE. you can get the repo url from your repo’s home page at github.com.
git clone https://github.com/your-domain/my-repo-name.git
STEP 4 is, committing and syncing your project daily on Github.
#Changes path to your project repository you cloned to your local machine. Copy all your project files (from your directory)
cd ~/Documents/github/my-repo-name
# Adds all files that have been changed, added or deleted in the queue to be committed.
git add -A
# Commits the changes to Github. 0.MMDD is the standard versioning method we follow for our commits. For example: on 15 April (15/04/13) you should add commit summary as ‘Development Build 0.0415’.
git commit -m ‘Development Build 0.MMDD’
#Finally push (sync) all the committed changes to the Github.
git push origin master
We are done.
IMP POINT: You have to follow STEP 2 only once, when you setup git first time, STEP 3 every time you are assigned a new repository, that should be once in 2-3 months and STEP 4 daily.
Github integration with XCode (for iOS app development):
(Step 1& 2 still need to be done before these)
To start a new project, follow these steps:
1. go to File -> source control ->repository. In the new window, click on “+” icon in left bottom corner and select “checkout or clone repository”. It will ask for repo path. add the repo path you would like to clone e.g. https://github.com/your-domain/test-repo.git and enter your credentials when asked. Clone the repo into a standard directory ~/Documents/github/
2. Once the repo is cloned. create a new project through standard process. Just choose the same folder in which you have cloned the repo and uncheck the option “create a local repository for this”.
3. Now everything is setup. you can use File->source control to commit and push changes to remote repo.
No comments yet.