Git For Mobile Application developers

Git is a distributed version controlling system created to manage the Linux kernel.  Few advantages are,

  • Reliability
  • Efficient management of large projects
  • Support for distributed development
  • Support for non-linear development

Even though git is managed by several user interfaces , Command line is the most common way to interact with Git.


If you are in the mac ,  download the dmg file and double click on it.


After the installation open a new command prompt and run the following command to test the installation,


git –version


output should be something like  

git version (Apple Git-33)


Initialize the Git Repo

If you are in the mac environment,

  • Open the terminal first,
  • create a directory called “test-git” in Desktop.
  • move your cursor into the created folder.


cd ~/Desktop/test-git



  • Add a file called index.html


<!DOCTYPE html>
&lt;title&gt;<span style="font-family: Consolas, Monaco, monospace;">Title tag</span>

This is a test git page.



This is just an html page for our purpose to test the git functionality. not just to teach you html.

Now you are in the /Desktop/test-git folder,

Run this First ever git command to initialize.



git init


Current directory is now going to be a powerful Git Repository.

Now you can watch there is a .git directory in your current folder.

Note :- Deleting “.git” folder will turn your repository into normal unversioned directory of file.

Check the git status


git status


you will get the response of


Initial commit

Untracked files:

  (use “git add <file>…” to include in what will be committed)


nothing added to commit but untracked files present (use “git add” to track)    


Git Staging.

Staging mean, what files to include in the next commit. Git does not track files automatically. We have to add the files manually to git.





We have just added index.html for the next commit.

Git Commit

Committing the changes to the local git folder done by the following command.



git commit -m “[message]”


When you enter this command you will be asked to type the message for the changes you have done for the commit.

View Git history



git log


to check the history of the work.


git log –oneline


the above command will give you structured log of the change history. There are so many commands that we should practice. To learn more about git commands click here.


Setting Your Name and Email in GIT

To identify or differentiate your commit from other commit in your team, we should update our name and email globally or specifically to the git project.

To update your name


//setup a name for your current git project.

$ git config "Apps Git"

//to setup your name globally for all your projects in your pc.

$ git config --globally "Apps Git"

//To setup your email in git 

$ git config ""

//to setup email globally

$ git config --global ""





Git Source Control with xCode 8.0++ in

iOS 10.0 Applications


We have setup GIT Source control to the pc. Now we will learn in a simple and step by step way, how to work with GIT in Xcode projects in iOS 10.0+ applications.


To open Xcode using keyboard short cut,  Press (Command + Space Bar) and type “Xcode” and press enter button.


Create a new project in Xcode and goto next page to select a directory to save the project. You will notice a checkbox like below to initiate a GIT Repository. check it.

initialize GIT for iOS mobile projects
initialize GIT for iOS mobile projects


Now project is ready with local empty git repository. We can add files to repository or remove.


Commit Files to Local Repository

Well initial commit willbe done by the Xcode it self. If you goto

Top Menu -> Source Control -> History 

You can see the Initial commit like below.



We will add our first commit to the Repo,

Edit any of the view controller and save the file. You will notice that there is a  “M”

mark next to the file name in the left Navigator.


You made a change to a file, Lets commit it by click the button in the,

Top Menu -> Source Control -> Commit



Xcode has great built in support for Git.

  1. You can check/uncheck the file from the commit.
  2. You can select/unselect a change from a file that is selected for commit.
  3. type your commit message.


You can check commit history by going

Top Menu -> Source Control -> History

To check the modified files of a commit,

  1. Open the Commit History page.
  2. Click the button which is located next to commit message



Congratulation! You know how to successfully use Git with Xcode. Next we will look how to upload the fresh Xcode project to remote GitHub account.



Upload Xcode Project to Github Remote



  1. Sign in to your GitHub account and create a new Repository.

Note : Don’t Add .gitignore file or README file while you create repository. You can add them later.

2. Copy the remote url.


3. Goto Config page of the local branch and add the url


Goto Remote tab.

Press “+” button in the bottom left right side

Select “Add Remote” button.



After you added the url, type your username and password of your GitHub account to verify your account.


Now push the commits to the remote.


Thats all, You are done now. To verify the changes login to remote GitHub by browser and check whether changes are uploaded to the server.


If you guys want to work with Any other Git client side tools other than default Xcode built in support, I would suggest you to download and install SourceTree

I will cover The SourceTree guide in another tutorial.


I will get back to you with some other useful blogs soon.





Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.