63 Posts Tagged ‘git’ (Page 2)

(All tags.)


Git: Undo a rebase with git reflog

If you make a mistake whilst rebasing, it might seem hard to undo. But with git reflog, you can find the original commit SHA and revert back to it. Let’s see how with an example.

Read more...

My appearance on The Python Show

Earlier this week, I made another podcast appearance on The Python Show, episode 22: Git and Django with Adam Johnson. As fellow authors, Mike and I talked a lot about the writing process, on topics like:

Read more...

My appearance on the PyBites Podcast

Last week, I made another podcast appearance on the PyBites Podcast, episode 139: Maximizing Your Developer Experience (DX) with Adam Johnson. We talked about various topics, including:

Read more...

My appearance on The Real Python Podcast 179

I had the pleasure of returning to The Real Python podcast in last week’s episode 179, Improving Your Git Developer Experience in Python. It was great to catch up with host Christopher Bailey and chat about:

Read more...

Git: Show commits that come after

git log with a commit SHA shows that commit and those before it:

Read more...

Git: Force push safely with --force-with-lease and --force-if-includes

When you push, Git checks that you are only adding commits to the remote branch. If you try to push an out-of-date branch, it will fail:

Read more...

Git: Show a commit message or subject

To show only the subject of the latest commit (the first line of its message), use:

Read more...

Git: Rebase an old branch incrementally

You worked on a sizeable feature branch some time ago but left it to focus on other things. Now you’re ready to pick it up, so you want to rebase it onto your updated main branch. But when you try that, you’re presented with an overwhelming number of merge conflicts.

Read more...

Boost Your DX bundle deal

I released Boost Your Git DX nearly two weeks ago. It’s the second in my “Boost Your DX” series, following last year’s Boost Your Django DX. Both books aim to improve your development experience with their respective tool.

Read more...

“Boost Your Git DX” out now

My new book, Boost Your Git DX is out now, on my birthday 🥳. It’s taken nearly a year of work with four months in early access.

Read more...

Git: Show the initial (root) commit

To show the initial, or root, commit* of your repository, use:

Read more...

My fourth appearance on Django Chat

I’ve once more had the pleasure of joining Carlton and Will on the Django Chat podcast, in Episode #146. We spoke on Tuesday, just hours after Django 5.0 alpha 1 was released, on several topics:

Read more...

Git: Don’t create .gitkeep files, use .gitignore instead

Git only tracks files, not directories. It will only create a directory if it contains a tracked file. But sometimes you need to “track” a directory, to ensure it exists for fresh clones of a repository. For example, you might need an output directory called build.

Read more...

Git: Clear unreachable files from the .git directory

Every object you commit in Git is copied into its object store, within the .git directory. If you undo a commit, the commit object and associated file objects remain in Git’s object store, at least for a while. The normal garbage collection process will clean them out, by default in 30 days.

Read more...

Git: Output the top-level directory of the current repository

To output the root directory of the current repository, use:

Read more...

Git: Output just the current branch name

To print just the name of the current branch, use:

Read more...

“Boost Your Git DX” available in early access

I’m happy to announce that my new book, Boost Your Git DX is available now, in “early access”.

Read more...

Git: Detect an in-progress cherry-pick, merge, rebase, or revert

To detect if a certain operation is in progress in a Git repository, use git rev-parse like so:

Read more...

Git: How to skip hooks

Git hooks are useful for enforcing standards in your repositories. But sometimes, they’re in the way and you gotta skip ’em (locally), such as when writing “WIP” commits, experiments, and even testing hooks. Here are a few techniques for skipping hooks.

Read more...

Git: How to add and remove execute permissions

POSIX permissions include the execute permission, which allows the file to be executed as a program. The permission can be set for each of the three classes: user, group, and others. So, for example, you can have a file that is executable only by its owning user.

Read more...

Git: How to change the case of filenames

Different filesystems have different case sensitivity, for example:

Read more...

Git: How to disable status advice

Many Git commands output “advice”, with hints about which commands you could run next. Most notably, git status gives you advice for what to do about files in each state:

Read more...

Git: An alias to speed up fixing merge conflicts

There you are, minding your own business, rebasing your branch and… surprise! A merge conflict!

Read more...

pre-commit: How to run hooks during a rebase

pre-commit uses Git’s hook system to run tools when you commit. Unfortunately, Git doesn’t run any hooks when making a commit during a rebase. This can lead to you rebasing a branch and not realizing some code needs fixing, at least not until your CI system runs pre-commit (say, with pre-commit.ci).

Read more...

Git: How to set up a global ignore file

Have you ever accidentally committed a bunch of junk created by your OS, like Thumbs.db files from Windows, or .DS_Store files from macOS? Or, have you joined a project, and for one of your first commits, added rules to the .gitignore file for your text editor’s project files? If so, this post is for you! You can avoid such pain or busywork by making a global ignore file.

Read more...