My first commit in my first fork

This is that kind of things I'm not use to do every day, so I'm sure I will forget tomorrow.
I'm writing this post to come back and remember when I need it.

Lately I'm working with the Cakephp-Facebook-Plugin to allow users to login in a web application through Facebook.

In that process I modified some function in the helper of the plugin and I decided to fork the project and share my updates with the world. The only thing is that I'm not sure about what is the normal way to make these thing.

This is what I did:


From, I fork the project at
In a terminal, clone the project:

	pedro@vaio01:~/Trabajos/gittests$ git clone git:// facebook
	pedro@vaio01:~/Trabajos/gittests$ cd facebook



At this point you can see which branches there are locally:

	pedro@vaio01:~/Trabajos/gittests/facebook$ git branch
	* master

Or to see all the branches, from remote too:

	pedro@vaio01:~/Trabajos/gittests/facebook$ git branch -a
	* master
	  remotes/origin/HEAD > origin/master



Select the branch cakephp1.3 because I'm still working in version 1.3 from CakePHP:

	pedro@vaio01:~/Trabajos/gittests/facebook$ git checkout -b cakephp1.3 origin/cakephp1.3
	Branch cakephp1.3 set up to track remote branch cakephp1.3 from origin.
	Switched to a new branch 'cakephp1.3'

And to check the last command effect, you can see again the branches:

	pedro@vaio01:~/Trabajos/gittests/facebook$ git branch
	* cakephp1.3



If you want to switch to the master branch again:

	pedro@vaio01:~/Trabajos/gittests/facebook$ git checkout master
	Switched to branch 'master'

The source files in the directory will change to the selected branch files.
To see if I can loose the changes switching from a branch to another I created a file in cakephp1.3 branch and it was there when I changed to master branch.
Anyway, I went back to cakephp1.3 branch like I said before:

	pedro@vaio01:~/Trabajos/gittests/facebook$ git checkout cakephp1.3
	Switched to branch 'cakephp1.3'



Modified the file that I needed. I did this task with meld because I was working for real in another directory (I don't control git that much :D).
The updated file was /views/helpers/facebook.php



If you want to see what changes you did:

pedro@vaio01:~/Trabajos/gittests/facebook$ git status
# On branch cakephp1.3
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#	modified:   views/helpers/facebook.php
no changes added to commit (use "git add" and/or "git commit -a")



If you want to commit all the changes done to your local branch:

pedro@vaio01:~/Trabajos/gittests/facebook$ git commit -a
[cakephp1.3 e1efa49] Added 2 params in facebook helper init() function to pass the on login url and on logout url to redirect after facebook login and logout respectively. That creates the callback functions to do that.
 1 file changed, 14 insertions(+), 2 deletions(-)

It require some description for the commit. The description I wrote is right after the command line 'git commit -a'. Now you have the changes commited in your local git. To upload to a remote branch from github:

pedro@vaio01:~/Trabajos/gittests/facebook$ git push
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 786 bytes, done.
Total 5 (delta 2), reused 0 (delta 0)
   e76480e..e1efa49  cakephp1.3 -> cakephp1.3

It requested me for my github password, perhaps that may be configured to not request password every time.

Thu, Jul 5th 2012, 11:10 | CakePHP, Git


Add New Comment

Your name:
Your e-mail:
Your web page:
I would like to receive new comment notification.
Security code: