How to create a branch and click on the server

I cloned a project from a repo, and I need to create a branch, and in this branch make my changes. After that I need to push this thread to the repo. How to do it? Sorry, am I new to git?

+6
source share
1 answer

You can create a new branch called my-work (based on the current commit) and switch to this branch with:

 git branch my-work git checkout my-work 

Or, as a shortcut to these two commands, you can simply do:

 git checkout -b my-work 

To drag this branch into a cloned repository, you must do:

 git push origin my-work 

origin is an alias for the repository you cloned. It is known as "remote", in git terminology. Update: clarification due to a useful comment by Michael Minton: this will push your my-work branch to a branch called my-work in the remote repository, creating it if necessary - if you had something else in mind, it would be better to edit Your question is to clarify this point.

The first time you run this push command, you might want to make git push -u origin my-work , which sets the configuration parameters that make the my-work branch in the origin repository considered as the default upstream branch for your my-work branch. (You don’t need to worry about this if you are new to git, but that would mean that git provides more useful status information, and various commands have more useful default actions.)

+16
source

Source: https://habr.com/ru/post/898965/


All Articles