-
Notifications
You must be signed in to change notification settings - Fork 0
/
mynote.txt
76 lines (44 loc) · 1.9 KB
/
mynote.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Git Branching
o List branch
git branch
The branch that's marked with "*" is the current one
o Create a production branch
git branch production
o To switch to a specific branch
git checkout [target branch]
o Merge into a branch
To merge current branch into a targeting (e.g., merge master into production):
git checkout production
git pull origin production # to get latest from remote
git merge master
o Push a branch to remote server
git push origin prodution
o Delete a branch from local repo:
git branch -D production
o Delete a brach from a remote server (e.g., delete production branch from GitHub)
git push origin production
Capstrano setting
set :repository, "[email protected]:vanpelt/rails-app.git" # Your clone URL
set :scm, "git"
set :branch, "production" (older version: set :branch, "origin/production")
Using capistrano to deploy from different git branches
you could structure it from the command line where you have a default branch and environment and also you are able to pass parameters to the cap call which could include the environment and the branch to use. This could be a branch that is explicitly passed or you could have a parameter which would indicate current branch as described in the link you listed.
#call with cap -S env="<env>" branch="<branchname>" deploy
...
# Prevents error if not parameter passed, assumes that default 'cap deploy' command
# and should deploy the master branch to the production server
set(:env, ‘production’) unless exists?(:env)
set(:branch, ‘master’) unless exists?(:branch)
if !env.nil? && env == "production"
role :web, "production_ip_address"
else # add more as needed
role :web, "development_ip_address"
end
if !branch.nil? && branch == "current"
set :branch, $1 if `git branch` =~ /\* (\S+)\s/m
elsif !branch.nil?
set :branch, branch
else # add more as needed
set :branch, "master"
end
...