git branch -M main

Update: The -m and -M options to git branch were upgrade in Git 2.30 to allow renaming the not-yet-existing current branch name in special situations, such as when you’re in a new, empty repository. You mention in your own answer that git branch -m main (or the same with -M) only works once you have … Read more

Add patch in git, all hunks matching regex in file

The Solution The following one-liner worked for me where <regex> is a POSIX Extended Regular Expression. This requires grepdiff but it was already included in my Ubuntu distribution. git diff -U1 -G<regex> –pickaxe-regex \ | grepdiff -E <regex> –output-matching=hunk \ | git apply –cached How it works The first line shows all differences whose patch … Read more

How to remove previously added git subtree and its history

You need to use a filter-branch along with the –prune-empty option to remove any commits that no longer introduce new changes. git filter-branch –index-filter ‘git rm –cached –ignore-unmatch -rf dir1 dir2 dirN file1 file2 fileN’ –prune-empty -f HEAD After that, if you want to recover disk space you will need to delete all the original … Read more

Finding out the version of git on remote server

Modern git servers (beginning in git 1.7.12.1) will return their version information in the capabilities negotiation in the protocol. While it’s accurate that there’s no git command that you can run locally, you can simply query the git server for the information and a recent version will provide the version number. You can find this … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)