Hi, good morning.
Ok, so are you saying that even though, using ls -la, I "see" an updated (size/date) script having first switched "back" to main (from steve) git has NOT actually done anything to the "live" script (so running it would execute the pre-updated script) and it is not until I switch back to steve, do a git push, merge in Github, and then (on branch main) do a git pull that the "changes" being made would become executable from within the main branch?
I guess what I'm trying to understand is why I "see" the changes (date/size) when switching back to main from steve? Also, when back in main (and before any push to github etc.) I can cat the "changed" script and see the changes within!!
Original Message:
Sent: Mon June 19, 2023 05:14 PM
From: Stephen Ulmer
Subject: git-2.38.3-1 -- Odd behaviour when switching branches and modified file NOT committed
I just want to clarify: git would not have merged for you, it would have carried the changes to the new branch so that
you could do a merge.
--
Stephen L. Ulmer
Enterprise Architect
Mainline Information Systems
(m) 352-870-8649
Original Message:
Sent: 6/19/2023 4:25:00 AM
From: Steve Munday
Subject: RE: git-2.38.3-1 -- Odd behaviour when switching branches and modified file NOT committed
Stephen,
Hi, good morning.
Ok, so if I've understood correctly, as I was in the "steve" branch and made changes which would merge nicely with the original script in "main" branch when I did switch to "main" (without any add/commit beforehand) that merge took place (as no issues found). Would there have been issues when I switched then Git would have thrown up a message.
Many thanks, Steve
------------------------------
Steve Munday
AIX, IBM i, HMC, PowerVM
Original Message:
Sent: Fri June 16, 2023 01:50 PM
From: Stephen Ulmer
Subject: git-2.38.3-1 -- Odd behaviour when switching branches and modified file NOT committed
Okay, put on a helmet:
Git will let you switch branches with local changes when doing so would not clobber anything on the new branch.
So if you are on branch1 and create branch2, there is nothing to clobber. It will switch and take the modified files with it.
If you try to switch from branch1 to an existing branch2, with incompatible changes to working files, then git won't let you until you do something to avoid losing your work. You could commit it, to put it into the stash. Look into git stash push and git stash apply.
These rules always work, but if you have staged files, it might not be obvious what would be included in the change set.
--
Stephen L. Ulmer
Enterprise Architect
Mainline Information Systems
Original Message:
Sent: 6/16/2023 11:52:00 AM
From: Steve Munday
Subject: git-2.38.3-1 -- Odd behaviour when switching branches and modified file NOT committed
AIX: 7.3.0.2
Git: 2.38.3-1 (latest)
In Git I created a branch ("steve") and switched to it before modifying a script, at this stage I have not run "git add" or "git commit". I then switched to "main" and Git allowed to do this.
NOTE: What does the "M" (first column second line) actually mean here? Is it just meaning "M"odified?
$ git switch mainM nim_scripts/check_hmc_IBMi.shSwitched to branch 'main'Your branch is up to date with 'origin/main'.
The timestamp on the file in "main" has been updated and the content too.
$ ls -latotal 144drwxr-xr-x 2 mundays emea 4096 Jun 16 09:04 .drwxr-xr-x 4 mundays emea 4096 Jun 16 09:04 ..-rwxr-xr-x 1 mundays emea 3519 Jun 16 11:23 check_hmc_IBMi.sh
I then switched back to "steve" and did a "git restore"
$ git switch steveM nim_scripts/check_hmc_IBMi.shSwitched to branch 'steve'$ git statusOn branch steveChanges not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: check_hmc_IBMi.shno changes added to commit (use "git add" and/or "git commit -a")$ git restore check_hmc_IBMi.sh$ git statusOn branch stevenothing to commit, working tree clean$ ls -latotal 144drwxr-xr-x 2 mundays emea 4096 Jun 16 11:29 .drwxr-xr-x 4 mundays emea 4096 Jun 16 09:04 ..-rwxr-xr-x 1 mundays emea 3405 Jun 16 11:29 check_hmc_IBMi.sh
The timestamp got updated (due to the removal of my change) and the content was also reverted back to before my change.
Question
Is this considered "normal behaviour" for Git as I thought that if you try to switch to an alternate branch with un-committed changes you get prompted?
Many thanks, Steve
------------------------------
Steve Munday
AIX, IBM i, HMC, PowerVM
------------------------------
#AIXOpenSource