Tuesday, 20 May 2025

[git] Create a local branch from another branch

From the active branch

git checkout -b <LOCAL_BRANCH>

From a donator branch

git checkout -b <LOCAL_BRANCH> <DONATING_BRANCH>

Monday, 12 May 2025

[git] Associate a remote branch to a local branch

Obviously, the remote branch cannot exist yet and the local branch is not associated with a remote branch. However, there might be reasons for re-associate the local branch to a another remote branch, I cannot imagine yet.

Both branches have the same name

git checkout <LOCAL_BRANCH> # Checkout the local branch
git push origin <LOCAL_BRANCH> # Pushing the local branch creating a unconnected remote branch
git push --set-upstream origin <LOCAL_BRANCH> # associate the local to the remote branch

The remote branch has a different name

git checkout <LOCAL_BRANCH> # Checkout the local branch
git push origin <LOCAL_BRANCH>:<REMOTE_BRANCH> # Pushing the local branch creating a unconnected remote branch
git push --set-upstream origin <REMOTE_BRANCH> # associate the local to the remote branch

Sunday, 9 March 2025

[PDF] Merge two pdf files

Task

I recently needed to merge two pdf files, i.e. concatenate one after the other. My PDFsam Visual installation was unexpected broken, and I did not want to spend the time quite then to fix it. So, I tried to use imagemagicks `convert` and acutally it worked but had a price. It converts all to images, i.e. a file from 200 kB size concatenated to a file with 4.8 MB resulted in a file with 13 MB. And the originally non-image parts were blurred a bit. All in all, not acceptable to me.

Solution

Use `qpdf` but watch out. Its use is not so straight forward. The following works.

qpdf --empty --pages file1.pdf file2.pdf [...] -- output.pdf

You cannot shortcut to

qpdf file1.pdf --pages file2.pdf [...] -- output.pdf

With this, file1.pdf will be missing. I do not know the reason for this.

[git] Create a local branch from another branch

From the active branch git checkout -b <LOCAL_BRANCH> From a donator branch git checkout -b <LOCAL_BRANCH> <DONATING_BRANCH...