Re: Branch Management
- From
Bagas Sanjaya <bagasdotme@gmail.com>
- Date
- Aug 11, 2021, 06:31 UTC
- Message-ID
- <4b533ee7-4aa7-6ad5-6722-fca3eaadf464@gmail.com>
- In-Reply-To
- <01d001d78e36$8d47f380$a7d7da80$@gmail.com>
On 11/08/21 05.24, mail.chris.az@gmail.com wrote:
Show 9 quoted lines
> I have a private git repository (private.git) on a private server > (PRIVATEREPO.COM). That repo is updated via development on my local system. > All works great in that area. I have 2 branches, "master" and "version". > > I want to update my production system via git from the private git > repository via command line. The production system not only contains the > files from the repo, but also additional files and directories. I need > those files to be left alone. >
You can specify which files and directories you want to ignore in .gitignore. For example, based on your use case:
``` /var/prod/ /etc/ohmyapp/ohmyapp.conf ... ```
Show 7 quoted lines
> I was able to successful clone just the "master" branch using: > > # git clone -b master git_user@PRIVATEREPO.COM:private.git production.git > > I am now ready to move the new "version" branch. > 1. How can I do that? >
Use `git checkout version`.
Show 10 quoted lines
> The "version" branch contains some new files that are not in the "master" > branch. > > Now suppose that I move to the "version" branch, but determine that I need > to go back to the "master" branch. > > 2. How do I go back to the "master" branch and remove any of the new files > that were uploaded from the "version" branch? I don't want any remnants > that the "version" branch was even there. >
Practically speaking, `git checkout` updates working directory to revision specified in the argument, ignoring `.gitignore`.
I assumed that you have app+default config committed to your repo (not including /var-like production data of course). In that case, a simple `git checkout` will do most of the job; you need to figure out how to handle .gitignore-ed trees (since these maybe version-specific).
-- An old man doll... just what I always wanted! - Clara