Working and managing large development projects is a very serious proposition. An important challenge is code version management a number of developers create and update code for the project.
To maintain the history and various versions of the code, the best technical solution is Git. This tool allows you to build the history of the code by updating nodes with unique hashes.
Git offers a set of commands for maintaining code versions and deployment on the production servers. It works equally well with GitHub and bitbucket and it an ideal component of the workflows of development projects.
In this article, I will offer a detailed overview of creating local repositories and how a developer can add, commit, merge code and view the changelogs. I will also demonstrate a workflow between local machine->GitHub->Production server for automatic code deployment.
-
Git Architecture
-
Git Installation
-
Local Code Repositories
-
Git Staging Environment
-
Pushing code to GitHub
-
Clone & Pull the Repo from GitHub
-
Working with Branches
-
Automatic Deployment through GitHub
Git Working Architecture
1. Working Directory
2. Staging Directory
3. Repository
Git Installation on Different OS
Working with Local Repository
Adding Files to Staging
Status of Tracked Files
Committing the Changes
Logging and Checkout Commits
Git Staging Directory: File Removal
Push Code to GitHub
Clone & Pull the Repo From GitHub
Working with Branches in Git
Comparing Branches
Merge Two Branches
Resolve Merge Conflicts
-
Aborting the merge
-
Resolving conflicts manually
-
Using Tools
Automatic Deployment with GitHub
Create a Webhook in GitHub
Tools for Automatic Deployment
Beside creating your own workflows, you can also use open source or paid tools for automatic deployment to your production server. DeployBot and deployHQ are two popular tools for continuous integrations.
Final Words
Shahroze is a PHP Community Manager at Cloudways – A Managed PHP Hosting Platform. He’s always in search of new frameworks and methods to implement them. Besides his coding life, he loves movies and playing soccer with friends. You can email him at shahroze.nawaz@cloudways.com