Showing posts with label github. Show all posts
Showing posts with label github. Show all posts

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

How to upload fresh project on github?


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


Well.. After I followed all the steps on github like created a repository, added the ssh key etc as described in the set up link I provided above.

Now the time comes for me to upload my project on github.

So, my project is in Home/Documents/MIMSlideShow/
I navigate to that directory and then created a local git repository and pushed my project on the remote MIMSlideShow folder.The highlighted lines were written by me and non-highlighted lines are the system messages.




Reetu-Rajs-MacBook:~ reeturaj$ ls
Apple Sample Codes Library Public
Desktop Movies RootPasswd.rtf
Documents Music Sites
Downloads Pictures Softwares
Reetu-Rajs-MacBook:~ reeturaj$ cd Documents/MIMSlideShow/
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git init
Initialized empty Git repository in /Users/reeturaj/Documents/MIMSlideShow/.git/
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git add .
NOTE: add[space]. Otherwise you will get warning !
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git commit -m "Initial commit"
[master 3ef6aac] Initial commit
 40 files changed, 11851 insertions(+), 0 deletions(-)
 create mode 100644 MIMSlideShow.xcodeproj/project.pbxproj
 create mode 100644 MIMSlideShow.xcodeproj/project.xcworkspace/contents.xcworkspacedata
 create mode 100644 MIMSlideShow.xcodeproj/project.xcworkspace/xcuserdata/reeturaj.xcuserdatad/UserInterfaceState.xcuserstate
 create mode 100644 MIMSlideShow.xcodeproj/xcuserdata/reeturaj.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
 create mode 100644 MIMSlideShow.xcodeproj/xcuserdata/reeturaj.xcuserdatad/xcschemes/MIMSlideShow.xcscheme
 create mode 100644 MIMSlideShow.xcodeproj/xcuserdata/reeturaj.xcuserdatad/xcschemes/xcschememanagement.plist
 create mode 100644 MIMSlideShow/1.jpg
 create mode 100644 MIMSlideShow/10.jpg
 create mode 100644 MIMSlideShow/11.jpg
 create mode 100644 MIMSlideShow/12.jpg
 create mode 100644 MIMSlideShow/13.jpg
 create mode 100644 MIMSlideShow/14.jpg
 create mode 100644 MIMSlideShow/15.jpg
 create mode 100644 MIMSlideShow/16.jpg
 create mode 100644 MIMSlideShow/2.jpg
 create mode 100644 MIMSlideShow/3.jpg
 create mode 100644 MIMSlideShow/4.jpg
 create mode 100644 MIMSlideShow/5.jpg
 create mode 100644 MIMSlideShow/6.jpg
 create mode 100644 MIMSlideShow/7.jpg
 create mode 100644 MIMSlideShow/8.jpg
 create mode 100644 MIMSlideShow/9.jpg
 create mode 100644 MIMSlideShow/Global.h
 create mode 100644 MIMSlideShow/MIMLayer1.h
 create mode 100644 MIMSlideShow/MIMLayer1.m
 create mode 100644 MIMSlideShow/MIMLayer2.h
 create mode 100644 MIMSlideShow/MIMLayer2.m
 create mode 100644 MIMSlideShow/MIMSlideShow-Info.plist
 create mode 100644 MIMSlideShow/MIMSlideShow-Prefix.pch
 create mode 100644 MIMSlideShow/MIMSlideShowAppDelegate.h
 create mode 100644 MIMSlideShow/MIMSlideShowAppDelegate.m
 create mode 100644 MIMSlideShow/MIMSlideShowTemplate1.h
 create mode 100644 MIMSlideShow/MIMSlideShowTemplate1.m
 create mode 100644 MIMSlideShow/MainViewController.h
 create mode 100644 MIMSlideShow/MainViewController.m
 create mode 100644 MIMSlideShow/MainViewController.xib
 create mode 100644 MIMSlideShow/en.lproj/InfoPlist.strings
 create mode 100644 MIMSlideShow/en.lproj/MainWindow.xib
 create mode 100644 MIMSlideShow/main.m
Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git remote add origin git@github.com:ReetuRaj/MIMSlideShow.git

Reetu-Rajs-MacBook:MIMSlideShow reeturaj$ git push origin master
Counting objects: 54, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (52/52), 4.52 MiB | 38 KiB/s, done.
Total 52 (delta 4), reused 0 (delta 0)
To git@github.com:ReetuRaj/MIMSlideShow.git
   1f5162a..3ef6aac  master -> master


Thats it ! Project was there  on my github MIMSlideshow repository !

Note: How did I get git@github.com:ReetuRaj/MIMSlideShow.git ?
Well for your own project it will be different string. You can find it on your project page as shown in the screenshot below:











Next thing useful for you could be ARTICLE: How to commit changes to your project on github?










NOTE: Recently, while adding a new project to Github, I was getting following error



git remote add origin git@github.com:Reetu/MIMChartLib.git
fatal: remote origin already exists.




So following command removed the error
$ git remote rm origin

Installing Github on MacOSX

Ok. After delaying the process for so many days, I decided to just do this task pending on my to-do list !
Now on, all my opensource projects/codes will be available on github repositories !
I have been constantly  getting hit by new ideas to do and my to-do list is just getting bigger day by day ! :)
So more articles will  be arriving on blog :)

Anyways. If you want to set up your github too. Here is the link to do so which is its official page. I followed the same :)

LINK


Note: After you follow steps on link above , if you are new then following are 2 topics are not specified in the link above. You can find them in following articles:

ARTICLE 1: How to upload fresh project on github?


ARTICLE 2: How to commit changes to your project on github?



There is a good news. I am trying to work on this opengl ES  tutorial series which is loosely based on the legendary NeHe opengl tutorial series. I will be following kind of same topics but in opengl ES :) Also going to put all the tutorial source code on the github. I have been getting constant emails about how the basic codes in my articles which I have uploaded so far have been helping people in getting things going. I am really really glad that I could be useful for the coder community.