GIT workflow with multiple workstations and a centralized server

Well, a few things I'm not quite sure about.

To start:

  • I have a bare repo on VPS in a remote DC.
  • I have a workstation on which I also code.
  • I have a workstation at home, on which I also have a code.

1 - When I installed my initial repo on one of my workstations (I think Git calls this wizard), should I check and work from another directory? Like subversion.

2 - When I want to work on the code at work, I am confused about how to make commits for the LOCAL repo on the desktop, and then at the end of the day push my changes to the “bare” repo on my VPS so that I can transfer updates to my home worker table.

I tried using a clone, but every push I make from my home desktop ended with w / me, pushing the changes back to the remote repo.

+3
source share
2 answers

1 - masteris the default git name for the main repository branch. It does not apply to the entire repository, but to one line of development. You do not need a separate working directory - the general idea of ​​local git development is to work in the directory, commit changes to the repository, and then push them up as necessary.

2 - , , VPS. , VPS, "". , . - , , , , .

, , VPS . , git push git pull. , VPS, ,

git remote add origin <url-of-VPS-repo>
git config branch.master.remote origin
git config branch.master.merge = refs/heads/master

git , , ( VPS).

+4

Git ( ) " ". , "master" "devel",

$ git checkout devel

"devel". , .


"", "" "" :

-, . , "", "" "" ( ), , ( "git remote add" ):

[remote "bare"]
    url = user@example.com:/path/to/repo.git
    fetch = +refs/heads/*:refs/remotes/bare/*
    push = refs/heads/*:refs/heads/*

, , (, fetch = +refs/tags/*:refs/tags/* ..), .

-, , "master", "", "" :

[branch "master"]
    remote = bare
    merge = refs/heads/master

, .

. "", "".

  • , , "" . , "" . , "git pull bare" "git pull":

    $ git pull bare
    Updating 8818df8..9ad6770
    Fast forward
     foo |    1 +
     1 files changed, 1 insertions(+), 0 deletions(-)
    

    " " , "" , ( - , "" ). "", "", , , , .

  • ( ):

    $ edit, edit, edit
    $ git commit -a
    $ git add somefile
    $ git commit -a
    $ git commit --amend
    

    , , , . , "git pull", , . "git stash", oncomitted , stash () pull.

  • "" , .

    $ git push bare
    Counting objects: 8, done.
    Compressing objects: 100% (3/3), done.
    Writing objects: 100% (6/6), 493 bytes, done.
    Total 6 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (6/6), done.
    To user@example.com:/path/to/repo.git
       9ad6770..4230584  master -> master
    

, .

0

Source: https://habr.com/ru/post/1720705/


All Articles