Skip to main content

30 posts tagged with "git"

git tag description

View All Tags

Ultimate pre-commit Configuration for Python: Complete setup & Advanced practices

路 8 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Maintaining code consistency and preventing quality regressions across a development team can be challenging. Manually checking styles or reminding teammates about formatting imports leads to cognitive overhead and code reviews cluttered with style arguments.

By implementing pre-commit, you can automate code formatting, import sorting, stylistic linting, and static type checking directly into your Git commit lifecycle. This guide outlines the ultimate pre-commit configuration for Python, demonstrates how to centralize settings, and provides advanced optimization tips.

Git error: 'main/' does not have a commit checked out`

路 4 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

The error error: 'main/' does not have a commit checked out occurs when Git tries to add files to a submodule that is in a detached HEAD state or has no checked-out commit. This happens because the main repository expects the submodule to point to a specific commit, but it's in an invalid state.

To fix this, you need to navigate into the submodule's directory and check out a commit, usually by switching to the main branch or a specific branch.

Save username and password in Git

路 4 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

To save your username and password in Git, you can configure a credential helper. A credential helper is a Git component that securely stores your authentication information in memory or on disk, so you don't have to enter it every time you interact with a remote repository.

Fix 'Write access to repository not granted' in Git/GitHub

路 7 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

The fatal: unable to access error with the message "Write access to repository not granted" typically means you don't have the necessary permissions to push changes to the GitHub repository. It's a clear signal from the server that your authentication credentials, while valid, don't grant you the required write access.

Here's how to diagnose and solve this issue:

Git ours vs. git theirs

路 5 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

In Git, the terms ours and theirs are used to refer to the two conflicting versions of a file during a merge or rebase. Understanding which version is which is critical for resolving conflicts correctly [1].

Rebasing a local branch onto a remote branch

路 8 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Rebasing a local branch onto a remote branch is a common workflow for keeping your feature branch up-to-date with the main development branch (like main or master) and maintaining a clean, linear commit history.

The process involves a few key steps: fetching the latest changes, checking out your local branch, performing the rebase, handling conflicts, and then force-pushing your changes if the branch was already shared.

Git Branch Operations: Checkout Files, Replace Branches, Rebase Syntax, and Deletion

路 9 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Sometimes, you may want to retrieve a specific file from another branch in a Git repository without switching branches completely. This is particularly useful when you want to grab a specific version of a file for debugging, rollback, or review.

In this guide, we'll walk through how to checkout a single file from another branch using Git. We'll cover multiple scenarios with examples and best practices.

How to Fix Git Pull Errors: Divergent Branches, Fast-Forward, and Unrelated Histories

路 7 min read
Serhii Hrekov
Senior Software Engineer & System Architect specializing in Python, Web Systems, Cloud Infrastructure & Automation

Running git pull is usually straightforward, but when your local repository's history doesn't align with the remote server, Git stops the operation to prevent you from losing your work. This results in errors like:

  • fatal: Not possible to fast-forward, aborting.
  • Hint: You have divergent branches and need to specify how to reconcile them.
  • fatal: refusing to merge unrelated histories