I am a contractor working on a small time-constrained project. I don't know Git very well which is naturally why I am here. The client uses GitHub and we use Bitbucket, so we essentially need some automated pulls with GitHub -> Bitbucket periodically, then some automated pushes with Bitbucket -> GitHub so we can do a pull request on their GitHub. That magic is being handled with Pipelines, but I can't get the dice roll of Git commands right to sync essentially independent repositories. Code is run as ordered except with Version 1 and Version 2 sections.
# Starting on origin/develop git remote add clientrepo1 git@github.com:[username]/client-repo-1.git # Boss wants this commit hidden and the file removed from Client repository, so I do this first in my local develop branch. git rm bitbucket-pipelines.yml --force --ignore-unmatch git commit -m "Removing pipeline file." # Version 1 # "Just Sync the code, hide commit history, delete pipelines.yml file on push" git fetch clientrepo1 develop:temp-branch git checkout temp-branch git merge --squash develop temp-branch -Xtheirs git commit -m "Pushing updates to Client Repository" git push clientrepo1 temp-branch:develop # Version 2 - NOT WORKING # "Sync the code, preserve commit history, but still hide the pipelines.yml file" git fetch clientrepo1 develop:temp-branch git checkout temp-branch git merge origin/develop temp-branch -Xours git push clientrepo1 temp-branch:develop Version one is something I made to sync our develop branch with theirs while also hiding commit history and the bitbucket-pipelines.yml file at request of my boss. That was great except legitimate DELETE file commits were now being ignored and not pushed to the GitHub repository. I suspect --squash. Not a big deal anymore though because we aren't using this solution after my demonstration.
Version two is probably getting closer to the preferred syncing solution because the client now wants transparency with commit history, but it is broken because GitHub has "Deleted pipelines.yml" commits that conflict with my Bitbucket local branch despite my -Xtheirs option. It also doesn't even touch the "Ignore the Pipelines.yml commit" problem yet. I suspect this problem is related to merging a few times before and having multiple +Deleted pipelines.yml commits despite me never actually adding a +pipelines.yml file in the first place in GitHub. Idk.
So I am trying to get Version 2 working with the constraints: Push to client's develop branch, Preserve commit history, and hide pipelines.yml so it never touches the GitHub repository, and keep this automated because this is going in Bitbucket pipelines. I would appreciate any advice or examples as a new learner.
https://stackoverflow.com/questions/66468430/how-do-i-sync-a-bitbucket-branch-to-github-without-the-bitbucket-pipelines-yml-a March 04, 2021 at 12:07PM
没有评论:
发表评论