{"thread":{"id":"47276","subject":"bash script to pull in branch B the changes from parent branch A","startedAt":"2017-11-21T17:19:32Z","lastAt":"2017-11-21T22:06:09Z","messageCount":2,"participants":["Laetitia Pfaender","Paul Smith"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"333109","messageId":"BEFA6451-9A9A-4B44-B067-727136AD39EF@icloud.com","threadId":"47276","inReplyTo":null,"subject":"bash script to pull in branch B the changes from parent branch A","fromName":"Laetitia Pfaender","fromEmail":"laetitia.pfaender@icloud.com","sentAt":"2017-11-21T16:19:22Z","receivedAt":"2017-11-21T17:19:32Z","isPatch":false,"sender":{"key":"laetitia.pfaender@icloud.com","avatar":null},"body":"Hi,\n\nI have a bash script to pull in branch B the changes from parent branch A that does the following:\n\ncd repo-in-branchB\ngit branch --set-upstream-to=origin/branchB\ngit pull\ngit branch --set-upstream-to=origin/branchA\ngit pull\ngit branch --set-upstream-to=origin/branchB\n\nIt does exactly what I want but, as I have many children branches B to update, I would like to prompt my username and password only once and then makes the script use them in all following git requests. I came to the conclusion that I needed to update my script as follow:\n\nread -p \"Username for 'https://github.com': \" username\nread -s -p \"Password for 'https://$username@github.com': \" password\necho \"\"\ncd repo-in-branchB\necho “pull from branchB\"\ngit pull https://$username:$password@github.com/myrepo.git heads/branchB\necho “pull from parent branchA\"\ngit pull https://$username:$password@github.com/myrepo.git heads/branchA\n\nI have never used this kind of URLs, so just to make sure, are these 2 versions conceptually equivalent? Will they do the exact same thing?\n\nBest regards\n\nLaetitia\n\nPS: I’m open to suggestions but note that I don’t want to rebase, neither can I configure my username and password in a permanent way on this server.\n\n\n\n"},{"id":"333174","messageId":"1511300532.7410.19.camel@mad-scientist.net","threadId":"47276","inReplyTo":"BEFA6451-9A9A-4B44-B067-727136AD39EF@icloud.com","subject":"Re: bash script to pull in branch B the changes from parent branch A","fromName":"Paul Smith","fromEmail":"paul@mad-scientist.net","sentAt":"2017-11-21T21:42:12Z","receivedAt":"2017-11-21T22:06:09Z","isPatch":false,"sender":{"key":"paul@mad-scientist.net","avatar":"https://avatars.githubusercontent.com/u/109636?v=4"},"body":"On Wed, 2017-11-22 at 00:19 +0800, Laetitia Pfaender wrote:\n> cd repo-in-branchB\n> git branch --set-upstream-to=origin/branchB\n> git pull\n> \n> git branch --set-upstream-to=origin/branchA\n> git pull\n> git branch --set-\n> upstream-to=origin/branchB\n> \n> It does exactly what I want but, as I have\n> many children branches B to update, I would like to prompt my\n> username and password only once and then makes the script use them in\n> all following git requests.\n\nIt would be nice if you explained in words exactly what it is you want\nto do.\n\nThis seems like a lot more work than necessary.  A \"git pull\" consists\nof two steps: first a \"git fetch\" which is the part that actually goes\nout to the remote and pulls all the new content, and then a merge\noperation to the remote's version of the current branch.\n\nThe \"git fetch\" is all that needs credentials, and it pulls the entire\ncontents of the repo including all branches, so you only need to do it\nonce.\n\nIs there some reason why you can't do the following:\n\n  cd repo\n  git fetch (requires you to enter username/password)\n  git merge origin/branchB\n  git merge origin/branchA\n\nand just continue to merge for each different branch (without re-\nrunning git fetch)?\n\n>  I came to the conclusion that I needed to update my script as\n> follow:\n> echo “pull from branchB\"\n> git pull https://$username:$password@g\n> ithub.com/myrepo.git heads/branchB\n> echo “pull from parent branchA\"\n> git\n> pull https://$username:$password@github.com/myrepo.git heads/branchA\n>  I came to the conclusion that I needed to update my script as\n> follow:\n> echo “pull from branchB\"\n> git pull https://$username:$password@g\n> ithub.com/myrepo.git heads/branchB\n> echo “pull from parent branchA\"\n> git\n> pull https://$username:$password@github.com/myrepo.git heads/branchA\n\nDon't know how well this works as I don't use HTTPS remotes very much. \nBut note, this will make your username AND password for your GitHub\naccount visible to anyone one the system who happens to run \"ps\" while\nyour pull command is running.\n"}]}