git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: bash script to pull in branch B the changes from parent branch A

From
Paul Smith <paul@mad-scientist.net>
Date
Nov 21, 2017, 21:42 UTC
Message-ID
<1511300532.7410.19.camel@mad-scientist.net>
In-Reply-To
<BEFA6451-9A9A-4B44-B067-727136AD39EF@icloud.com>
On Wed, 2017-11-22 at 00:19 +0800, Laetitia Pfaender wrote:
Show 13 quoted lines
> cd repo-in-branchB
> git branch --set-upstream-to=origin/branchB
> git pull
> 
> git branch --set-upstream-to=origin/branchA
> git pull
> git branch --set-
> upstream-to=origin/branchB
> 
> It 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.

It would be nice if you explained in words exactly what it is you want to do.

This seems like a lot more work than necessary. A "git pull" consists of two steps: first a "git fetch" which is the part that actually goes out to the remote and pulls all the new content, and then a merge operation to the remote's version of the current branch.

The "git fetch" is all that needs credentials, and it pulls the entire contents of the repo including all branches, so you only need to do it once.

Is there some reason why you can't do the following:
  cd repo
  git fetch (requires you to enter username/password)
  git merge origin/branchB
  git merge origin/branchA

and just continue to merge for each different branch (without re- running git fetch)?

Show 16 quoted lines
>  I came to the conclusion that I needed to update my script as
> follow:
> echo “pull from branchB"
> git pull https://$username:$password@g
> ithub.com/myrepo.git heads/branchB
> echo “pull from parent branchA"
> git
> pull https://$username:$password@github.com/myrepo.git heads/branchA
>  I came to the conclusion that I needed to update my script as
> follow:
> echo “pull from branchB"
> git pull https://$username:$password@g
> ithub.com/myrepo.git heads/branchB
> echo “pull from parent branchA"
> git
> pull https://$username:$password@github.com/myrepo.git heads/branchA

Don't know how well this works as I don't use HTTPS remotes very much. But note, this will make your username AND password for your GitHub account visible to anyone one the system who happens to run "ps" while your pull command is running.

Previous: Laetitia Pfaender
Message 2 of 2 in “bash script to pull in branch B the changes from parent branch A”
  1. Laetitia PfaenderNov 21, 2017
  2. Paul SmithNov 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.