Check out git fetch;git rebase origin/master or git pull --rebase , follow the order of commits in the main repository, because it will reinstall by fixing local commits from above. You do not care that the order of local commits is as significant in local branches, because only you have them. Try, but use with caution, for example. duplicate the branch before rebooting, until you get used to it.
In general, you are talking about git workflow, and I found that you need to familiarize yourself with the two main workflows. Keep in mind that I am talking from personal experience on how to minimize conflicts:
- The first workflow for the database (for the cleanest commit history, pushes the burden of conflict in general to uncommitted code).
- Combining a workflow (sometimes easier when there are many changes that conflict, I usually use this only as a backup)
Example Initial Workflow
git checkout master // For the sake of argument, let say the latest commit in your local master is from august 1st or something old like that. git branch temp_branch // copy of the master git checkout temp_branch git add changedFiles;git commit changedFiles; // A change from november 2nd. git log // Now your dev branch has a new commit on top of an otherwise old branch. git log origin/master // You get a listing of the commits from the origin repository, the master branch.
I usually use origin / master for development, with git tags standing for commits that are made live.
Now here, where the problem arises, and where the choice of the workflow comes into play: let's say there is a commit that came from another dev repository in master, for example. commissioned on October 15th. Perhaps this was commissioned by another developer, perhaps by himself.
Your options: Merge or reinstall.
Combine
Implements additional fixation, honors your local (unpushed) branched history of development over the canonical (source / main) history, creates a little more opportunity for conflicts for other and other branches . Essentially, you say: โMy commit order will be mixed with the master branch fix orderโ as opposed to reordering the commit history.
git merge origin/master // merge commit introduced ... // Resolve any conflicts, and finalize the merge commit. git checkout master;git rebase temp_branch // Move the changes to master. git push origin/master // Pushing changes, including merge commit, to origin/master
At the end, the commit history will look something like this: August-October-November-MergeCommit
Rebase
No additional commits, honorary characters are not fixed in the canonical repository (origin / master) according to local commits, conflicts that occur usually occur during a commit that the developer has not yet committed (and therefore no one can take into account).
git rebase origin/master
Note. If you need to execute more than two conflict resolutions, then the best time is for git rebase --abort and return to the merge.
Try this process, see if it matters to you! This requires some experimentation before you can actually get a tactic that works well for your development in git, I think, because there are so many other approaches when you get decentralized.