GIT Tips

Doing diffs

I use Beyond Compare.

First it must be configured in .gitconfig for GIT on Windows (not Linux! Not MacOS!), as per instructions in BeyondCompare documentation

I like to use it on a folder, like this (this shows differences between working tree and last commit on the working branch):

aleja@CC-Labs-2 MINGW64 ~/Documents/Code/consulting/CCL_Finastra/project (EAA_PCL)
$ git difftool HEAD --dir-diff

Get information on origin

Useful:

git remote show origin

git remote show origin | grep -v feature  # To filter out lines for feature branches (reduce output size)

Update the master branch from a feature branch

This is done by dhecking all work in the feature file, switching to the master branch and doing a git merge <feature branch>. Below is an example.

Step 1: Notice feature branch is ahead of master

## Notice how ``master`` is 7 comments behind the ``EAA_PCL`` branch:

aleja@CC-Labs-2 MINGW64 ~/Documents/Code/consulting/CCL_Finastra/project (EAA_PCL)
$ git log --oneline -n 10
334a6a9 (HEAD -> EAA_PCL) Minor improvements to the EA Domain Sphinx extension, relating to the :eaa:font: role  ## EAA_PCL branch
62fe93d Completed implementation of EA_Analyst_Domain directives/roles related to controlling fonts
5313474 Enhanced the EAA custom Sphinx domain to be able to change the font of text as part of role
58f7550 [EAAPCL-32] Finished documenting GIT and Analysis_Utilities libraries. Experiment in progress with a raw HTML role as a way to control font color
ccbc995 [EAAPCL-32] Continued commenting the GIT libraries. Almost done
961b54c [EAAPCL-32] Progressed GIT_Analyzer documentation, and enhanced the EAA domain so that we have a sidebar with the members of the library
6c83408 Cosmetic documentation changes
94be5c7 (master) Cosmetic change to documentation   ## Master branch
20dfc8a Added documentation for adding a product to Azure ingestion
3b40862 Completed presentation at EA Forum

Step 2: Commit in feature branch

Step 3: Switch to master branch

aleja@CC-Labs-2 MINGW64 ~/Documents/Code/consulting/CCL_Finastra/project (EAA_PCL)
$ git checkout master
Switched to branch 'master'

Step 4: Merge feature file into master

## This is a fragment of real output aleja@CC-Labs-2 MINGW64 ~/Documents/Code/consulting/CCL_Finastra/project (master) $ git merge EAA_PCL Updating 94be5c7..334a6a9 Fast-forward .gitignore | 3 + …/business_logic/build_a_distribution.ipynb | 309 +- …/business_logic/control_plane_utilities.py | 159 +- …/business_logic/documentation_pilot.ipynb | 559 —- control_plane/business_logic/pipeline.ipynb | 333 ++-

Step 5: Verify that the master branch has moved forward to feature branch

aleja@CC-Labs-2 MINGW64 ~/Documents/Code/consulting/CCL_Finastra/project (master)
$ git log --oneline -n 10
334a6a9 (HEAD -> master, EAA_PCL) Minor improvements to the EA Domain Sphinx extension, relating to the :eaa:font: role
62fe93d Completed implementation of EA_Analyst_Domain directives/roles related to controlling fonts
5313474 Enhanced the EAA custom Sphinx domain to be able to change the font of text as part of role
58f7550 [EAAPCL-32] Finished documenting GIT and Analysis_Utilities libraries. Experiment in progress with a raw HTML role as a way to control font color
ccbc995 [EAAPCL-32] Continued commenting the GIT libraries. Almost done
961b54c [EAAPCL-32] Progressed GIT_Analyzer documentation, and enhanced the EAA domain so that we have a sidebar with the members of the library
6c83408 Cosmetic documentation changes
94be5c7 Cosmetic change to documentation
20dfc8a Added documentation for adding a product to Azure ingestion
3b40862 Completed presentation at EA Forum

Changing working branch

Example of how to change remote tracking branch (for example, when team moves to develop a new release in a new branch, s o work moves from the 5.3.1.5 to the 5.5.2 branch in the remote)

ahernand@NYCLNY6X2VBH2 MINGW64 /c/Alex/CodeRepos/Repos-Essence-L3/cbsl3repos (develop_5.3.1.5)
$ git branch -vv
all             d4b5d1c367 Merge pull request #998 in EL/cbsl3repos from release/5.3.1.5-FB-5892-cloned-backport-mpm-host-id-changes-in-essence-payments to develop_5.3.1.5
* develop_5.3.1.5 d4b5d1c367 [origin/develop_5.3.1.5] Merge pull request #998 in EL/cbsl3repos from release/5.3.1.5-FB-5892-cloned-backport-mpm-host-id-changes-in-essence-payments to develop_5.3.1.5
(base)
ahernand@NYCLNY6X2VBH2 MINGW64 /c/Alex/CodeRepos/Repos-Essence-L3/cbsl3repos (develop_5.3.1.5)
$ git checkout --track origin/develop_5.5.2
Checking out files: 100% (420/420), done.
Switched to a new branch 'develop_5.5.2'
M       MisysPD/PaymentMessaging/BFPaymentMessaging/.project
M       MisysPD/PaymentMessaging/BFPaymentMessagingExternalAdapters/.project
Branch 'develop_5.5.2' set up to track remote branch 'develop_5.5.2' from 'origin'.
(base)
ahernand@NYCLNY6X2VBH2 MINGW64 /c/Alex/CodeRepos/Repos-Essence-L3/cbsl3repos (develop_5.5.2)
$ git branch -vv
all             d4b5d1c367 Merge pull request #998 in EL/cbsl3repos from release/5.3.1.5-FB-5892-cloned-backport-mpm-host-id-changes-in-essence-payments to develop_5.3.1.5
develop_5.3.1.5 d4b5d1c367 [origin/develop_5.3.1.5] Merge pull request #998 in EL/cbsl3repos from release/5.3.1.5-FB-5892-cloned-backport-mpm-host-id-changes-in-essence-payments to develop_5.3.1.5
* develop_5.5.2   034115d2f3 [origin/develop_5.5.2] Merge pull request #1099 in EL/cbsl3repos from release/5.5.2-FBIT-8943-provide-dsx-implementation to develop_5.5.2

Problems updating repos having files with long filenames

* GOTCHA * - Note from February 15, 2020

Some repos have update issues. Typically it’s because GIT gets confused thinking there are outstanding edits, because of some long files that GIT on Windows was not able to check out, so GIT later thinks they are unstaged/uncommitted deletes from the GIT workspace. This impedes doing a git pull and can’t be remedied since they can’t really be deleted in the repo nor made to appear in the workspace.

At first the only recourse was to re-clone from scratch the offending repo. This could take hours on a slow connection.

Alternatively,searching in the web found that this is a Windows issue that can be fixed by setting a configuration in GIT as follows. I did that and that seemed to work, at least for now…

git config --system core.longpaths true

* TIP * - Note from February 15, 2020

To remove files that were committed but which GIT should ignore, add to .gitignore (prevents more such files to be added) and to remove the ones that were already added, do something like

git rm --cached  --ignore-unmatch   presentations/200207 Essence update/.ipynb_checkpoints/*

The --cashed is important so that it be removed from the repo but not from the working directory (for example, for useful tempory or backup files generated by IDEs that should not be commited)