DEV Community

Discussion on: Master Git in 7 minutes

Collapse
 
emptypockets profile image
Andrey Kondratyuk

Does it matter if branch changes are pushed to a remote before rebasing? Would the steps be any different?

Collapse
 
valeriavg profile image
Valeria

No, the steps would be the same, but force push would wipe remote branch commits that have not been pulled and may require hard reset on all local repositories, apart from your own.

Collapse
 
emptypockets profile image
Andrey Kondratyuk • Edited

I don't think I 100% follow.

If I created a branch git checkout -b my-new-branch and then stage, commit, and push:

  • git add .
  • git commit -m "my message"
  • git push origin my-new-branch

Does it matter that it the code was pushed to the remote? Could I then rebase as you described?

Thread Thread
 
valeriavg profile image
Valeria

Yes you can rebase my-new-branch from main with git rebase main locally, but you will need to git push --force my-new-branch to push these changes to a remote origin

Thread Thread
 
emptypockets profile image
Andrey Kondratyuk

Thanks for the clarification. I think I understand. My plan at the moment is to try it with different scenarios and make sure I really do get it.

Great guide. Very much appreciated!