git-rebase

git rebase onto remote updates

孤街浪徒 提交于 2019-11-28 17:13:10
问题 I work with a small team that uses git for source code management. Recently, we have been doing topic branches to keep track of features then merging them into master locally then pushing them to a central git repository on a remote server. This works great when no changes have been made in master: I create my topic branch, commit it, merge it into master, then push. Hooray. However, if someone has pushed to origin before I do, my commits are not fast-forward. Thus a merge commit ensues. This

Git rebase loses history, then why rebase?

偶尔善良 提交于 2019-11-28 17:11:17
I've been looking into rebasing with Git over the past couple days. Most of the arguments for rebasing say that it cleans up the history and makes it more linear. If you do plain merges (for example), you get a history that shows when the history diverged and when it was brought back together. As far as I can tell, rebasing removes all that history. Question is this: why wouldn't you want the repo history to reflect all the ways the code developed, including where and how it diverged? As far as I can tell, rebasing removes all that history. That's not correct. Rebasing, as the name suggests,

git rebase merge conflict

*爱你&永不变心* 提交于 2019-11-28 16:47:57
I forked a github repo and worked on my github repo. I have made pull-requests and it was completed. After that the upstream had some more commits so now I want to rebase, I guess thats what I have to do. But I'm getting these merge conflicts: First, rewinding head to replay your work on top of it... Applying: Issue 135 homepage refresh Using index info to reconstruct a base tree... <stdin>:17: trailing whitespace. %h4 warning: 1 line adds whitespace errors. Falling back to patching base and 3-way merge... Auto-merging app/views/layouts/application.html.haml CONFLICT (content): Merge conflict

How do I reword the very first git commit message?

大城市里の小女人 提交于 2019-11-28 16:27:06
I have a working tree containing 3 commmits: ➜ ~myproject git:(master) git log commit a99cce8240495de29254b5df8745e41815db5a75 Author: My Name <my@mail.com> Date: Thu Aug 16 00:59:05 2012 +0200 .gitignore edits commit 5bccda674c7ca51e849741290530a0d48efd69e8 Author: My Name <my@mail.com> Date: Mon Aug 13 01:36:39 2012 +0200 Create .gitignore file commit 6707a66191c84ec6fbf148f8f1c3e8ac83453ae3 Author: My Name <my@mail.com> Date: Mon Aug 13 01:13:05 2012 +0200 Initial commit (with a misleading message) Now I wish to reword the commit message of my first commit (6707a66) ➜ ~myproject git:(master

How do I squash two non-consecutive commits?

寵の児 提交于 2019-11-28 15:26:18
I'm a bit new to the whole rebasing feature within git. Let's say that I made the following commits: A -> B -> C -> D Afterwards, I realize that D contains a fix which depends on some new code added in A , and that these commits belong together. How do I squash A & D together and leave B & C alone? You can run git rebase --interactive and reorder D before B and squash D into A. Git will open an editor, and you see a file like this: pick aaaaaaa Commit A pick bbbbbbb Commit B pick ccccccc Commit C pick ddddddd Commit D # Rebase aaaaaaa..ddddddd onto 1234567 (4 command(s)) # # Commands: # p,

Git: How to rebase to a specific commit?

风流意气都作罢 提交于 2019-11-28 15:21:50
I'd like to rebase to a specific commit, not to a HEAD of the other branch: A --- B --- C master \ \-- D topic to A --- B --- C master \ \-- D topic instead of A --- B --- C master \ \-- D topic How can I achieve that? Adam Dymitruk You can avoid using the --onto parameter by making a temp branch on the commit you like and then use rebase in it's simple form: git branch temp master^ git checkout topic git rebase temp git branch -d temp r0hitsharma You can even take a direct approach: git checkout topic git rebase <commitB> Adam Dymitruk Use the "onto" option: git rebase --onto master^ D^ D The

Git: How to reuse/retain commit messages after 'git reset'?

白昼怎懂夜的黑 提交于 2019-11-28 15:13:56
问题 As Git user I regular come across the situation, that I need to rework one or more commits in a way which do not fit into --amend or rebase -i with fixup commits. Typically I would do something like git reset HEAD~1 # hack, fix, hack git commit -a # argh .. do I need to retype my message? I take sensible composed commit messages quite serious. They typically contain larger text with references & justifications for the change. Until now, I'm quite annoyed on the lengthy process to recover my

Change old commit message on Git

◇◆丶佛笑我妖孽 提交于 2019-11-28 15:07:55
I was trying to edit an old commit message as explained here . The thing is that now, when I try to run rebase -i HEAD~5 it says interactive rebase already started . So then I try: git rebase --continue but got this error: error: Ref refs/heads/master is at 7c1645b447a8ea86ee143dd08400710c419b945b but expected c7577b53d05c91026b9906b6d29c1cf44117d6ba fatal: Cannot lock the ref 'refs/heads/master'. Any ideas? VonC It says: When you save and exit the editor, it will rewind you back to that last commit in that list and drop you on the command line with the following message: $ git rebase -i HEAD

How to get “their” changes in the middle of conflicting Git rebase?

独自空忆成欢 提交于 2019-11-28 13:08:55
问题 I have conflicting branches, branch2 branched from branch1. Let's say when rebasing branch2 on current branch1 , while resolving conflicts, I decide to take some (not all) of "their" (i.e. branch1 ) files as-is. How do I do that? I tried: git checkout branch1:foo/bar.java fatal: reference is not a tree: TS-modules-tmp:foo/bar.java git checkout refs/heads/branch1:foo/bar.java fatal: reference is not a tree: refs/heads/TS-modules-tmp:foo/bar.java 回答1: You want to use: git checkout --ours foo

How do I git rebase the first commit?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 05:44:33
I used git init to create a fresh repo, then made three commits. Now I want to rebase to go back and amend my first commit, but if I do git rebase -i HEAD~3 it complains! If I try the same with HEAD~2 then it kinda works but only lets me rearrange the last two commits. How do I refer to the 'commit before there were any commits' or go back and insert an empty commit? torek The easy way, with a recent-enough git (this has been out for a long time now so you should have this): git rebase -i --root The other easy way, as twalberg noted in a comment , is to use git checkout --orphan to set up to