28. git push: Push your new branches and
data to a remote repository
29.
30. VS
⢠Git is a revision control system, a tool to
manage your source code history.
⢠GitHub is a hosting service for Git
repositories.
⢠Git the tool, GitHub the service for
projects that uses Git.
38. Grab the code and push WordCamp
Nepal folder to GitHub
39. Youâll Need to use these
commands on your CLI to
upload to GitHub.
⢠git status: See your changed files
⢠git add: Queue up files
⢠git commit: Make a commit
⢠git push: Push commits to
GitHub.com
Hello Everybody, welcome to WordCamp. Today Iâm here to speak about Git, GitHub and WordPress.
I had a client come up to me and say that she want her website redesigned. I agreed to redesign and basically made changes to her existing theme files. After the website was redesigned she ran a feedback form for her audienceâs input on the new redesigned website. She figured out that her readers preferred the old site compared to the new one because they were used to it. So after some months, she came back to me and asked me to bring back her old website.
I had a problem here. I didnât have backup of her old files because I made changes to her existing theme files. And I had no system to roll back past changes. Which made me code again. It was painful for me to code again.
At the end, I couldnât make it look like her old site. My client was angry and I lost her.
She figured out that her readers preferred the old site because they were used to it and also because itâs functionality. She then thought of keeping the functionality same as that of her old site and then only making changes to the styles. She then, after two months, said to me that she wanted her old site back.
I had a problem here. I didnât have backup of her old theme files because I had made changes to her existing theme files. Also, even if I did had her old theme files, I didnât have any system to go back and roll back those changes.
After that I had to go through this painful period where I had to redesign her website again to look like her old site. But I couldnât make it look like her old site because I didnât have any idea of how it looked. Hence, she was angry at me and I lost the client.
This not only happens while working for clients, but also happens while working for yourself. When I first figured about WordPress, I started creating WordPress themes. I used to have a folder for creating theme files. Whenever I used to add new feature, I used to create a new folder just for the feature just incase it doesnât work out. If the new feature wouldnât work out, Iâd could delete the folder and go back to the old files. But it wasnât practical. My workflow was getting pretty messy. I couldnât roll back changes either.
So, these were the pain points:
Backup
Unorganized and Messy Workflow
Difficult to Add New Features to your Projects
Hard to Collaborate with Others
Difficult to Track Changes
I then started searching for a solution to solve all these problem. Did some research and figuerd about git.
It did solve all my previous mentioned problems.
Now, if you are not a developer or a programmer, you can still benefit from Git. Because itâs not just for programmers, but also for writers and bloggers. Itâs just a system which anyone can use it to organize their project. For example, WordPress is writing a book on the history and development of WordPress using github. They are basically able to collaborate with anyone in the world. Without github, it would have been very difficult for them to collaborate. So, github is not only for programmers and developers, but also for writers and bloggers.
So, what is git?
In shortâŚ.
These are the basic tools youâll require to use github. Basic CLI. Basic Git Commands and setting up and using a repo.
You need to install git first to start using it. Whatever operating system youâre using, you can download git from git-scm.com/download.
Git-scm.com/download
You can download git from git-scm.com/download. Itâs available for mac, windows and linux from there.
Anyone whoâs not comfortable with command line or terminal can use GUI for GitHub. However, command line is recommended because itâs more powerful than the GUI, and offers lots of other features which GUI doesnât offer. If youâre just starting out then GUI can be helpful to you because youâll be able to see how things work.
Also, other 3rd party GUI clients are also available. Example includes Tower, Gitbox for mac. Git Extentions for Windows. Giggle, Gitg for Linux. And whole other range of GUI clients. You can google for it.
Okay, but whatâs the difference of using GitHub and using backup solutions like dropbox and google drive? You might be wondering why youâll need to use dropbox if you already have backup of it in dropbox. So, Iâll walk you through the features and advantages of using github.
Once you push your repo to GitHub, you can track all changes. See who changed it and when it happened. You cannot do this with backup solutions like dropbox.
You can also see exactly what you changed and roll back those changes if required. Itâs interface is similar to WordPressâs post revision control. The red highlighted area shows you your previous content whereas the green highlighted area shows you your recent content.
As Iâve said before it was very difficult and almost impossible for me to collaborate with my friend who wanted to help me. I didnât have any system for that. But github offers this. Itâs very easy to collaborate with other developers on GitHub.
Once you start using git, youâll not require many folders. One folder will be enough to manage your workflow, which makes it pretty organized.
Once you start using git, you wonât have lots of folders. Like I said before, I used to create lots of folders for a theme while Iâd create a new feature. But now while working with git, if you want to create a new feature, you can simply create a branch. If you like it, you can merge it. If not, delete it.
You can think of branch as a way to request a brand new working directory, staging area, and project history. It helps you create a new feature, and incase it doesnât work, you can delete it and simply go back to what you were developing. However, if it does work out, you can merge it with the main repo.
If you get on an airplane or a train and want to do a little work, you can commit happily until you get to a network connection to upload. If you go home and canât get your VPN client working properly, you can still work. In many other systems, doing so is either impossible or painful.
This was my biggest pain point and it solved it.
On this yearâs WordCamp San Francisco State of the Word, Matt announced that GitHub and WordPress will now work together for pull requests.
These are the basic git commands which you can learn to start playing around with git. Iâll walk you through them.
We use git status to see what the state our project is in. If youâve added new files or modified some existing files. Here, in the green, you can see two new files READE and hello.rb; and also in the red README which has been modified. So, it basically shows us what state our project is in.
You will use git add to start tracking new files and also to stage changes to already tracked files. You can see that README and hello.rb are not staged. After we do git add, they are staged for commit. Git add basically makes our files commit ready.
git diff will display what code or content you've changed in your project. The red highlighted text shows your previous data and the green highlighted area shows your recent data. You can also see the plus and minus sign, which explains the same thing.
You run git commit to record the snapshot of your staged content. You stage changes by doing git add as Iâve mentioned previously, and git commit to record the snapshot of your staged content. This snapshot can then be compared, shared and reverted to if you need to.
To share the cool commits you've done with others, you need to push your changes to the remote repository. Which shows up in GitHub. If you donât git push, your repository wonât get uploaded to GitHub.
These are the basic commands in the initial stage that youâll be using to work with git. However, once you go deep into git, youâll require more and more git commands.
You can think of git as creating a website on your localhost. You can only work on it and view it. But for you to make it available to everyone, youâll need to upload it to a web hosting service. And github is basically like a webhosting service.
WordCamp Nepal folder on our desktop.
I created this WordPressInfo.html file just for the demonstration purpose. Added some basic html.
Go to github.com and create a new repository.
Give repository the same name as in the desktop, which is âWordCamp Nepalâ.
Simply grab the code and push the folder to github.com.
You can use the previously mentioned git commands to upload it to github.com
So, now we have wordcamp nepal folder on github.
And wordpressinfo.html on github.
WordCamp nepal folder on your local computer looks like this.
Wordcamp nepal folder on github.com looks like this. You can see the repo name here. The folder structure here.
This is the text editor where I wrote some basic html. This is how it looks on our local computer.
And this is how it looks on github.com
You can check it out live on github.com by going to.
Pro git is a book by scott chacon that has everything you need to know about git from beginning until the end. Itâs available for free online and as ebook.
Git immersion is a guided tour that walks you through the fundamentals of git. You can learn it in your browser.
Learn git is my personal favorite. Itâs an interactive tutorial which is similar to codeacademy, but for git.
For all the git commands, you can bookmark gitref.org for handy git reference.
You donât want to make premium themes public on GitHub. Private repo costs money.
So, the alternatives to GitHub are:
These are some of the alternatives of GitHub. I personally use Bitbucket for private repositories for premium WordPress themes. But you can try any other services you find comfortable.