After a Git push, remote repo shows files as deleted

前端 未结 3 789
無奈伤痛
無奈伤痛 2020-12-10 21:30

I cannot find any of the files on my remote repo.

  1. Created a Git repo on shared hosting (site5) as described by their tutorial
  2. init\'d it and added a s
3条回答
  •  南笙
    南笙 (楼主)
    2020-12-10 21:55

    I have a similar use case at work: desiring a 'pristine' home directory on a number of servers where I check processes, monitor logs, etc. - without having to change every single one of them when I add a new command, alias, script, etc. Learning from the existing answers here I solved like this:

    1. Create a 'master' repo on my desktop machine representing my desired $HOME directory on the remote
    2. Get the master repo into a good state with the setup I wanted (in particular with a canonical .ssh/authorized_keys file)
    3. On one remote machine, create a new (non-bare) repo in $HOME
    4. Push the master to the remote repo in $HOME
    5. Run 'git reset --hard' in remote repo

    To keep them up to date I added the following git alias to help me out with updating all my remote working copies in a single command:

    [alias]
        pushall = "!for remote in myremote{1..10}; do git push ${remote} master; ssh ${remote} git reset --hard; done"
    

    Now when a new remote is provisioned - I rsync my $HOME directory from an existing remote to the new one, then add my new machine to the alias above. Running 'git pushall' after making a change (say after adding a handy new script to look at logs) will then update all the remote working copies with a pristine copy of what I want my (remote) $HOME directory to be. No more updating every single remote by hand!

    Note: the double quotes around the entire alias are important here otherwise the semi-colon will bite you

    Thanks to others for existing answers that helped me get this working.

提交回复
热议问题