In a nutshell: Use git rebase --onto target-branch source-commit target-branch means "branch you want to be based on" source-commit means "commit before your first feature commit...
...master and we want it to be based on production. Consider this history: %%{init: { 'gitGraph': {'showCommitLabel': true, 'mainBranchName': 'production'}} }%% gitGraph commit id: "1" commit id: "2" branch master
Using git checkout - you can switch back to the branch you previously worked on. (master) $ git checkout foobar Switched to branch 'foobar' (foobar) $ git checkout - Switched to branch 'master'
...This also works with other commands like git merge: (master) $ git checkout foobar Switched to branch 'foobar' (foobar) $ git merge - Merged branch 'master...
Sometimes you want git to ignore certain files that appear on your machine. You can do this in 3 ways: Per project, in the project's .gitignore file
...in a local exclude file Globally on your machine Downsides of per-project .gitignore entries While it might be tempting to set it per project (other devs might benefit from...
You can convert git commits into patch files. Those can be used to apply to a different repository [1] or by someone else (e.g. sent when sent to them via...
Creating a patch in git Make your changes and commit them. Run git format-patch COMMIT_REFERENCE to convert all commits since the referenced commit (not including it...
First find the reference for the entry you want through looking at the stash: $ git stash list stash@{0}: WIP on feature/foo stash@{1}: WIP on feature/bar stash@{2}: WIP...
Now you can simply use that reference, but curly braces must be escaped: git stash pop stash@\{1\} or quoted: git stash apply "stash@{1}" Quick reminder to not...
Just run git show branch:file. Examples: git show HEAD~:bin/command git show origin/master:../lib/version.rb
You can use git worktree to manage multiple working trees attached to the same repository. But why should I use git worktree? You can use more than one working tree...
...done, you can remove the working tree with git worktree remove . For more details see git-worktree. Warning Worktrees share the git directory (a new worktree points to the .git...
tig is a command line explorer for Git that is just awesome. Install via apt-get or brew. Handy commands t ("tree"): Directory-structure based access. You'll see the...
...with the commit list filtered to those that touched the given file(s). Interactive Git status. Run tig status. Stage/unstage with U, navigate with ENTER/Q. Stash management. Call tig stash...
Browsing the git stash is a bit tricky. Here is how to see the changes without applying them: git command on the console The following will give you the diff...
...of the topmost stash item: git stash show -u But what about other items on the stash? Well, you can list them like this: $ git stash list stash@{0}: WIP...
...first ., \H: full hostname \w: current working directory, \W: same, but only the basename $(__git_ps1 "%s"): your current git branch if you're in a git directory, otherwise nothing...
...by writing export PS1='...' to your .bashrc or .profile. Examples export PS1='\h \w$(__git_ps1 "(%s)") \$ ' => mycomputer ~/apps/chess/tmp(master) $ _ export PS1='\[\e[33m\]\h\[\e[0m\]:\W\[\e[33m...
...package upgrades. Only upgrade individual packages that have a known vulnerability. 2. Block transitive git dependencies Some compromised packages included malicious code by way of a git dependency. That git...
...will not appear in your package.json, only in your giant lockfile. We recommend blocking git sources for transitive dependencies. pnpm Ensure your team uses pnpm 10.26+. In your pnpm-workspace.yaml: blockExoticSubdeps...
local LINEAR_ID=$(echo "$1" | grep "[^/]*$" -o) # Extract linear ID from URLs git log --oneline --grep $LINEAR_ID | grep "^[a-z0-9]*" -o | xargs --no-run-if-empty git...
...can use use the command with up to three arguments (just like a regular git show). Example output for linearcommits ABC-165086636 --stat: commit 048054b1df87576f7c59cc0161cc331c44d2ea6b Author: Foo Bar <foo@bar.com>
Git is our version control system. This lesson covers the everyday moves — committing, branching, merging, working with a remote — and the habits that make your history pleasant to review.
...review: one change per commit, a subject line that says what and why. Your Git configuration follows our config example (e.g. identity, SSH key, pull behaviour). You can browse a...
...dirty WIP commits back into the master as one pretty commit. Squashing commits with git rebase What we are describing here will destroy commit history and can go wrong. For...
...this reason, do the squashing on a separate branch: git checkout -b squashed_feature This way, if you screw up, you can go back to your original branch, make another...
...large refactors. debug_repo_context Inspect which files are packed into the XML pack_git_diff_main Generates a diff between the current work and main. Can be used for...
...Code reviews, test generation etc. pack_git_diff_head Generates a diff of uncommitted changes. Can be used to get assistance on current work. pack_git_show Generates a diff...
Beyond commit, push and pull, Git lets you rewrite history, split and squash commits, and recover from mistakes. This lesson covers the tools we use daily to keep feature branches...
...to what you already know. Just ask. Pick one introduction to rewriting history 📘 Pro Git, 7.6 "Rewriting History" — amend, interactive rebase, reorder, squash, split; the canonical text 📄 Rewriting history — Atlassian...
...people recovering from Subversion. Get an existing from the server for the first time git clone git@example.com:repositoryname See what's changed git status Check in locally
...good description" Push local commits to the server git push Get and merge updates from the server git pull Stage a file for the next local commit
Git log offers useful options for filtering. This card provides a short overview. By message Only commits that include a specific string in their commit message git log --grep="tracker...
By file Only commits that introduced changes to a specific file git log -- foo.rb bar.rb Note In case the file was renamed or moved the --follow option can be...
git shortlog -s -n [commit-range] -n, --numbered Sort output according to the number of commits per author -s, --summary Suppress commit descriptions, only provide commit count [commit-range]
...Manuel Kallenbach 1 Andreas Robecke Alternatives There is a powerful CLI tool called git who...
Today I got a better understanding of how git works, in particular what git checkout and git reset do. Git basics A commit holds a certain state of a directory...
...commits. You are "on a branch" when HEAD is pointing to a branch. checkout git checkout … tells Git to replace the current state of paths with their state in the...
...Configuration Management verstanden. Du verstehst, warum man den Source Code von Configuration Management im Git haben möchte. Du hast den Unterschied zwischen deklarativem und prozeduralem/imperativem Configuration Management verstanden.
Aufgaben Die Inhalte, die du für das Buch erstellst, sollen in einem git repository landen. Scanne deinen Code mit ansible-lint. Du kannst das auch gerne in einen...
In the source repository, create a patch based on the commit by running git format-patch SHA1_OF_COMMIT~..SHA1_OF_COMMIT # Note the ~ git format-patch HEAD~ # Shortcut...
In the target repository, restore the commit from the patch file with git am -3way path/to.patch Should this fail, you can fall back to only applying the...
...expected, got commit 'HEAD~3' git switch --detach HEAD~3 git branch # * (HEAD detached at git-hash) # master Hint You can also use the short version git switch -d.
...With git checkout you can achieve the same. Sources Git - git-switch Documentation
The linked article found a simple way to rewrite legacy git aliases to make them work with differently named default branches Step 1: Decide which is the most common default...
...branch name of your projects, e.g. master. Define it as the global init.defaultBranch git configuration : git config --global init.defaultBranch master Step 2: Overwrite the value in each project directory that...