threads / discuss / 56250

Branch Management

Subject: Branch Management

## tl;dr

2 messages between Aug 10, 2021 and Aug 11, 2021.

replies: 1people: 2as markdown or json

mail.chris.az@gmail.com· Aug 10, 2021, 22:24 UTC · lore

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.

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?

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.
Hopefully someone can head me in the right direction.
Thanks!
Bagas Sanjaya· Aug 11, 2021, 06:31 UTC · re: mail.chris.az@gmail.com · lore

Re: Branch Management

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

← back to recent threads