-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit_cmd.txt
109 lines (89 loc) · 3.23 KB
/
git_cmd.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
git config receive.denyCurrentBranch ignore
1、创建秘钥对,生成到默认的~/.ssh/ 目录下:
ssh-keygen -t rsa -b 4096 -C "[email protected]"
2、创建ssh配置文件:
vi ~/.ssh/config
添加以下内容:
Host cl1
HostName 192.168.0.252
User weihu
Port 1604
IdentityFile ~/.ssh/id_rsa
Host cl2
HostName 192.168.0.253
User weihu
Port 1604
IdentityFile ~/.ssh/id_rsa
3、把公钥拷贝到其它服务器:
cat ~/.ssh/id_rsa.pub | ssh cl1 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'
cat ~/.ssh/id_rsa.pub | ssh cl2 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'
P.S.第一次拷贝时需输入weihu用户的密码,后面直接ssh cl1 or ssh cl2就登陆到后面两台服务器去了(不再用密码)
git remote set-url origin [email protected]:gitolite-admin
cat ~/.ssh/id_rsa.pub | ssh cl0 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'
sudo rm -rf /var/lib/apt/lists/*
git config --local receive.denyCurrentBranch ignore
find ~ -type f -size +2G
/Users/piao/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/log/docker.log
git stash
git pull
git stash pop
# if conflict on pop:如果有冲突文件,这时会显示出来,然后checkout这些冲突文件的本地版本就行了
git checkout --theirs -- conflict.file
git pull -X ours
//git ls-files -i --exclude-from=.gitignore | xargs git rm --cached
git rm -r --cached . or git rm --cached file1 file2 dir/file3
git add .
git commit -m "Removing all files in .gitignore"
ssh-add ~/.ssh/git
cp git ~/.ssh/id_rsa
git clone ssh://[email protected]:1604/fg_data/git_repo/2016-06-22-tag.git
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected] -p 1604
cd .git/hooks
vi post-receive 放入如下命令:
#!/bin/sh
cd ..
env -i git reset --hard
//and then
chmod +x post-receive
https://www.digitalocean.com/community/tutorials/how-to-use-git-hooks-to-automate-development-and-deployment-tasks
find ~ -type f -size +2G
git fetch --all; git branch -vv
https://git-scm.com/book/ch3-5.html
git push origin --delete serverfix
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/novice79
ssh-add ~/.ssh/id_rsa
//git deploy code
//in porduction serverfix
mkdir -p /data/git_repo/mch && cd /data/git_repo/mch
git init --bare
vi hooks/post-receive
chmod +x hooks/post-receive
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Master ref received. Deploying master branch to production..."
git --work-tree=/data/apps/mch --git-dir=/data/git_repo/mch_mgr checkout -f
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
//and in client
git clone ssh://[email protected]:1611/data/git_repo/mch_mgr
//add files && commit && push
git clone ssh://[email protected]:1604/gitolite-admin
//gitolite
sudo adduser --system --shell /bin/bash --group --disabled-password --home /home/git git
sudo apt-get install gitolite3
scp ~/.ssh/id_rsa.pub [email protected]:/home/david
sudo su - git
gitolite setup -pk /home/david/*.pub
ssh git@hostname info
ssh-keygen -t rsa
git fetch --all
Then, you have two options:
git reset --hard origin/master
OR If you are on some other branch:
git reset --hard origin/<branch_name>