Git – Configuration and Basic Commands – Part 2

It is time to add Git repo.. Go to Repositories -> New



As soon as you create the Repo provides the commands to work with the repository.


The below section is to push the existing project code to repository in GitHub that we just created. We have a project folder where our code is present and would like to make it as GitHub repository.

#git init – Initializing as repository

#git status – exactly what it says “Status”- points to note here.. it shows which branch we are on,  if there are any untracked files, files to be committed and whether we are ahead of the master repo the we cloned from.. (please go through the document to understand).

# git add <file> && git commit – If there are any untracked files we need to add them to track and commit them locally.

#git push – push the committed local repository to the GitHub Repo.


So we have initialized the repo locally and it still does not know the repository on GitHub. So we need to add the “remote repository” – Repository created in GitHub ( in below screenshot doing git push already indicating it ).


As given in the instructions lets add the remote and push to repository in GitHub.


We can see the file in GitHub now – 1 commit – from Jenkins Automation Server with the comment from commit.


Sometimes you may want to skip some files pushing to the repository. For example – some compiled files, sensitive files, user specific configuration etc.

For example, adding the following to a .gitignore file in your project root will prevent compiled Python modules being tracked and pushed to repo.


The below section is to work on the existing repository in GitHub. First we need to clone the repo into local system.


Lets create file now, add and commit locally.. In the screenshot below we can clearly see in red – as soon as we create file it is “untracked”. Once we add then it turned green – so file is being tracked now for changes but needs to be committed. Command “git commit” does the job.


Push to the repository now.. “git remote” shows where the code is being pushed to in GitHub. We can also see that local master being pushed to master branch in remote repository.


On the GitHub repo we can see 2 commits and the new clone file..


Last part of this post is how to pull files from remote repository to local. Consider a scenario where we have cloned the GitHub repository and one of your colleagues pushed a file OR updated file in GitHub repository.

I’ve added a file to remote repository..


Now lets pull it to the cloned using “git pull” command..



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s