If you run the git branch -a command, it displays this

 aleksey@aleksey:~/Downloads/NTZ/FittingRoom$ git branch -a * develop master remotes/origin/HEAD -> origin/master remotes/origin/master 

2 local branches and 2 on the server ... Locally master and develop , and now if I want to push to the server, then I definitely need to do it in the master ... But I have this branch for releases ...

How to create on the server branch of the dev?

EDIT

 $ git remote show origin * remote origin Fetch URL: https://gitlab.com/alekseytimoshchenko/NewTimeZone.git Push URL: https://gitlab.com/alekseytimoshchenko/NewTimeZone.git HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) 
  • Please attach the output of git remote show origin - aleksandr barakin
  • 2
    git checkout develop && git push -u origin develop - KoVadim
  • @alexanderbarakin added - Aleksey Timoshchenko
  • @KoVadim I don’t fully understand what your team is doing, it switches to a branch (and if I'm already on it?), And does a push to the server devs (but this branch is not there ...) ... Can you explain? - Aleksey Timoshchenko
  • one
    first switch. If already there, then you can not do, but nothing terrible will happen. The second command "sends a branch to the server with a binding". If it is not there, it will be created. - KoVadim 3:19 pm

1 answer 1

 $ git remote show origin ... Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) 

here you can see that for the git pull command (without parameters) only the local master branch is configured (updates will be taken from the remote master branch). similarly for git push (without parameters) - only updates from the local master branch will be sent to the remote repository (to the remote master branch).


The local branch can be configured to send changes to any branch of the remote repository (when calling git push with no parameters in this branch).

the easiest way to do this is by passing the -u ( --set-upstream ) option to the git push command once. Naturally, you need to specify both the repository name and the branch in it, to which the current branch will be “tied”.

for your particular case:

  1. make the develop branch current:

     $ git checkout develop 
  2. send the changes from it, while specifying the "binding" to the remote branch develop in the origin repository (an example of the output is also shown):

     $ git push -u origin develop Total 0 (delta 0), reused 0 (delta 0) To url-репозитория * [new branch] develop -> develop Branch develop set up to track remote branch develop from origin. 

    The last line just reports that the local develop branch is “connected” to the remote develop branch (in the origin repository).


now the command:

 $ git remote show origin 

will show a little more information about the "bindings":

 ... Local branches configured for 'git pull': develop merges with remote develop master merges with remote master Local refs configured for 'git push': develop pushes to develop (up to date) master pushes to master (up to date) 

and the git push command (without parameters) that is executed later in the develop branch will send the changes to the remote develop branch.


by the way

one-time to send changes from any local branch to (almost) any branch in the remote repository (and without performing any “bindings”), you can:

 $ git push репозиторий локальная_ветка:удалённая_ветка 

For example, for your case:

 $ git push origin develop:develop 

if the branch with the specified name does not exist in the remote repository, it will be created. and if it exists, then, in principle, the command may fail with an error - if you “merge” changes from a local branch into a remote branch, it will not work. but that's another story.