Deep into the git matrix….

The past two days have been a deep dive into the git matrix, it was a magical journey troubleshooting and discovering beautiful workflow between git and Github.

The first thing I’m excited to share is this beautiful log graph command that anyone deserves to have, it gives you a beautiful visual of what you have accomplished in the terminal, looks even more visually pleasing with my current favorite terminal theme “homebrew“ for a neon intense Matrix look. To set up “homebrew", please go to “setting” under dropdown menu after clicking “Terminal“on the top left, see below:

Now everything looks visually awesome, let’s finally reveal this incredible command:

git log --all --decorate --oneline --graph

the nickname is “git log a dog“ ( --all --decorate --oneline --graph ) I picked this one up from a Youtube tutorial, my warm thanks and credit to Cameron McKenzie

Here’s my beautiful result of a stunning visual representation of what I have been doing the past two days:

The most challenging part is merging conflict between local main and local branch, I was able to detect the cause of the conflict is due to having different edit in the file apple.rtf in main and branch “demimi“, that could happen when your company has two people trying to make some edit on the same file, then the person working on branch tries to merge into main. The solution is to just PICK ONE cuz git is confused which one it should be and she wouldn’t know what to do, it wouldn’t be fair to pick either right? Once you pick one, then merge again, it should work fine.

Another conflict popped up like below during the experimentation. This is rather interesting, please share your thoughts with me if you have encountered a similiar situation.

Eventually, merging worked out, the conflict was resolved, me ang git are both happy.

Based on my experiment and case study, here are some workflow tips for troubleshooting, and some healthy habits that might help you stay out of trouble:

  • Make sure to push your local branch to Github first, this may or may not be why your local branch has trouble merging with with your local main. I understand you might want to just focus on getting the work done on local branch and push them altogether in the end, but it’s just a cleaner workflow to get this done to avoid possible conflict in the future.

  • Avoid editing the same file in main and branch, again, this would cause merging conflict.

  • If you delete a file locally on the branch, make sure to go through the whole “add—commit—push“ process, otherwise, this file will still appear on your main when you merge the branch into the main, because you never committed the deletion, so it’s still there as far as git’s concern.

  • Check your graph tree using “git log a dog“ command periodically to avoid having a messy diverging relationship between main and branch, a good habit might be rebasing as it fits if the structure is diverging too much unnecessarily.

  • Before committing anything, when in doubt, just go ahead and check which branch you are currently in with “git branch“ command.

  • I personally like the habit of checking “git status“ as a visual note and confirmation to keep me visually organized.

And below is the satisfying moment I want to share with you when the merging conflict got resolved!

That’s it for now, happy Gitting!

Previous
Previous

the making of the Dice rolling app

Next
Next

the making of “I AM RICH”