The essential Git Bash to GitHub workflow to get you productive fast!
Git Bash may appear to be a veritable beast to tame. Luckily, you don’t need much to start being productive and implementing an effective workflow.
The PCP Workflow overview
When you work with version control repositories, you must acknowledge that there is a server loaded with information that may be vital to your project. That goes without saying that in the situation that you are working as part of a team, there will be multiple people submitting changes to the same server.
How do you avoid merging conflicts and other conflicts with the server? It is extremely important to be mindful of the order in which you process commands when using Git Bash-Github version control.
PCP is an acromion I personally use to remember the effective and fool-proof way to version control my projects. PCP stands for Pull, Commit, and Push, we will be exploring what each means and how to execute them.
PCP workflow steps-by-step:
- Pull Downloads the information present in our GitHub repository giving us the most up-to-date version possible, and merges it with your current work.
$ git pull
When using git pull, you must specify the source from which you are pulling your information and the receptor.
$ git pull origin master
Note: If you need more information on setting up a connection between Git Bash and GitHub, please visit the following link: How to connect Github to Unity — A quick and easy guide!
Remember. You can always check which changes are currently available for with git status. It will show you all unsaved changes in red.
$ git status
2. Add all the unsaved changes you wish to back up in your repository with the following command.
$ git add .
git status will show you all the added files in green.
You can also add individual files by using the name of the specific file instead of “ . ” which stands for “all”.
3. Commit your added changes via commit -m, which allows you to attach a message to briefly detail what you’ve added.
$ commit -m "Added a laser to my game"
4. Push the committed changes to the server via
$ git push origin master
Summary: The essential workflow goes as follows
- You are pulling information from the server to make sure you have the most up-to-date version of the project, and not cause any conflicts.
- You are adding your current changes with the data you pulled from the server.
- You are committing that these are the changes you want to store
- Lastly, you are pushing the new content to the server.
In my next article, I will be showing you how to make your Unity Editor more productive!