{"thread":{"id":"17941","subject":"How to update? (git Changed but not updated)","startedAt":"2009-02-21T21:23:01Z","lastAt":"2009-02-22T10:07:43Z","messageCount":4,"participants":["Reto S. News","Sitaram Chamarty","Rainer Blome","Reto Schär"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"105745","messageId":"49A070B5.90909@dplanet.ch","threadId":"17941","inReplyTo":null,"subject":"How to update? (git Changed but not updated)","fromName":"Reto S. News","fromEmail":"retoh@dplanet.ch","sentAt":"2009-02-21T21:23:01Z","receivedAt":"2009-02-21T21:23:01Z","isPatch":false,"sender":{"key":"retoh@dplanet.ch","avatar":null},"body":"Beginner question: \"How to update the pushed changes on the master?\"\n\nAs a proof of concept to switch from CVS to git I prepared an\nenvironment on two servers. I call the one \"Slave\" and \"Master\"\nthe other. Almost everything is working besides a silly\n\"cvs update\" functionality I couldn't still find out after hours.\n\nOn Slave Host (a Developer that receives a working copy of a project):\n\n$ git clone git://master.example.net/test myrepo\n$ cd myrepo   # ... here I see all received files from the master\n$ Changing file \"foo.txt\"\n$ git add .   # ... for whatever reason this is necessary\n$ git commit -m 'I changed this file'\n$ git push\n\nOn Master Host (master.example.net):\n\n# git status # Shows me correctly foo.txt has been changed by the\"Slave\"\n# git show   # Shows me even the made changes in a diff style!\n\n\nNow I have to update the fresh content produced by the \"Slave\". As an\nugly work-around, I'm currently cloning it again from localhost :-|\n\nAny suggestions are very appreciated.\n\n--reto\n"},{"id":"105751","messageId":"slrngq19fs.vna.sitaramc@sitaramc.homelinux.net","threadId":"17941","inReplyTo":"49A070B5.90909@dplanet.ch","subject":"Re: How to update? (git Changed but not updated)","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2009-02-22T01:10:20Z","receivedAt":"2009-02-22T01:10:20Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On 2009-02-21, Reto S. News <retoh@dplanet.ch> wrote:\n> Beginner question: \"How to update the pushed changes on the master?\"\n>\n> On Slave Host (a Developer that receives a working copy of a project):\n>\n> $ git clone git://master.example.net/test myrepo\n> $ cd myrepo   # ... here I see all received files from the master\n> $ Changing file \"foo.txt\"\n> $ git add .   # ... for whatever reason this is necessary\n> $ git commit -m 'I changed this file'\n> $ git push\n>\n> On Master Host (master.example.net):\n>\n> # git status # Shows me correctly foo.txt has been changed by the\"Slave\"\n> # git show   # Shows me even the made changes in a diff style!\n\nI'll bet the changes shown are 'reversed'...\n\n> Now I have to update the fresh content produced by the \"Slave\". As an\n> ugly work-around, I'm currently cloning it again from localhost :-|\n>\n> Any suggestions are very appreciated.\n\nYour master is a non-bare repo.  Try\nhttp://git.or.cz/gitwiki/GitFaq#non-bare .\n\nI also wrote up a much more detailed description of this at\nhttp://sitaramc.github.com/concepts-and-tips/0-terminology.html#a5\n-- I hope it helps you.\n\nRegards,\n\nSitaram\n"},{"id":"105752","messageId":"49A0AB26.40701@gmx.de","threadId":"17941","inReplyTo":"49A070B5.90909@dplanet.ch","subject":"Re: How to update? (git Changed but not updated)","fromName":"Rainer Blome","fromEmail":"rainer.blome@gmx.de","sentAt":"2009-02-22T01:32:22Z","receivedAt":"2009-02-22T01:32:22Z","isPatch":false,"sender":{"key":"rainer.blome@gmx.de","avatar":null},"body":"Reto S. News wrote:\n> Beginner question: \"How to update the pushed changes on the master?\"\n\n> # git status # Shows me correctly foo.txt has been changed by the\"Slave\"\n\nNo, it shows that the work tree has been left behind with respect to the \nhead of master.\n\nFix this using git checkout master and git reset --hard.\n\n> # git show   # Shows me even the made changes in a diff style!\n\nBut probably the wrong way around, showing added lines as removed?\n\n\nFreshman answer:\nHere's what I am doing.\n\nThe attached script mygit-test.sh is a simple test of the below work \nflow, with three repositories a (origin), and clones b and c.\n\nLet's calls the \"Master\" server \"Shared\", to avoid confusion with any \n\"master\" branch.\n\nOn Shared, do not work in the master branch.\nInstead, work in a dedicated local branch, for example \n\"central-development\".\n\n# Only needed if your working directory and index are not clean:\ngit stash\n\ngit checkout master\ngit checkout -b central-development\n\n# Only needed if you had to stash above:\ngit stash apply\n# You can now commit any changes\n# Once you've safely commited the changes, use: git stash clear\n\n\nOn Slave, do not work in the master branch as well.\nInstead, work in a dedicated local branch, for example \"slave\".\n\ngit checkout -b master origin/master  # Ensure a local copy of master exists\ngit pull origin master # Ensure the new branch is up to date\ngit checkout -b slave  # Create the local development branch\n\n# Now edit, commit, edit, commit, ...\n# Once you want to publish your changes:\n\n# Update local copy of master:\ngit pull --rebase origin master\n\n# LOOP:\n# Merge your changes on top of new master, staying on slave:\ngit rebase master slave\n# Test and review the merged code on slave.\n\n# Update local copy of master, again,\n# to make sure it has not changed in the meantime:\ngit pull --rebase origin master\n# If it changed, go to LOOP, otherwise continue below.\n\n# Update local copy of master (this is now fast-forward)\ngit rebase slave master\n# Send changes to master on Shared\ngit push origin master\n# Leave master\ngit checkout slave\n\nOn Shared:\n# Update development with respect to changes on master\ngit rebase master development\n\n\nComplex?  Yes.\nCan it be simplified?  I hope so.\n\nI have written a script that helps to use the work flow described here.\nIf anyone is interested, please comment.\n\nGood luck, Rainer\n\n"},{"id":"105815","messageId":"loom.20090222T100316-281@post.gmane.org","threadId":"17941","inReplyTo":"49A070B5.90909@dplanet.ch","subject":"Re: How to update? (git Changed but not updated)","fromName":"Reto Schär","fromEmail":"spam@infocopter.ch","sentAt":"2009-02-22T10:07:43Z","receivedAt":"2009-02-22T10:07:43Z","isPatch":false,"sender":{"key":"spam@infocopter.ch","avatar":null},"body":"Sorry. The final counterpart of a \"cvs update\" was a simple \"git pull\".\n\n# Almost too much documentation available for such simple scenarios ;_)\n\n--\nReto S. News <retoh <at> dplanet.ch> writes:\n"}]}