08-01-21
At the start of every project, most managers generally ask the same basic setup question, "how should we establish the git flow?" At most large-scale teams and companies, there is a pretty rigorous method set in place in order to prevent stepping over each other's toes. But having only been a front-end developer for the most part of my time, I can only account for the issues that I faced and how my flow works from a day-to-day basis.
There are senior engineers and other backend developers who are tasked with the extra work of wrangling bug issues and branch management. This article won't cover those steps, I will only highlight the brief steps I take when managing my local system and then when I need to deliver them.
Below are the commands I usually type in from start to finish when working by myself. My current site follows this specific method.
Let's begin with the basic git commands.
The following commands are what I usually type in (in this order specifically) when getting a new branch up and running on my local machine.
git branch
git branch
. If you find yourself on a working branch, type git checkout master
in order to switch back.git status
git stash
. This holds your current progress in place and puts your branch back at to the last commit. If you want to bring it back up, simply type git stash pop
.git fetch && git pull
git fetch
is a safe way to check if there are any changes incoming from master/main before you do a pull.git pull
will allow you to grab the latest code from master/main.git checkout -b < name of new branch >
-b
will no only make a new branch for you, but it will switch you over to that branch automatically. (note: do not add the open and close brackets in your code)Alright, let's say you are ready to commit some changes and deliver them to your team. I usually type the following commands.
git status
git add -A
or git add <name of file>
-A
syntax. There are instances where I need to only commit specific changes from my local, say a specific CSS file, a few selected JavaScript files. In the past, for example, working in Drupal I had to make sure I didn't unload unnecessary modules. These files were changes I needed in order to get my local running properly, but I didn't need to push them back upstream, the team already has them.git commit -m " < your commit message here > "
git checkout master
git merge < name of latest committed branch >
git push origin master
Well, this is it. I hope this has been helpful for you. Again, these are the steps and commands I have grown accustomed to. But feel free to go in between and add additional commands as needed for your project.
Happy coding!