After the last pull'a from the githab, it popped up to create a new branch for further work and all commits were made to the master.

Now I want to re-upload the project to the githab to test and create a pull request.

Is such a way possible:

  • I create branch branch1 (as I understand it it will contain info from the last master commit)
  • her push on githab
  • I am creating a PR between a rep master and a branch1 just filled in with

Changes will be visible?

  • git checkout -b, then dropping a local master and re-defining is not an option? - Qwertiy
  • then you have to manually make edits, no? - rostov-7
  • Not understood. This is the creation of a new branch from the current commit. - Qwertiy
  • logically - in principle, an option)) .. just did not know that you could drop the local master, and then start up the old one from the repo. and my vajrant does not suit at all? Isn’t PR comparing not repov master with a thread? - rostov-7
  • I do not know ... Maybe so. - Qwertiy

2 answers 2

You can leave at the current location (with changes) a new branch:

git checkout -b branch1 

... and only push it .

 git push -u origin branch1 

Yes, the changes will be visible if the old master on the server.
At this stage, you can already do pull request.


But the local master should be rolled back to the state on the server in order to avoid surprises during further work. This can be done at any time, but the best thing is after sending branch1 to the server, so as not to lose anything.

 git checkout master git reset --hard origin/master 

The last command forcibly hangs the master branch at the specified point ( origin/master ). In this form, it is relatively safe, because the story does not correspond, but slightly moves into the past.

But in general, it can easily do things and lose new commits. Therefore, it is a good habit to leave in place, from which the branch is removed, another, spare branch. Here it is already done: just there lies branch1 .

  • Thank you so much .. i. Will RP take the repo master for comparison? and branch1. after creating a PR, I can roll back the local master to the server .. after the RP, the sms master and branch, and after that, push everything back to the local machine? - rostov-7
  • one
    @ rostov-7 you do PR on the server. Take one server branch and offer to another. Your local branches can live their life. You can roll back the local master to the server state at any time. - D-side

You can hide local changes, sprawl, and then their svadzhit back

 git reset --soft commit_name git stash git pull --ff-only origin master git stash apply // тут могут предложить смерджиться, если автомердж не прошел. 

then you can continue to develop in the current master