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,982 other followers

Archive for the ‘git’ Category

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 »

 
%d bloggers like this: