![]() ![]() It allows you to batch-process a (potentially large) number of commits with a script. $ git rebase -continue Using git filter-branchĪnother way is to use Git's "filter-branch" command. Your job, now, is to correct the author information and then continue to the next concerned commit object until you've edited all the commits you just marked: $ git commit -amend -author="John Doe " -no-edit Once you are satisfied with your changes, run Git will now walk you through each commit, giving you the chance to mold it as you desire: Stopped at 5772b4bf2. Your editor will open, requesting you to mark all the commits you want to change with the "edit" keyword. ![]() The first step is to identify the last "good" commit and provide its hash to the rebase command: $ git rebase -i -p 0ad14fa5 Use it with care (and possibly read up on it)! However, being as powerful as it is, this also means you can very easily shoot yourself in the foot. Interactive Rebase is the Swiss Army Knife of tools in Git: it allows you to do and change almost anything. This effectively replaces the last commit with your "edited" version, correcting the wrong author information. In case you want to change just the very last commit, Git offers a very easy way to do this: git commit -amend -author="John Doe " There are three basic ways to edit your past commits: Using -amend for the Very Last Commit Therefore, think twice before you rewrite your commit history! This is nothing to take lightly: you will create new commit objects in this process, which can become a serious problem for your collaborators - because they might have already based new work on some of the original commits. No matter how exactly we change the information of past commits, there's one thing to always keep in mind: if we do this, we are effectively rewriting commit history. Git is the source code version control system that is rapidly becoming the standard for open source projects.Note Editing Past Commits Rewrites History! It has a powerful distributed model which allows advanced users to do tricky things with branches, and rewriting history. What a pity that it’s so hard to learn, has such an unpleasant command line interface, and treats its users with such utter contempt. The information model is complicated – and you need to know all of it. As a point of reference, consider Subversion: you have files, a working directory, a repository, versions, branches, and tags. That’s pretty much everything you need to know. In fact, branches are tags, and files you already know about, so you really need to learn three new things. Now Git: you have files, a working tree, an index, a local repository, a remote repository, remotes (pointers to remote repositories), commits, treeishes (pointers to commits), branches, a stash… and you need to know all of it. The command line syntax is completely arbitrary and inconsistent. Some “shortcuts” are graced with top level commands: “git pull” is exactly equivalent to “git fetch” followed by “git merge”. ![]() But the shortcut for “git branch” combined with “git checkout”? “git checkout -b”. Specifying filenames completely changes the semantics of some commands (“git commit” ignores local, unstaged changes in foo.txt “git commit foo.txt” doesn’t). The various options of “git reset” do completely different things. The most spectacular example of this is the command “git am”, which as far as I can tell, is something Linus hacked up and forced into the main codebase to solve a problem he was having one night. ![]() It combines email reading with patch applying, and thus uses a different patch syntax (specifically, one with email headers at the top). The man pages are one almighty “fuck you”. Git-push – Update remote refs along with associated objects They describe the commands from the perspective of a computer scientist, not a user. Git-rebase – Forward-port local commits to the updated upstream head Here’s a description for humans: git-push – Upload changes from your local repository into a remote repository #Change commit message smartgit update# #Change commit message smartgit update#. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |