Giter VIP home page Giter VIP logo

git-amend-old's Introduction

git-amend-old (deprecated)

⚠️ For a simpler solution, check out this git fixup alias: https://www.colinodell.com/blog/201803/four-useful-git-aliases ⚠️


Bash script to amend older commits with staged changes.

Think of it like git commit --amend, but for older commits.

Special thanks to @VonC for this StackOverflow answer which provided the basis for this script.

Note: Using git commit --fixup=<hash> && git rebase -i --autosquash <hash>^ is a more-modern (and probably more-reliable) way of doing this. It's not as automated but it does offer more flexibility. Check it out :)

Usage:

Once the script is added to your path, you can run it like so:

git amend-old <target-rev>

Where <target-rev> is the commit hash you'd like to merge your staged changes into.

Example:

# Edit some existing file
vi existing-file.ext
# Stage the changes you just made
git add existing-file.ext
# Combine the staged changes with commit abcd123
git amend-old abcd123

Caution:

I have not thoroughly tested this script, but so far it seems to work okay for my personal usage. It's possible that bugs exist which may cause undesired changes to your Git history. By using this script you agree to the included LICENSE. If you do encounter a bug, I'd appreciate if you'd create an issue or patch for it.

git-amend-old's People

Contributors

colinodell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

git-amend-old's Issues

Blog link

Hi, trying to use git fixup, but the blog doesn't have the code for the alias. (Using chrome on mac)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.