With over 11 million users and 30+ million projects, GITHUB is the most popular code versioning tool now. It’s not only used in the public domain to share code with the world but it also used at enterprise level to share code and collaborate with different teams in the organization.
In this blog, I will try to explain how to use GIT ( command line utility) to perform the common operations that a developer might do on a daily basis. All the instructions are for a MAC but should work for other platforms too.
Once installed, open up a terminal window (MAC/UNIX) or command prompt in Windows and enter the command ‘git’ in window to verify if GIT is installed fine.
Configuration
Git config files are stored in one of the following locations.
Using Git
In the upcoming section I will explain how to use the GIT commands to achieve the following not necessarily in the same order indicated below.
Creating a new code repository.
Adding files to the repository.
Pushing files.
Making changes to a file and updating the code repository.
For the purpose of this tutorial, I will keep the username/password as
1
(gittutorial@gmail.com/gittest)
.
Configure GIT on the machine so that it can talk to the GITHUB code repository.Start a terminal and enter the following commands.
Now create a folder
1
mycoderepo
and add a file to it.
Initialize the current folder as a repository and add the newly created file to be part of the repo.
Create repository. Verfiy email if needed.
Defining the remote location where to push the local repository.
Pushing files. You will encounter the permission denied error first time. Create a new SSH key as described here to resolve it.
Once the SSH issue is resolved we can re-try the command to push the code to the ‘master’ branch of the repo.
Lets add another file and check the status of the repository.
Lets add few more files. Note that we can user wild cards to refer to files.
Let’s say that we accidentally added ‘timer.js’ to be pushed. If we want to revert this back.
Lets commit and push this to Master branch.
Let’s modify the first file and delete the second file from local repo and push the changes out to remote.
If you don’t want some files to be reported as part of ‘git status’ command and never want to push it to remote repository then create a `.gitingore’ file with the file patterns that need to be ignored.
If you want to clone the remote repository on a different machine or at a different location.
Most of the applications have some sort of badging functionality which is used to display certain counts to the users for CTA (Call To Ac...… Continue reading