0

How is it possible to set git branch --set-upstream-to=origin with a Gitlab Access Token?

Adding git remote add origin with a Gitlab Access Token works well like described here.

Peter
  • 323
  • 4
  • 15
  • 1
    You shouldn't need to authenticate for each branch. If you already provided authentication for the server configured in your remote (`origin`) then there's nothing you need to do to use that remote with a new branch. Is there a specific problem or error you are experiencing? – sytech Sep 15 '22 at 20:52
  • The upstream setting for a branch name is for your local repository, and is effectively just a string (though it has some constraints). Since you set it in your *local* repository (not in a hosted repository) you don't need to authenticate at all, other than to log in to your own laptop in the usual way you do that. – torek Sep 16 '22 at 03:02
  • Typically, the upstream of branch `X` is `origin/X`, for any X. You would do this with `git branch --set-upstream-to=origin/X X`, or if you're on branch `X` already, `git branch --set-upstream-to=origin/X`. The main constraint here is that `origin/X` must exist *in your local repository*. (It need not exist in any other repository.) – torek Sep 16 '22 at 03:04
  • Note that you *must not* leave off the `X` here. Running `git branch --set-upstream-to=origin` is not what you want to do. (It does have a meaning, but with one exception, you never want this—and that one exception is such that you should almost never want to use it.) – torek Sep 16 '22 at 03:07

0 Answers0