The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,861 other subscribers

Archive for the ‘DVCS – Distributed Version Control’ Category

The most useful git commands | orga.cat

Posted by jpluimers on 2020/07/22

The most advanced commands are towards the tail of [WayBack] The most useful git commands | orga.cat

Here there are some examples of git commands that I use often.

They include:

Get the git root directory

git rev-parse --show-toplevel

Source: http://stackoverflow.com/q/957928/1391963

See closest tags

git describe --tags `git rev-list --tags --max-count=1`

Source: http://stackoverflow.com/q/1404796/1391963. See also git-describe.

See recently used branches (i.e. branches ordered by most recent commit)

git for-each-ref --sort=-committerdate refs/heads/ | head

Source: http://stackoverflow.com/q/5188320/1391963

Which means I need to look into at least these:

–jeroen

 

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »

Git install tip for Windows installations: “”

Posted by jpluimers on 2020/07/21

When installing Git on Windows, you might want to change the default HTTPS transport back-end setting into “Use the Windows Secure Channel library” as it will use the Windows Certificate Stores for certificate validation. For Windows users, this allows for a more natural way to configure additional Root CS certificates (for instance the ones coming from Active Directory Domain Services).

If you later want to change this, then you can either re-run the installer, or perform these commands (based on the installer source):

To select the OpenSSL library:

config --system http.sslBackend openssl

To select the Windows Secure Channel library:

config --system http.sslBackend schannel

I do need to check out other ways of installing it (more on that in [WayBack] 5 Ways to Install Git on Windows · James Sturtevant), but for now I’m using the regular installer.

At first time install (subsequent installs will re-use the first-time install location without a way to overwrite them):

  • If you run that “As Administrator”, then it will install for all users (64-bit in C:\Program Files\Git, 32-bit in C:\Program Files (x86)\Git)
  • Otherwise in %LOCALAPPDATA%\Programs\Git which usually is in C:\Users\<username>\AppData\Local\Programs\Git).

Note that the actually executables are inside a bin subdirectory of the installation path.

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »

“error: invalid object 100644” “git svn”

Posted by jpluimers on 2020/07/14

