makandra dev

Git has a built-in repository viewer for your web browser. a bit similar (but less awesome) than github. If you have apache installed, simply go to your repository, and...

git instaweb --httpd apache2 otherwise, simply install lighttpd and just run git instaweb This should open a brower automatically pointing to your repository. If not, try to connect to...

When using git diff, you might encounter weird characters where umlauts (or any other UTF-8) characters should be. It looks like this: R ckg ngig # should be "Rückgängig"

...not Git is to blame but the less command that Git uses to page your diff output. You need to tell less to use UTF-8 (otherwise it tries to...

makandracards.com

Resolve @{-1} to actual branch name. (Happens when merging "-".)

...the branch name from Linear (keyboard shortcut Ctrl-Shift-.). Branch off the main with: git checkout main git checkout -b $PASTE_BRANCH_NAME_HERE If your feature depends on another...

...merge request checklist: Within your feature branch, merge the current main and push using: git pull origin main git push -u origin feature-branch-name You're encouraged to use...

Say you want to move a git repository from one remote (perhaps Github) to another (perhaps Gitlab). If you have the repo checked out, you still should make sure to...

...current repo, and not the source repo, potentially missing commits. You can use this: git remote rename origin old-origin git remote add origin git fetch old-origin --prune

docs.gitlab.com

Short hint: If you want to push to a git repository that has CI configured, you can skip the CI pipeline for commits that don't need a CI run...

...git push -o ci.skip This has a few cavates: Skips only branch pipelines and not merge request pipelines. This does not skip pipelines for CI/CD integrations, such as Jenkins...

...However, this tool has some bugs. To only import the trunk (with complete history): git svn clone http://host/svn/... Create a .gitignore after the conversion. Turn the folder into a...

...git repository as described here...

When you want to do a git diff but do not care about the full diff and just want to know which files changed, use the --name-only switch:

...app/models/user.rb features/sign_in.feature To include some brief information about changed lines, use the --stat switch: $ git diff --stat app/controllers/sessions_controller.rb | 8 +- app/models/user.rb | 30 ++++ features/sign_in.feature | 136 +++++++++++++++++ The output of --stat is nicely colored...

stackoverflow.com

If your git index for some reason becomes invalid, no need to worry. Your index is corrupt when you see this error running usual git commands like git pull, git...

...there. Fix it by first removing the index file, then resetting the branch: rm .git/index git reset You should be all good now. To be safe, make a backup of...

Put this in your ~/.claude/settings.json: { "sandbox": { "enabled": true, "autoAllowBashIfSandboxed": true, "allowUnsandboxedCommands": false, "excludedCommands": [ "git checkout *", "git checkout", "git cherry-pick *", "git merge *", "git merge", "git pull *", "git pull",

...rebase *", "git rebase", "git reset *", "git restore *", "git revert *", "git stash *", "git stash", "git subtree *", "git switch *" ], "network": { "allowAllUnixSockets": true }, "filesystem": { "denyRead": [ "~/" ], "allowRead": [ ".", "~/.rbenv", "~/.nvm", "~/.claude", "~/.cache/node/corepack", "~/.cache/ms-playwright", "~/.config/glab-cli", "~/.config/mise...

kernel.org

If you say git stash, your stashed changes will be identified with an automatically generated message: $ git stash Saved working directory and index state WIP on master: 77af0df Merge branch...

...if you stash often. Of course, there is a way to do it with git: $ git stash save doing crazy things Saved working directory and index state On master: doing...

When you have files in your .gitignore they won't be considered for changes, but still you might want to get rid of them, e.g. because they clutter your file...

While a regular git clean will ignore them as well, passing the -x switch changes that: git clean -x If you want to see what would happen first, make...

...another branch or past commit without doing a complete checkout, you can either use git show branch:file git show commit:file to display, or check out the file into...

...your working directory with git checkout branch -- file git checkout commit -- file

richfrog.curzons.net

...up a cmd and put the full path to PuTTY's plink.exe into the GIT_SSH environment variable, e.g.: set GIT_SSH=D:\PuTTY\plink.exe You can then use Git...

...like you would on any sane operating system. Just go ahead and git clone, git pull, etc. Also, you may want to add the environment variable under the Windows system...

...find a version containing the regular expression foo in the history of any branch: git grep foo $(git rev-list --all) You may also limit the search to a file...

...extension, e.g. Ruby files (.rb) like this: git grep foo $(git rev-list --all) -- *.rb

In order to clone a git repository including all branches and tags you need to use two parameters when cloning the old and pushing to the new repository respectively:

...clone --bare http://example.com/old-repo.git cd old-repo git push --mirror http://example.com/new-repo.git Of course, the URLs to your repository might look different depending on the protocol used, username...

git apply allows you to apply a diff onto your HEAD. Most often you can achieve the same result with a rebase & merge. Example: master commit1 - commit3 feature-branch \ commit2...

git checkout feature-branch git reset --hard commit3 git diff ..commit4 | git apply master commit1 - commit3 feature-branch \ Unstaged commit 2 & 4 You can also create a patch and...

Merging .po-files with Git is painful. There have been attempts of making Git more clever when trying to merge .po-files. I believe however that this is not enough...

...invalid merges I additionally disable merging for po files altogether, by adding the following .gitattributes file to the root of the repository: *.po merge=binary *.pot merge=binary

If you modified git's history and the change was already pushed, you will usually get a ! [rejected] my-branch -> my-branch (non-fast-forward) error, when trying to push...

...You can force the push, with git push --force origin my-branch Careful: You might lose history. Unless your git is configured to push only the current branch, you must...

Instead of showing you two lines for each change, Git allows you to highlight changes in a line explicitly: git diff --word-diff some_file Hello [-world-]{+universe+}!

...unhandy to use.\ You maybe just want the diff put into your terminal: PAGER='' git diff --word-diff some_file

Every time you amend, rebase or reset, git commits get "overwritten". However, git still allows you to checkout those commits using their SHA1, given you can find it.

git reflog # or git reflog show [BRANCH] This will show a list of all commits the branch has recently pointed to. Git might garbage collect those...

You might get the above error message when cloning certain git repositories (for example the rails repository). It indicates that there is a malformed timestamp in some commit, and your...

...git installation is configured to validate it. As a workaround, you can disable the validation using git config --global fetch.fsckobjects false This settings seems to be the default for most...

If git gives you an error message such as "fatal: bad config file line 123 in .git/config" after you tried to checkout a branch with a very long branch name...

...you very likely come across a bug in git version < 1.8. You should ask someone with a newer git version (someone pushed the branch right?) to rename the branch to...

To display a list of your current Git remotes and...

...their endpoints, you can say git remote -v The output looks like this: brady8 https://github.com/brady8/aegis.git (fetch) brady8 https://github.com/brady8/aegis.git (push) origin git@github.com:makandra/aegis.git (fetch) origin git@github.com:makandra/aegis.git...