makandra dev

...me or my peer reviewer is able to parse 500k+ lines of code. Fortunately, git has some handy diff options ready: option comment --color-moved=dimmed_zebra Highlight only changes...

To tackle the rename limit mentioned above, update the local or global git configuration. git config diff.renameLimit 9999 Furthermore, I encourage you to further split the diff into...

If you are using git submodules in Gitlab CI, you might run into a "The project you were looking for could not be found or you don't have permission...

Gitlab added a feature that new projects are no longer allowed to be cloned inside CI runs of other repositories by default. To fix this

Just like Ruby Gems tag their version releases to the corresponding Git commit, it can be helpful to track production deploys within the commit history. This task does the tagging...

... desc 'Tag the deployed revision' task :tag_revision do date = Date.today.to_s puts `git tag deploy-#{date} #{fetch :current_revision}` puts `git push --tags origin` end end # config/deploy/production.rb

...rebase one clean commit interactively onto main without going through each commit individually using git rebase -i main. What it does: Opens an interactive rebase UI to choose squash/edit/fixup for...

...you squash, reorder, edit, or drop commits. Info This is not the same as git rebase -i main, which would rebase your branch onto main, changing its base. Example:

Sometimes you might need to nest a git-project inside another git-project. The right strategy is to use submodules in this case. How git submodules work Each submodule is...

...a own git repository Once you commit changes in a submodule, the parent repository can link the new sha as its reference You need to take care manually that your...

Geordi provides a pretty neat way to generate beautiful commit messages according to your stories in Linear: geordi commit

...Aug 11 09:42:34 2023 +0200 Add Apples as a new fruit diff --git a/app/models/apple.rb b/app/models/apple.rb new file mode 100644 index 0000000..a51cbad --- /dev/null +++ b/app/models/apple.rb...

+ + attr_accessor :type + + def to_s + I18n.t(type, scope: 'fruits.apples') + end +end diff --git a/spec/models/apple_spec.rb b/spec/models/apple_spec.rb new file mode 100644 index 0000000..6b9a90e --- /dev/null +++ b/spec/models/apple_spec.rb...

Inspired by recent "git shortcut" cards I figured it would be nice to have one of these for rebasing a few commits onto another branch. The usual notation is prone...

...You may add this rebase-onto function to your ~/.bashrc: function rebase-onto { commit=$(git log --oneline | fzf --prompt 'Select the first commit you want to move' | awk '{print...

worktrunk.dev

Worktrunk is a CLI tool that manages git worktrees for you. This can be useful when you want to work on multiple instances of the same repository with separate AI...

makandracards.com

In order to have more human readable git branches, do git pull --rebase To always pull like this, write these lines to your ~/.gitconfig: [pull] rebase = true

git config --global pull.rebase true Note that this will break if you pull from other upstream branches like git pull origin other-branch If you keep rebasing by default...

Git allows you to set push options when pushing a branch to the remote. You can use this to build an alias that automatically pushes a branch and creates a...

...alias] section: mr = push origin HEAD -o merge_request.create -o merge_request.draft Now you can do git mr and a draft merge request will be created. Target branch is your project's...

github.com

The linked GitHub repository is a bit like our "dev" cards deck, but groomed from a single person (Josh Branchaud). It includes an extensive list of over 900 TILs on...

...many topics that might be interesting for most of us. (e.g. Ruby, Rails, Git, Unix..) Ruby Here is an excerpt of all the Ruby TILs that were new to me...

Git commands like diff use the less binary for their output representation. I often find myself searching for strings like todo, then switching to the case-insensitive mode (-i) and...

...re-doing my search. Today I figured out that you can configure git to show case insensitive diffs every time: git config --global core.pager 'less -i...

stackoverflow.com

...changing this, so think before you do it. If you do, you can tell git to stash automatically before pulling: git config --global rebase.autoStash true Now on pull, git will...

...Note that applying your changes may lead to unresolvable conflicts! Further see a common git config with this configuration enabled...

makandra dev

Saying git diff only shows unstaged changes relative to the index (or HEAD if the index is empty, alternatively any hash or branch you supplied) but leaves out files you...

...already staged for the next commit. To diff your added changes with HEAD, say: git diff --cached Effectively, this gives you the changes you will commit when you run git...

Why Rails has multiple schema formats When you run migrations, Rails will write your current database schema into db/schema.rb. This...

Sure, you have a project directory – but all of it is tracked by Git. A project's tmp/ directory is usually not tracked, but by definition it is not...

...a related-files/ directory within your project(s). To keep this directory untracked by Git in all your projects, add it to your global .gitignore file with echo related-files...

If you want to see the git history of a project file, that doesn't exist anymore, the normal git log won't work. You have to add certain flags...

...to make it work: git log --all --full-history...

dev.to

...you may add an alias such as this to your ~/.bashrc: alias recent-branch="git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ | fzf | sed 's/\* //g' | xargs -I...

...git checkout {}" alias rb=recent-branch Now whenever you want to switch back and forth between your most recent branches, type recent-branch, select one and press enter...

...and fix trailing whitespace in your commits. Bypass # it with the --no-verify option to git-commit. # detect platform platform="win" uname_result=`uname` if [[ "$uname_result" == "Linux" ]]; then

...Removed trailing whitespace in \033[31m$file\033[0m:$line_number" done echo # credits: # https://github.com/philz/snippets/blob/master/pre-commit-remove-trailing-whitespace.sh # https://github.com/imoldman/config/blob/master/pre-commit.git.sh # If there still are whitespace errors, print the offending file...

Git has two kind of tags: annotated lightweight Annotated tags are stored as full objects in the Git database. They’re checksummed; contain the tagger name, email, and date; have...

...verified with GNU Privacy Guard (GPG) The following command will create a (lightweight) tag: git tag v0.1 An annotated tag is created by: git tag -a v0.1 -m "a special...

makandra dev

git commit -m "Rename foo to bar" git log bar commit adc8e6a05b65355359c4e4618d6af0ed8f8b7f14 (HEAD -> git-follow) Author: Michael Leimstaedtner <makmic@makandra.de> Date: Wed May...

...Rename foo to bar git log --follow bar commit adc8e6a05b65355359c4e4618d6af0ed8f8b7f14 (HEAD -> git-follow) Author: Michael Leimstaedtner <makmic@makandra.de> Date: Wed May 12 08:49:37 2021 +0200 Rename foo to bar...

...changes matching a given regular expression for a single commit. Example Consider the following git diff output. diff --git a/file1.rb b/file1.rb index 806ca88..36d536b 100644 --- a/file1.rb +++ b/file1.rb...

-# It will be removed. class File1 - def foo + def bar # ... end end diff --git a/file2.rb b/file2.rb index 550e1c6..600f4e3 100644 --- a/file2.rb +++ b/file2.rb @@ -1,6 +1,5 @@

When doing a git blame, git will blame the person who added or removed white space in a line (e.g. by indenting), not the person who originally wrote the code...

...Say git blame -w to ignore such white-space changes. You want this. \ Note that you can also use it when diffing: git diff -w. Example Consider this method, created...