简体   繁体   中英

Installing and updating local copy of project from git repo

I'm currently developing a small blogging system for use on two different websites (maybe more in time) that I plan to host on github. While I understand the development side of git (adding files, committing changes, pushing to a remote) I'm struggling to understand the deployment side. What I would like to know is how I would

  1. install the initial copy of the code necessary for the site and

  2. grab updates to that code after the repository has been updated

Similar to WordPress, the baseline code will include a sample config file that needs to be copied and edited as well as an empty directory used for client uploads. Here's how I think the process should flow along.

  1. Development - write code, commit, push
  2. Development - more code, commits, pushes
  3. Production - install software (how?)
  4. Development - code again, commit, push
  5. Production - update local install (how?)

Steps 3 and 5 are where I'm missing something. I've read about cloning, fetching, and pulling but I don't think they are what I need for this scenario.

I'm trying to figure out how I can grab the initial copy of the code plus grab updates while ensuring the following:

  1. I don't end up with the entire git repository history of the project in each install, just the current version of the files.
  2. Pulling updates only overwrites/deletes tracked code files and leaves things like the copied config file and uploads directory as-is

What command(s) do I need to do this?

To push new code to the server and have the server automatically update its code, you will want to use a "bare" git repository along with a git hook. See this page for instructions: http://toroid.org/git-website-howto

To avoid deleting or overwriting files, it sounds like what you're looking for is the .gitignore file. From git's documentation ( https://git-scm.com/docs/gitignore ):

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected

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