version control - Git pull requires a merge but no local changes -
i have webhook on github repo triggers git pull on server repository on server in sync what's been pushed github.
sometimes pull requires merge commit server version never committed or altered. when @ diffs, merge commit shows changes last few commits, makes seem server version up-to-date , it's trying pull down behind it.
it runs code pull down branches (which can improved). in case, branch master.
git fetch origin remote in $(git branch -r) ; git checkout $(echo $remote | cut -d \'/\' -f2) && git pull origin $(echo $remote | cut -d \'/\' -f2); done
when run git status on server's version, says local branch xx ahead of remote. these changes coming from?
it sounds may modifying commits have been pushed github. there many ways can happen, 2 common ones amending commits , rebasing. both of these fine local commits, doing shared commits causes trouble.
consider simple repository on github:
a---b---c [master] if developer decides amend commit c commit's hash gets changed, instance d. github has commits listed above, developer has locally:
a---b---d [master] when developer pushes github push refused, because github contains commit c master branch, commit not present in developer's branch. github accept changes, developer must force push.
any time find force pushing in git you're doing should considered. should occasional action when have to, , not part of "normal" workflow.
now github has been forcefully updated new commit structure includes commit d have exact same problem when try pull updates github: copy of repository on other developers' machines , on server can't cleanly resolve pull because contain commit c, no longer present on github.
we can avoid problem not modifying shared history. instead of amending shared commits, consider adding new commit. history may contain messages like
- add new feature x
- oops, fix simple bug in feature x
but that's small price pay not having deal branches have diverged modified shared history.
Comments
Post a Comment