Regularly synchronize a branch with a master using git rebase

I have a Git repository with a branch that almost never changes (no one contributes to it). This is basically a master branch with code and files highlighted. Having this branch makes it easier for me to pack a more compact version of my project without having to cut code and files manually each time.

I used git rebase to get this branch updated with the wizard, but I always get this warning when I try to push the branch after reboot:

 To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. 

Then I use git push --force and it works, but I feel like this is probably bad practice. I want this branch to "synchronize" with the master quickly and easily. Is there a better way to handle this?

Update

See this topic for a full explanation and solution:

git rebase and git push: fast forward, why use?

+2
source share
1 answer

Trick:

  • when you rebuild the "template" branch, you change its history (different SHA1), which means that any click will not be advanced (there is no "new SHA1" to add, but a completely new set of SHA1 to replace)
  • you then push this branch to a non-bare repo (which is prevented by default)

This is bad practice:

  • if other people depend on the selection of this branch (which is wrong here)
  • if you depend on the contents of the working tree of the remote repo you are clicking on (since this content, if set to represent the template branch, may not synchronize with the actual template branch that you just clicked)

If these two points are not a problem, you can continue.
But (or more) the β€œright” way to deal with this is to have an intermediate bare repo (on the remote server) that you need to click, and then extract / pull the template branch from this bare repo to another server where you need this template project.

+3
source

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


All Articles