A few small questions about git checkout-b and git push!

1. If I pull the code remotely now, there are two branches, master and a, and I git checkout-b on the master branch to build a new b branch, which is different from switching to the a branch and then git checkout-b?
2. Now the code on the b branch has been written and submitted to the remote warehouse, git add. And after git commit is direct git push or
git push origin b, (what"s the difference from git push origin BRV b? )
3. Now the code on the b branch has been written and submitted to the remote repository, git add. What happened to git push origin and git push origin an after git commit?

I just learned git. I don"t quite understand these points. I hope the boss will answer

.
Jul.06,2022

1, git checkout-b means to create a new branch b based on the content of the current branch and switch the context to the b branch. On master, the content of b is the same as that of master, and on a, the content of b is the same as that of a.
2 & 3, git push < remote host name > < local branch name >: < remote branch name > :
git push origin branch b means that the local b branch is pushed to the b branch on the remote origin host. In general, the remote branch name is the same as the local branch name, so: B will be omitted, if there is no branch named b, then b branch will be automatically created.

git push origin means that the current branch is pushed to the corresponding branch of the origin host. The context of git operation must be based on a certain branch. For example, if you have switched to branch b and then perform the operation, then the content is submitted directly git push origin . If the remote branch already has an association with the local branch, origin can also be omitted and the current branch can be pushed directly git push .

Menu