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. If you find yourself on a working branch, type
git checkout masterin order to switch back.
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 fetchis a safe way to check if there are any changes incoming from master/main before you do a pull.
git pullwill allow you to grab the latest code from master/main.
git checkout -b < name of new branch >
-bwill 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 add -Aor
git add <name of file>
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.