Setting up GIT and GITHUB for my PHP Blog

Setting up git and github

Hello! I’m Julián Campos and I’m working in a blog based in PHP, but i’m working in it from 0 and yes! I’ve started it 🙂 I’ve started in the first step for one project… I’ve prepared the repositories and I’ll explain you how setting up GIT and GITHUB.

Configure Git and GitHub it’s a fundamental to have a correct control of the process of developping the project. It is not very hard to do, but how I want write often in the blog, I think it could be a nice post.

Local repository (Git)

The first step is configure the local repository. I’ve installed Git in my laptop and I’ve created a folder in my Workspace named ‘My own PHP blog’. Here I’ve done my first error, name the folder with spaces. Now when I launch Git Bash and I want to go to the folder, I must write ‘My own php blog’ instead myownphpblog. I must use quotion marks every time.

Well, I’ve installed git and I’ve set up the local folder with git init in the folder. Easy. The principal branch is called “master” as Git always do.

Online repository (GitHub)

For the online repository I’ve used GitHub as the 99% of developers do. I’ve created the respository when I wrote my Hello World post, so the hard thing was connect the Online repository to the local respository for push and pull.

Setting up Git and Github
Screenshot of my configuration

It’s hard because I’m using SSH keys to connect instead of the account login in GitHub. So I needed create ssh keys, the private and the public keys. I’ve learned these task in the online course of Platzi. The steps in Windows 10 was:

  • Create in GitBash the keys in ~/.ssh. To do this you must use ssh-keygen -t rsa 4096 -C “[email protected]
  • Later use eval $(ssh-agent -S) to test everything it’s ok.
  • Add the private ssh key with ssh-add nameofthekey
github clone
How to clone a GitHub Repository

I think I didn’t forget any step… You can use Google to learn about it 😉 Then, I went to my GitHub repository, I named the main branch as master branch and I’ve copied the ssh comand to clone and I added the remote repostitory to my local repository:

If you test with git remote -v you can see the remote repositories that you’ve added to your git installation. You must have minimum two with the same url, for push and fetch.

Then, I’ve pulled the repository to my master branch:

  • Git pull origin master

If everything went good with the SSH keys, you must have the files of github in your folder. Now, I have the files (README.md and LICENSE) from GitHub in my local repository ready for edit them.

Finally everything is ok to continue and work in the real project. I’ve configured the workspace and the version’s control system. Maybe I was wrong in some step written in the blog, but I’ve wrote this using my memory instead of code or command references. You have more information of git and github in internet (doing courses or reading blogs… more confidents than mine 😉 )

See you in the next post!

Setting up GIT and GITHUB for my PHP Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top