Skip to content

πŸ•’ A tool for customizing your git commit timestamps

License

Notifications You must be signed in to change notification settings

richen604/git-timeshift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

git-timeshift

⚠️ ACTIVE DEVELOPMENT WARNING
This project is in active development and may have breaking changes.
for now, there is no built-in way to backup/restore changes.
ALWAYS create a manual backup of your repository before using this tool.

πŸ•’ A tool for customizing your git commit timestamps

preview

$ gt list
Found 3 commits to be shifted across 2 days:

πŸ“… 2024-03-20:
⚑ 14:30:00 feat: add new feature
  10:45:00 fix: update tests

πŸ“… 2024-03-19:
⚑ 13:15:00 docs: update readme

$ gt set
✨ Done! Your commits now have updated timestamps

what is this?

git-timeshift is a tool that helps you customize your commit timestamps. Perfect for adjusting your github contribution patterns or organizing your commit history in a way that better reflects your coding schedule.

features

  • flexible timestamp adjustment
  • configurable time windows
  • random time offsets for natural-looking commit patterns
  • preserves commit order and relative timing
  • simple command-line interface

requirements

  • python 3.6+
  • git-filter-repo

installation

manual installation

git clone https://github.com/richen604/git-timeshift.git
cd git-timeshift
pip install .

nix installation

you can install git-timeshift using nix in several ways:

# install directly (nix 2.4+)
nix profile install github:richen604/git-timeshift

# temporary shell with git-timeshift
nix shell github:richen604/git-timeshift

if you're using NixOS, you can add it to your system configuration:

{
  inputs.git-timeshift.url = "github:richen604/git-timeshift";
  
  outputs = { self, nixpkgs, git-timeshift }: {
    nixosConfigurations.yourHost = {
      environment.systemPackages = [
        git-timeshift.packages.${system}.default
      ];
    };
  };
}

usage

you can use either git-timeshift or the shorter alias gt:

  1. initialize configuration:
$ gt init
πŸ•’ Setting up git-timeshift configuration...
Let's customize your commit timestamps

Preferred time window start? (HH:MM) [09:00]: 
Preferred time window end? (HH:MM) [17:00]: 

✨ Configuration saved to ~/.config/git-timeshift/config.json
  1. list your commits:
$ gt list
Found 2 commits to be shifted:
πŸ“… 2024-03-20:
⚑ 14:30:00 feat: add new feature
  10:45:00 fix: update tests
  1. shift those timestamps:
$ gt set
Analyzing commits...
Ready to rewrite history? [y/N]: y

✨ Done! Your commits now have updated timestamps
  1. modify a specific commit:
$ gt pick
1. 2024-03-20 14:30 - feat: add new feature
2. 2024-03-20 10:45 - fix: update tests

Enter commit number: 1
Enter new date (YYYY-MM-DD HH:MM): 2024-03-20 20:30

✨ Done! Your commit has been shifted

configuration

the tool will create a config file at ~/.config/git-timeshift/config.json with your preferences:

  • time windows for commits
  • active days
  • shift strategy (earlier/later)

fallback: manual rebase method

if you encounter any issues with the automated process, you can manually adjust commit timestamps using interactive rebase:

  1. start an interactive rebase:
git rebase -i HEAD~n  # replace n with number of commits to modify
  1. mark commits you want to edit with edit instead of pick:
edit abc1234 feat: add new feature
pick def5678 fix: update tests
  1. for each commit, amend with a new date:
git commit --amend --no-edit --date="2024-03-20 20:30:00" # or --date="$(date) for current time
git rebase --continue

todo

bugs

  • times listed in preview are not the times that are set

new things

  • use worktrees to allow reverting changes
  • handle next day rollover
  • add timezone support
  • custom random time offsets
  • colored output
  • command completion (tab completion for shells)
  • interactive mode?

boring stuff

  • unit tests
  • integration tests
  • type hints
  • improve error handling
  • debian packaging
  • arch packaging
  • nixos packaging
  • homebrew packaging
  • pypi packaging
  • set up github actions - semvar etc
  • improve pypi metadata

license

mit license - see license file for details

acknowledgments

special thanks to:

About

πŸ•’ A tool for customizing your git commit timestamps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published