简体   繁体   中英

making sure Git merge / pull from remote fully updates repo

have question its not about a particular bit of code.

Have 3 git repositories, one is local (dev), one production (site with a domain name), and a remote repo at a code site like github.

I decided to do my changes to code in local repo, pushing them to the remote repo, then ssh into the server production repo and fetch/merge or pull updates from remote repo.

Today I did it second time to update some content. Fetch and merge did not go well, part of the code was updated but part (eg. styling) was obviously missing. Second time I tried just pulling to prod server from remote, and this time it seemed to work as things looked apparently right. But browsing I notice a few small changes are not applied.

found fix: git reset --hard origin/master

This applied all changes to prod repo. But now Im worried anytime I pull to prod repo some small thing might not be applied. How do I reliably update from a remote repo? Did I just do something wrong? is there some setting I can change or do I need to do above fix every time?

How do I reliably update from a remote repo?

Through an automated process, which means a GitHub Action associated to a to_prod branch.

Meaning:

  • when you push to your master branch on GitHub, nothing happen. You are just publishing your code to GitHub.
  • but when you are pushing that same code to the " to_prod " branch, then a GitHub Action can run, and copy (FTP for example) that code to your production server.
    Bonus: the production server no longer needs Git (which should not be required to actually run your program in production anyway)

There are many GitHub Actions , but consider for instance SamKirkland/FTP-Deploy-Action .
See also " Only run job on specific branch with GitHub Actions ":

on:
  push:
    branches:
      - to_prod

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM