Sunday, June 26, 2011

How to commit changes to your project on github?

Ok. So in our last post we saw how we can upload our fresh project on Github. LINK

If you have not set up your github on your mac yet. Here is the link to do so which is its official page. I followed the same :)
LINK



In this article, we are going to see how we can commit new changes in our project.

Conventions are same: Highlighted lines were written by me and Comments for the steps are written within /* */ and non-highlighted lines are the system responses.

/*We are going to add upstream support in our local Github repo*/

Reetu-Rajs-MacBook:Template1 reeturaj$ git remote add upstream git://github.com/ReetuRaj/MIMSlideShow.git


Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git fetch upstream

/*This command will tell you if you have any new files or any modified files  in your repo. Here you can see ReadMe is the modified file available which needs to be committed on remote Github repo.*/

Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git commit -m "commit 1.1"

# On branch master
# Changed but not updated:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#
# modified:   README
#
no changes added to commit (use "git add" and/or "git commit -a")

/*This command will actually open VIM editor and will ask you to enter the commit remark.Once you done with writing your remark, you can press ESC  then :wq to exit out of VIM editor.*/
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git commit -a

[master 1e1fd23] Test Commit
 3 files changed, 4532 insertions(+), 4538 deletions(-)
/*This command will  push all the latest changes on remote Github repo.*/
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git push origin master

Counting objects: 19, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 7.05 KiB, done.
Total 10 (delta 4), reused 0 (delta 0)
To git@github.com:ReetuRaj/MIMSlideShow.git
   3ef6aac..1e1fd23  master -> master




CASE 2:

As shown in above lines you can find how many files were modified or added by following command:
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git commit -m "commit 1.1"


If you see that new files were added, you will get following for the files which are new and not available on the remote Github repo. In my case, README file is not yet present on remote Github repo but its present on my local Github repo. So obviously I want to add it on my remote repo.

# On branch master
# Untracked files:
#   (use "git add ..." to include in what will be committed)
#
# README
nothing added to commit but untracked files present (use "git add" to track)

/*So I will  just run add . command to add all new files , Note the dot(.) after add*/
Reetu-Rajs-MacBook:Template1 reeturaj$ git add .

/*Then our usual commit followed by push command*/
Reetu-Rajs-MacBook:Template1 reeturaj$ git commit -a

[master 7f8db7e] Adding a README file
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 README

Reetu-Rajs-MacBook:Template1 reeturaj$ git push origin master
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 465 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)


DONE !  :)


HOW TO DELETE A REPO FROM GITHUB

No comments:

Post a Comment