github time travelling explained (it is not what you are thinking about)

Do you know how much freedom we got by having git?
I am always amazed by reviewing pull requests where there is confirmed by a developer only one commit. By confirmed, I mean that I asked a dev if there was more of them, but mostly it is the only one that is pushed to the PR (sometimes there are 2 or 3 as the branch needed to be adjusted with the main/master one). That situation can bring a few issues:

  • There is a risk that all changes will be lost when a device that is in use will have a big boom and there will be  commit/push to the remote/global repo
  • There is no restore point, which is helpful to try/test different solutions, CTRL+Z not always works as a charm 
  • Pushing code, in most cases, means that it will trigger CI/CD pipeline and find any issues early

As git is giving us very fast commiting experience (it is not a slow VPN connection to TFS, it is local repo) then you can be as extreme as crazy to commit every 5 seconds.


So that means we are recording most actions, especially when our IDE is set to save file on focus change/file change. 

As we can see below,  the commits are only added when a change s persisted on disk, so when we are idle - nothing is added and we will don't need to travel over empty changes.

Below listing for a simple batch to auto-commit

As we are commiting to local branch, then no one shall see this commits..

git checkout __our_feature_or_bug_branch_
git merge --squash __local_branch_name_
git commit



Using gitUI,a rather gitk, you can browse commits and files and time travel



And finally when the working branch is merged with destiation, we can see only on commit:



Now, ask yourself - how many hours lost you were experiencing by re-doing some changes that were overwritten, but not committed to the repo? I lost many hours, that is the reason I try to automate this and from time to time merge changes to feature branch and I am PUSHING code out of my workstation. (BTW some ppl use their one drive for a repo location, and they are complaining that all takes minutes to go.....)

There is nothing for free, our local repo from time to time will require a bit of maintenance, but git will prompt you for that in the UI tool (see below), or on a command prompt as well.



Happy commiting!




Comments

Popular posts from this blog

when a new guy joins a team...

FizzBuzz - my first interview task on whiteboard

are YOU a garbage collector?