{"thread":{"id":"30797","subject":"Git rebase basics","startedAt":"2012-06-13T20:59:12Z","lastAt":"2012-06-14T17:21:44Z","messageCount":8,"participants":["lancelyons","Michael Witten","Hilco Wijbenga"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"193591","messageId":"1339621152946-7561468.post@n2.nabble.com","threadId":"30797","inReplyTo":null,"subject":"Git rebase basics","fromName":"lancelyons","fromEmail":"llyons2@cox.net","sentAt":"2012-06-13T20:59:12Z","receivedAt":"2012-06-13T20:59:12Z","isPatch":false,"sender":{"key":"llyons2@cox.net","avatar":null},"body":"I am trying to learn git on my own.  I have setup our own server for git\nusing https and have cloned this repository and have done pushes and pulls\nwith no problem.\n\nI am trying to learn more about rebase so i have cloned the central repo (I\ncall this origin)\nand made changes to the cloned copy and pushed two commits to origin.\n\nso I have the following.\n\norigin -->  C1 --> C2\n\nin my cloned copy which I consider a branch\n\nI have made two more commits  C3 and C4\n\nclone --> C3 -->  C4\n\nI am able to easily pull from origin to get my clone to look like  clone -->\nC3 --> C4 --> C1 --> C2\n\nI was wanting to rebase the clone branch so that it shows    clone -> C1 -->\nC2 --> C3 --> C4\n\nI though the command to do this was   git rebase origin master but that\ndoesnt work.\n\n\n\nAny ideas on what I am doing wrong?\n\nthanks\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/Git-rebase-basics-tp7561468.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"193609","messageId":"CAMOZ1BudfqB2wf2emGL_J5kvEkF=dz0y4h6LCA7W0RCWCCyg2A@mail.gmail.com","threadId":"30797","inReplyTo":"1339621152946-7561468.post@n2.nabble.com","subject":"Re: Git rebase basics","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2012-06-14T00:07:51Z","receivedAt":"2012-06-14T00:07:51Z","isPatch":false,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Wed, Jun 13, 2012 at 8:59 PM, lancelyons <llyons2@cox.net> wrote:\n\n> I am trying to learn git on my own.  I have setup our own server for git\n> using https and have cloned this repository and have done pushes and pulls\n> with no problem.\n>\n> I am trying to learn more about rebase so i have cloned the central repo (I\n> call this origin)\n> and made changes to the cloned copy and pushed two commits to origin.\n>\n> so I have the following.\n>\n> origin -->  C1 --> C2\n>\n> in my cloned copy which I consider a branch\n>\n> I have made two more commits  C3 and C4\n>\n> clone --> C3 -->  C4\n>\n> I am able to easily pull from origin to get my clone to look like  clone -->\n> C3 --> C4 --> C1 --> C2\n>\n> I was wanting to rebase the clone branch so that it shows    clone -> C1 -->\n> C2 --> C3 --> C4\n>\n> I though the command to do this was   git rebase origin master but that\n> doesnt work.\n>\n>\n>\n> Any ideas on what I am doing wrong?\n>\n> thanks\n\nIt's amazing to me that people regularly describe their problems not\nwith the precision of a universally reproducible sequence of command\nlines, but rather with some imprecise, personal language concocted in\nthe very midst of using it.\n\nSir. You are trying to figure out how to use git commands. Why not\nillustrate your difficulties by writing out a sequence of... well...\nGIT COMMANDS, which everyone on this list may easily try and, most\nimportantly, understand with precision?\n\n  $ git init origin\n  $ cd origin\n  ...\n\nList your expected results and your actual results.\n\nIn fact, by distilling your issue into a workable example, you will\nprobably figure the whole thing out anyway.\n\nNow, don't worry about writing another email. Somebody who has more\ntime to burn will answer your original email cordially enough (and\nchastise me in the process by remarking how your scenario is\nperfectly easy to understand as is).\n\nSINCERELY,\nMichael Witten\n"},{"id":"193612","messageId":"1339642794317-7561489.post@n2.nabble.com","threadId":"30797","inReplyTo":"1339621152946-7561468.post@n2.nabble.com","subject":"Re: Git rebase basics","fromName":"lancelyons","fromEmail":"llyons2@cox.net","sentAt":"2012-06-14T02:59:54Z","receivedAt":"2012-06-14T02:59:54Z","isPatch":false,"sender":{"key":"llyons2@cox.net","avatar":null},"body":"Sorry about that.. I thought I was being pretty descriptive but maybe I\nmissed something.\n\nAfter we setup Git (msysgit) and set it up using Apache with active\ndirectory authentication, I added a repository using git init --bare then I\ncopied my files I wanted to add to the repository and did a git add . and\ngit commit -a\n\nSo that all worked.   We have done several clones using git clone with this\nremote repo.  We have also done  git push and git pull to verify everything\nis working ok.   Everything was working fine.\n\nSo back to my original train of though.\n\nI am trying to learn more about rebase so i have cloned the central repo two\ntimes  (I call the central repo the origin) doing the following (to help you\nunderstand)\n\ngit clone https://servername:port/repopath c:\\clonedrepo1\n\ngit clone https://servername:port/repopath c:\\clonedrepo2\n\nand then made changes to this cloned copy (clonedrepo1) and pushed two\ncommits back to origin.\n(git commit -a  two times)\n\nso now I have the following in the remote repo (origin)   \n\norigin -->  C1 --> C2\n\n(Note to help you understand  C1 = commit 1 and c2 = commit 2, etc)\n\nIn the other cloned copy (clonedrepo2), which I consider a branch, I have\nmade two more commits  C3 and C4\n\nclonedrepo2 --> C3 -->  C4\n\nI am able to easily pull from origin to get my clonedrepo2 to look like \nclonerepo2 --> C3 --> C4 --> C1 --> C2 using git pull origin  or git pull\nhttps://servername:port/repopath\n\nhowever I was wanting to rebase the clonedrepo2 branch so that it shows   \nclonerepo2 -> C1 --> C2 --> C3 --> C4\n\nIn other words I am wanting to rebase clonedrepo2 to the master of the\norigin.\n\n\nI thought the command to do this was   git rebase origin master but that\ndoesnt work and I get\n\nC:\\clonedrepo2>git rebase origin master\nSwitched to branch 'master'\nYour branch is ahead of 'origin/master' by 2 commits.\nCurrent branch master is up to date.\n\nI know my my branch is ahead by c3 and c4 but it does not have C1 and C2\n\nThoughts.\n\n--\nView this message in context: http://git.661346.n2.nabble.com/Git-rebase-basics-tp7561468p7561489.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"193614","messageId":"CAE1pOi3uXHcXm=fpH-e6pHyBTAACS7=KkdR9jQEuEjzoXy1w=A@mail.gmail.com","threadId":"30797","inReplyTo":"1339642794317-7561489.post@n2.nabble.com","subject":"Re: Git rebase basics","fromName":"Hilco Wijbenga","fromEmail":"hilco.wijbenga@gmail.com","sentAt":"2012-06-14T04:39:03Z","receivedAt":"2012-06-14T04:39:03Z","isPatch":false,"sender":{"key":"hilco.wijbenga@gmail.com","avatar":null},"body":"On 13 June 2012 19:59, lancelyons <llyons2@cox.net> wrote:\n> Sorry about that.. I thought I was being pretty descriptive but maybe I\n> missed something.\n\nPerhaps \"descriptive\" but certainly not \"precise\".\n\n> After we setup Git (msysgit) and set it up using Apache with active\n> directory authentication, I added a repository using git init --bare then I\n> copied my files I wanted to add to the repository and did a git add . and\n> git commit -a\n>\n> So that all worked.   We have done several clones using git clone with this\n> remote repo.  We have also done  git push and git pull to verify everything\n> is working ok.   Everything was working fine.\n>\n> So back to my original train of though.\n>\n> I am trying to learn more about rebase so i have cloned the central repo two\n> times  (I call the central repo the origin) doing the following (to help you\n> understand)\n>\n> git clone https://servername:port/repopath c:\\clonedrepo1\n>\n> git clone https://servername:port/repopath c:\\clonedrepo2\n>\n> and then made changes to this cloned copy (clonedrepo1) and pushed two\n> commits back to origin.\n> (git commit -a  two times)\n>\n> so now I have the following in the remote repo (origin)\n>\n> origin -->  C1 --> C2\n>\n> (Note to help you understand  C1 = commit 1 and c2 = commit 2, etc)\n>\n> In the other cloned copy (clonedrepo2), which I consider a branch, I have\n> made two more commits  C3 and C4\n>\n> clonedrepo2 --> C3 -->  C4\n>\n> I am able to easily pull from origin to get my clonedrepo2 to look like\n> clonerepo2 --> C3 --> C4 --> C1 --> C2 using git pull origin  or git pull\n> https://servername:port/repopath\n>\n> however I was wanting to rebase the clonedrepo2 branch so that it shows\n> clonerepo2 -> C1 --> C2 --> C3 --> C4\n>\n> In other words I am wanting to rebase clonedrepo2 to the master of the\n> origin.\n\nWhat you want is \"git pull --rebase origin master\". See \"git help\npull\". Also check \"git help fetch\" if you really want to keep doing\nthis.\n\nBut it sounds like you should simply be using a real branch. You can\ndo \"git pull\" on your master branch and then run \"git rebase master\"\non your own branch. Did you really read up on Git? It has truly\nexcellent documentation. See for example http://git-scm.com/book (but\nthis is just one of many).\n\n> I thought the command to do this was   git rebase origin master but that\n> doesnt work and I get\n>\n> C:\\clonedrepo2>git rebase origin master\n> Switched to branch 'master'\n> Your branch is ahead of 'origin/master' by 2 commits.\n> Current branch master is up to date.\n>\n> I know my my branch is ahead by c3 and c4 but it does not have C1 and C2\n>\n> Thoughts.\n>\n> --\n> View this message in context: http://git.661346.n2.nabble.com/Git-rebase-basics-tp7561468p7561489.html\n> Sent from the git mailing list archive at Nabble.com.\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"193617","messageId":"af093eb8bd7c4b39a17807c5cb5723e4-mfwitten@gmail.com","threadId":"30797","inReplyTo":"1339642794317-7561489.post@n2.nabble.com","subject":"Re: Git rebase basics","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":null,"receivedAt":"2012-06-14T05:08:54Z","isPatch":false,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Wed, 13 Jun 2012 19:59:54 -0700 (PDT), Lance\n\n> Sorry about that.. I thought I was being pretty descriptive but maybe I\n> missed something.\n>\n> After we setup Git (msysgit) and set it up using Apache with active\n> directory authentication, I added a repository using git init --bare then I\n> copied my files I wanted to add to the repository and did a git add . and\n> git commit -a\n>\n> So that all worked.   We have done several clones using git clone with this\n> remote repo.  We have also done  git push and git pull to verify everything\n> is working ok.   Everything was working fine.\n>\n> So back to my original train of though.\n>\n> I am trying to learn more about rebase so i have cloned the central repo two\n> times  (I call the central repo the origin) doing the following (to help you\n> understand)\n>\n> git clone https://servername:port/repopath c:\\clonedrepo1\n>\n> git clone https://servername:port/repopath c:\\clonedrepo2\n>\n> and then made changes to this cloned copy (clonedrepo1) and pushed two\n> commits back to origin.\n> (git commit -a  two times)\n>\n> so now I have the following in the remote repo (origin)   \n>\n> origin -->  C1 --> C2\n>\n> (Note to help you understand  C1 = commit 1 and c2 = commit 2, etc)\n>\n> In the other cloned copy (clonedrepo2), which I consider a branch, I have\n> made two more commits  C3 and C4\n>\n> clonedrepo2 --> C3 -->  C4\n>\n> I am able to easily pull from origin to get my clonedrepo2 to look like \n> clonerepo2 --> C3 --> C4 --> C1 --> C2 using git pull origin  or git pull\n> https://servername:port/repopath\n>\n> however I was wanting to rebase the clonedrepo2 branch so that it shows   \n> clonerepo2 -> C1 --> C2 --> C3 --> C4\n>\n> In other words I am wanting to rebase clonedrepo2 to the master of the\n> origin.\n>\n>\n> I thought the command to do this was   git rebase origin master but that\n> doesnt work and I get\n>\n> C:\\clonedrepo2>git rebase origin master\n> Switched to branch 'master'\n> Your branch is ahead of 'origin/master' by 2 commits.\n> Current branch master is up to date.\n>\n> I know my my branch is ahead by c3 and c4 but it does not have C1 and C2\n>\n> Thoughts.\n\nThis is what I SUPPOSE you mean (using a bash prompt):\n\n  $ git init temp; cd temp\n  $ echo 0 > a; git add a; git commit -m C0\n  $ cd ..; git clone --bare temp origin; rm -rf temp\n  $ git clone origin clonedrepo1\n  $ git clone origin clonedrepo2\n  $ cd clonedrepo1\n  $ echo 1 > a; git commit -am C1\n  $ echo 2 > a; git commit -am C2\n  $ git push\n  $ cd ../clonedrepo2\n  $ echo 0 > b; git add b; git commit  -m C3\n  $ echo 1 > b;            git commit -am C4\n  $ # The following line is essentially `git pull',\n  $ # but it would appear that `git pull' is currently\n  $ # ignorant of merge's `-m' flag for specifying a\n  $ # commit message on the command line.\n  $ git fetch; git merge -m C5 origin/master # Essentially `git pull'\n  $ git log --format=%s --graph\n  *   C5\n  |\\  \n  | * C2\n  | * C1\n  * | C4\n  * | C3\n  |/  \n  * C0\n\nNotice how the history splits at C0, and then merges back together\nat C5; it's not actually the case that C1 has been made a child\nof C4 (I'm guessing you have used `git log' to see a linearized\noutput, which does not reflect the topology of the graph).\n\nThe simplest solution would have been to tell `git pull' to perform\na rebase rather than a merge:\n\n  git pull --rebase\n\nWe can simulate having done so by resetting our work\nand pulling again:\n\n  $ git reset --hard :/C4 # Reset back to C4; see `git help rev-parse'\n  $ git branch C4 # Save this original C4 for later reference\n  $ git log --format=%s --graph\n  * C4\n  * C3\n  * C0\n  $ git pull --rebase\n  $ git log --format=%s --graph\n  * C4\n  * C3\n  * C2\n  * C1\n  * C0\n\nThe line:\n\n  git pull --rebase\n\nIs essentially just the same as before, except that a rebase\nrather than a merge is performed, essentially equivalent to\nthe following:\n\n  git fetch; git rebase origin/master\n\nwhich is something you could certainly do by hand to fix\nthe problem without performing the additional fetch:\n\n  $ git reset --hard C4 # Go back to the original C4 commit\n  $ git rebase origin/master\n\nSincerely,\nMichael Witten\n"},{"id":"193656","messageId":"1339689678486-7561538.post@n2.nabble.com","threadId":"30797","inReplyTo":"CAE1pOi3uXHcXm=fpH-e6pHyBTAACS7=KkdR9jQEuEjzoXy1w=A@mail.gmail.com","subject":"Re: Git rebase basics","fromName":"lancelyons","fromEmail":"llyons2@cox.net","sentAt":"2012-06-14T16:01:18Z","receivedAt":"2012-06-14T16:01:18Z","isPatch":false,"sender":{"key":"llyons2@cox.net","avatar":null},"body":"Thanks Hilco,\n\ngit pull --rebase origin master    gave me the desire results.   Thanks\n\nI am still wondering why git rebase origin master did not.\n\nI was thinking that this command would rebase the cloned repository I was in\nand rebase it to the master of the origin.\n\nin my scenario  what would git rebase origin master  be doing?\n\nAgain thanks\n\n--\nView this message in context: http://git.661346.n2.nabble.com/Git-rebase-basics-tp7561468p7561538.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"193659","messageId":"CAMOZ1BusvR=dTSRaRxHiH_wpGnk86gBU4PRvJ=sjV8xHc4OXpA@mail.gmail.com","threadId":"30797","inReplyTo":"1339689678486-7561538.post@n2.nabble.com","subject":"Re: Git rebase basics","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2012-06-14T16:28:21Z","receivedAt":"2012-06-14T16:28:21Z","isPatch":false,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Thu, Jun 14, 2012 at 4:01 PM, lancelyons <llyons2@cox.net> wrote:\n>\n> in my scenario  what would git rebase origin master  be doing?\n\nI suggest reading the documentation for `git rebase'.\n"},{"id":"193663","messageId":"1339694504410-7561545.post@n2.nabble.com","threadId":"30797","inReplyTo":"CAMOZ1BusvR=dTSRaRxHiH_wpGnk86gBU4PRvJ=sjV8xHc4OXpA@mail.gmail.com","subject":"Re: Git rebase basics","fromName":"lancelyons","fromEmail":"llyons2@cox.net","sentAt":"2012-06-14T17:21:44Z","receivedAt":"2012-06-14T17:21:44Z","isPatch":false,"sender":{"key":"llyons2@cox.net","avatar":null},"body":"Hey Michael,   Thanks thats good information there.\n\n--\nView this message in context: http://git.661346.n2.nabble.com/Git-rebase-basics-tp7561468p7561545.html\nSent from the git mailing list archive at Nabble.com.\n"}]}