Remote tracking of the current branch in Git

I transfer my continuous testing to a dedicated server (autotest slows down my local laptop too much). I would like my test server (which runs CruiseControl.rb) to constantly receive my latest (committed) changes using Git - ideally without any changes to my own workflow. I am the only developer working on this project.

Before receiving the test server, I had:

  • My laptop as my main development system
  • Several branches in my local repository.
  • A local working copy pointing to one of the branches. I often switch between branches (usually for new features).
  • GitHub account, which I often click local branches on mirrored remote branches. (This is mainly used for backups on a remote server, I am not sharing the code for my current project). I try to push GitHub at least towards the end of every workday, although sometimes I forget it.

I want to keep all this unchanged. In addition, I now have:

  • Test server
  • ... launch CruiseControl.rb
  • Clone of my laptop repository on my test server. (He does not currently clone GitHub)
  • Local working copy on the test server from which CC builds / tests.
  • This working copy points to one specific Git branch (of course)

, , , . ( ).

, :

  • git checkout origin/HEAD: , CruiseControl, "" .
  • git checkout --track -b a_branch origin/a_branch: , CC , . .
  • git checkout --track -b my_testing_branch origin/HEAD: , , . origin/HEAD HEAD "default", .

( Git), ?

+3
6

- hook, . , post-commit, , . , , , .

+3

, .
(. git merge -s ours, " .

CI :

 $ git fetch laptopRepo
 $ git checkout -b testingBranch laptopRepo/testingBranch

, .

+1

, -...

git remote show origin, , . ,

$ git remote show origin
* remote origin
  Fetch URL: blade:/var/scratch/code
  Push  URL: blade:/var/scratch/code
  HEAD branch: foo
  Remote branches:
    foo tracked
    bar tracked
    qux tracked

, foo.

, , , , (, - ). ,

$ b=$(git remote show origin | grep "HEAD branch" | awk -F: '{print $2}')
$ echo $b
foo

, origin/foo origin/HEAD ( ), CruiseControl , , , hard- reset :

$ b=$(git remote show origin | grep "HEAD branch" | awk -F: '{print $2}')
$ git reset --hard origin/$b

: , HEAD , . , rebase HEAD . HEAD , .

+1

, , . , , , .

:

git remote add testing <url of testing server>

, , push:

git push -f testing HEAD:master

, . -f , , ; - .

, CruiseControl . , ( CC ).

, commit + push script ; . - ( ), .

+1

GitHub host and use post-recieve hooks . The way services like Devver and RunCodeRun do it.

+1
source

I looked at the git missed past and moved to the / NFS / rsync shared folder solution, but it has one serious problem: it does not start / is not limited to commits, so I get false positive broken assemblies while I am in the middle of typing something.

0
source

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


All Articles