Generate a TOC for Markdown (Bitbucket, Git or Gitlab)

This tiny tutorial shows, how to generate a TOC for Markdown with the help of a tiny npm package called doctoc in just a few seconds. Since a while I write down the most important facts about a project or an module to the README.md file of the corresponding GIT repository. That’s good to  keep […]

GIT – reconnect remote branch

Sometimes it is necessary to remap a local git  branch to a remote one (reconnect remote branch). For me it was the case, because I accidentally removed all origins in a multi-origin setup. Hence I got the following error message when trying to pull without naming remote and branch, although I re-added and fetched all […]

Export git subfolder to archive

Today a colleague of mine wanted to export a single folder from a git repository to a tar.gz archive. This is how to export git subfolder to archive: git archive –remote=’git@bitbucket.org:sheldon/ask-sheldon.com.git’ master path/to/file/or/folder/in/repo –format=tar.gz > archived_folder.tar.gz With this snippet the git repository folder path/to/file/or/folder/in/repo is exported to the archive file archived_folder.tar.gz. The archive will be cleared of all […]

Remove a tag from GIT version control

Recently I accidentally added a wrong tag to one of my git repositories. So I had to remove a tag from GIT. Here is how I did it: $> git tag -d release_2.0.0 $> git push origin :refs/tags/release_2.0.0 What these two lines do is: delete tag from local repository pust the update (deletion of tag) […]

GIT – Remove file permissions

In most cases it is useful to manage file permissions for such projects separated from GIT otherwise these permissions are forced on all machines checking out the respective repository. And that can really be a really tricky affair. To remove file permissions from repository, you can run these commands from within your project folder (where .git folder […]

Cherry picking

Sometimes it is necessary to merge partial changes from one branch into another. Therefor you can use cherry-picking and merge a chosen commit into the actual branch: $> git cherry-pick a686df3 [sprint-04 39f1473] FZMP-993- Download actual db 2 files changed, 88 insertions(+), 43 deletions(-) create mode 100644 tools/mina/config/deploy_db.rb  

Extract single file or folder

You know the problem when trying to get just one file or folder out of your GIT repository? For example if you had a repository for all your Magento modules you’ve written, you might  want to extract only one of them to a new project. Sure  you can use subtree but sometimes you only want to get […]

Checkout subtree

Create and initialize your new repository: $> mkdir <repo> && cd <repo> $> git init $> git remote add –f <name> <url> Enable sparse-checkout: $> git config core.sparsecheckout true Configure sparse-checkout by listing your desired sub-trees in .git/info/sparse-checkout: $> echo some/dir/ >> .git/info/sparse-checkout $> echo another/sub/tree >> .git/info/sparse-checkout Checkout from the remote: $> git pull […]

GIT – Secrets (Cheat Sheet)

Init from the scratch $> mkdir /path/to/your/project $> cd /path/to/your/project $> git init $> git remote add origin https://Bravehartk2@bitbucket.org/Bravehartk2/magento-versions.git $> git fetch First checkout $> git checkout origin/master $> git pull origin master Push to an existing repo $> cd /path/to/my/repo $> git remote add origin https://Bravehartk2@bitbucket.org/Bravehartk2/magento-versions.git $> git push -u origin –all # pushes […]