A while back, while using “git svn”, on a Windows system, I got [Archive.is“error: invalid object 100644” “git svn” – Google Search after statements like this:

# git svn rebase
error: refs/remotes/git-svn does not point to a valid object!
error: invalid object 100644 ac7df132f5bd7d639fc525f1f0204a546658d0c5 for 'Source/ToDoList/GX_ToDo.pas'
fatal: git-write-tree: error building trees
write-tree: command returned error: 128

# git svn fetch
error: refs/remotes/git-svn does not point to a valid object!
error: invalid object 100644 ac7df132f5bd7d639fc525f1f0204a546658d0c5 for 'Source/ToDoList/GX_ToDo.pas'
fatal: git-write-tree: error building trees
write-tree: command returned error: 128

In my case, regular git operations (like branching, committing, pushing, etc) worked fine, but git svn would fail.

One problem was that [Archive.is“error: refs/remotes/git-svn does not point to a valid object” – Google Search only returned one un-meaningful result: [WayBack] gist:87613 · GitHub.

Luckily, I had a backup (though it was from a while ago as that VM had not been in use for quite some time) which is the first part in [WayBack] Git FAQ – Git SCM Wiki: How to fix a broken repo?.

Since I was still interested finding out how to resurrect, just in case this happens at a time the backups do not go back far enough, I tried the steps below.

The very first fixing step is to ensure you can quickly restore things, or even better: operate on a copy of the broken pieces. On Windows, robocopy /mir is my friend for this, in Linux rsync -avloz (although on some systems, -z crashes).

TL;DR from the fixing steps

Find out what problems you have, and in which order to fix them. Otherwise you will break more stuff and take longer to fix it.

In this case, two things failed: one on the git side, and one on the git svn side. Since git svn depends on git, the best approach is to fix the git problem first, then the git svn thing.

Fixing this manually try 1

Read the rest of this entry »

Posted in CertUtil, Development, DVCS - Distributed Version Control, git, Hashing, md5, Power User, Security, SHA, SHA-1, SHA-256, SHA-512, Software Development, Source Code Management, Subversion/SVN, Windows | Leave a Comment »

How can I debug git/git-shell related problems? – Stack Overflow

Posted by jpluimers on 2020/07/07

Always read the comments (:

Cool tip by Paul Irish (but remember it will dump the binary curl output as well) at [WayBack] How can I debug git/git-shell related problems? – Stack Overflow:

There are a few GIT_TRACE options, beyond the core one. Here’s the über-verbose option: set -x; GIT_TRACE=2 GIT_CURL_VERBOSE=2 GIT_TRACE_PERFORMANCE=2 GIT_TRACE_PACK_ACCESS=2 GIT_TRACE_PACKET=2 GIT_TRACE_PACKFILE=2 GIT_TRACE_SETUP=2 GIT_TRACE_SHALLOW=2 git pull origin master -v -v; set +x

Related: [WayBack] Git – Environment Variables

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »

Git – Credential Storage: caching for some time (and removing it)

Posted by jpluimers on 2020/06/24

From [WayBackGit – Credential Storage:

Git has a few options provided in the box:

  • The default is not to cache at all. Every connection will prompt you for your username and password.
  • The “cache” mode keeps credentials in memory for a certain period of time. None of the passwords are ever stored on disk, and they are purged from the cache after 15 minutes.

$ git config --global credential.helper cache

The cache helper accepts the --timeout <seconds> option, which changes the amount of time its daemon is kept running (the default is 900, or 15 minutes).

This is a one time config setting.

To remove it, use this command:

$ git config --global unset credential.helper cache

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »

Git submodule inside of a submodule (nested submodules) – Stack Overflow

Posted by jpluimers on 2020/06/23

Not sure why yet, but with a nested pacapt git submodule inside another git submodule bash.aliases, when pulling bash.aliases it did pull the actual content of pacapt, only the reference.

I wanted this because this allowed me to abstract installation of common packages no matter if the system was using the apt-get, zypper, homebrew or other package managers. [WayBack] GitHub – icy/pacapt: An Arch’s pacman-like package manager for some Unices supports many in a coherent way (I’m way past the not-invented-here syndrome:[WayBack] linux – A universal bash script for installing with apt-get and yum – Stack Overflow).

A git pull --recurse-submodules failed.

Even executing git submodule update --init --recursive at the top-level did not get it.

Forcing a submodule to update after a shallow clone

I had to to inside the bash.aliases submodule and perform git submodule update --init <submoduleName>:

$ git submodule update --init pacapt
Submodule 'pacapt' (https://github.com/icy/pacapt.git) registered for path 'pacapt'
Cloning into '/home/jeroen_pluimers_com/bash.aliases/pacapt'...
Submodule path 'pacapt': checked out '31f43d901055e3c361dfbcefdf50231442da13de'

I got this workaround at [WayBack] Git submodule inside of a submodule (nested submodules) – Stack Overflow.

It might mean I need to read more deeply into these asgit submodule update --init --recursive might by now need to be git submodule update --init --recurse-submodules, but the docs are not clear on that:

Forcing a recursive clone including submodules

This worked out of the box on a Git > 2.13:

D:\Versioned\github.com\project-jedi>call git clone --recurse-submodules -j8 https://github.com/project-jedi/jcl.git
Cloning into 'jcl'...
remote: Enumerating objects: 79, done.
remote: Counting objects: 100% (79/79), done.
remote: Compressing objects: 100% (46/46), done.
Receiving objects: 100% (82053/82053), 78.7delta 33), pack-reused 81974 eceiving objects: 100% (82053/82053), 72.05 MiB | 7.14 MiB/s
9 MiB | 3.77 MiB/s, done.
Resolving deltas: 100% (65056/65056), done.
Checking out files: 100% (3461/3461), done.
Submodule 'jcl/source/include/jedi' (https://github.com/project-jedi/jedi.git) registered for path 'jcl/source/include/jedi'
Cloning into 'D:/Versioned/github.com/project-jedi/jcl/jcl/source/include/jedi'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 379 (delta 0), reused 3 (delta 0), pack-reused 375
Receiving objects: 100% (379/379), 123.87 KiB | 568.00 KiB/s, done.
Resolving deltas: 100% (120/120), done.
Submodule path 'jcl/source/include/jedi': checked out 'd04f4d341051c1245c06c822468ea927073e26eb'

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Source Code Management | Leave a Comment »

tfs – How to retrieve the hash for the current commit in Git? – Stack Overflow

Posted by jpluimers on 2020/06/18

Based on [WayBack] tfs – How to retrieve the hash for the current commit in Git? – Stack Overflow

Get current hash:

git rev-parse HEAD

Show summary of current commit, including hash:

git show --summary

Show all hashes of all branches (both in heads and in remotes) and tags:

git show-ref

Get current hash with a * marking if it is dirty:

git describe --always --abbrev=0 --match "NOT A TAG" --dirty="*"

The last one was [WayBack] answered by [WayBack] Rado:

display the full sha1 of the commit, but append an asterisk to the end if the working directory is not clean. …

Here is the one liner that does:
git describe --always --abbrev=0 --match "NOT A TAG" --dirty="*"
Result: f5366ccb21588c0d7a5f7d9fa1d3f85e9f9d1ffe*

Explanation: describes (using annotated tags) the current commit, but only with tags containing “NOT A TAG”. Since tags cannot have spaces, this never matches a tag and since we want to show a result --always, the command falls back displaying the full (--abbrev=0) sha1 of the commit and it appends an asterisk if the working directory is --dirty.

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »

How to move Git submodule to sub-directory? – Stack Overflow

Posted by jpluimers on 2020/05/26

It’s a few steps as per [WayBackHow to move Git submodule to sub-directory? – Stack Overflow, so I’m not sure it is the best solution, but it at least works (thanks Philzen):

Had the same problem just the moment ago and ended up deleting the submodule reference (as outlined in this article) and recreating it where i wanted it to go.

To follow your example of moving submodule jquery into repos/jquery

  1. Delete the (typically three lines) submodule reference from .gitmodules.
  2. Check .git/config for references to the submodule and remove them, if existent
  3. do git rm --cached jquery to cut the submodule reference out of the repository
  4. remove the old submodule folder
  5. recreate you submodule reference (as you possibly did before) with git submodule add git://github.com/jquery/jquery.git repos/jquery

In case your submodule was set to specific tag, respectively commit (which you’ll surely have in a stable project) you will have set it again.

Due to this complex process i am strongly hoping there is (or will be, at least on the git roadmap) a more straightforward way of achieving this. If not, surely some scripts could be fumbled together to do this quicker…

References:

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »

version control – How do I do an initial push to a remote repository with Git? – Stack Overflow

Posted by jpluimers on 2020/04/30

Based on [WayBack] version control – How do I do an initial push to a remote repository with Git? – Stack Overflow, this is what I do:

On the server

mkdir my_project.git
cd my_project.git
git --bare init

On the client

mkdir my_project
cd my_project
touch .gitignore
git init
git add . git
commit -m "Initial commit"
git remote add origin youruser@yourserver.com:/path/to/my_project.git
git push --set-upstream origin master

The last one is important, especially when you have multiple remotes.

Some servers allow you to skip the server part, as they run them automatically when pushing a new repository from the client.

This can be both an advantage and a disadvantage, for instance when you have typos when adding the remote.

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »

Mono-repo or multi-repo? Why choose one, when you can have both?

Posted by jpluimers on 2020/04/29

Interesting: [WayBack] Mono-repo or multi-repo? Why choose one, when you can have both?

Uses: [WayBack] GitHub – mateodelnorte/meta: tool for turning many repos into a meta repo. why choose many repos or a monolithic repo, when you can have both with a meta repo?

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »