简体   繁体   中英

git pull request and remote branch relation

I git cloned master from the server. Then create a local new_branch, make changes and add/commit to local new_branch. Then push new_branch to server.

Until this time, I can't see this new_branch on a server by git branch -r.
Added: I can't see the new_branch on git server browser either. The master is not under my control. In my understanding, after I "git push origin new_branch", the local new_branch should be created on remote already. I thought creating new_branch on the remote should have nothing to do with creating a pull request or not. However, even no commit detail in a log, as my colleague said. He told me to create a pull request(on the browser) to begin a review, then merge to master.

I don't understand this process very well. Why creating a new remote branch is bonded to creating a pull request? Or is that just a pre-defined binding by the project admin to enforce the review process? Anyway, I can't see the remote new_branch after push. I have Read/Write permission.

The toolsRT_lingyuntest(the new_branch mentioned) is what I pushed to the remote. I searched the red list(not show fully in this snapshot). I can't find it.

(I have to erase some texts in the picture to hide some information) 在此处输入图像描述

Just after you pushed the new branch to remote, your local repo is not yet aware of the new remote branch, only the local one.

You'd now have to git fetch to have your newly created branch appear in git branch -r output.


For the pull request part, hard to say from here, but it's likely just an indication of the prefered way to merge things into master , as it is often the case for "main" (stable) branches.

So to put on master whatever changes you commited and pushed on your new branch, you'll have to create, on remote server, the pull request new_branch > master

I found the reason. It's my fault.

I didn't use "-u" on first push. That seems why I got "fatal: the current branch xyz has no upstream"

I missed rest of the red list actually. It didn't show complete list and I didn't type space bar to read the rest. My branch is there, though I don't know when it's created.

During the operation, Actually I had tried once "git push -u origin xyz" but I'm unaware I had changed my current path to another git repo folder. And I got an error I can't understand. Every step returned me an error and I lose patience.

Now I got why. Several mixed mistakes.

The process is:

  1. create local branch

  2. make changes, add, commit

  3. git push -u origin xyz, clearly know where you're

Then should see the remote branch. I think the "make pull request" is another thing, irrespective to the new branch. It's a next optional step to make review and merge code automatically. Am I right?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM