标签:change deletion script select soft web app one git pull
git checkout 3.5-bugfix——拉取最新代码git pull——创建、切换到自己任务分支git checkout -b T000001——存到暂存区git stash——切换到提交分支,拉取最新代码——切回任务分支git checkout ——将提交分子最新代分支并到当前任务分支git merge 3.5-bugfix——取出暂存代码git stash pop检查错误——推送git push origin
写代码之前,一定要先pull拉取最新代码
zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (develop)
$ git pull
然后切换到需要操作的任务分支(比如3.6-fixbug
)
zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (develop)
$ git checkout 3.6-bugfix
M kthrp_base/views/kthrp_calendar_view.xml
M kthrp_stock/__init__.py
Branch 3.6-bugfix set up to track remote branch 3.6-bugfix from origin.
Switched to a new branch ‘3.6-bugfix‘
再pull一下代码
zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (3.5-bugfix)
$ git pull
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 12 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (12/12), done.
From http://61.183.163.210:81/kthrp/kthrp
7ab182a..9ca22ac 3.6-bugfix -> origin/3.6-bugfix
91742d9..96576ed develop -> origin/develop
Already up-to-date.
然后创建自己的分支进行代码操作(分支名T000001
)
$ git checkout -b T000001
Switched to a new branch ‘T000001‘
查看代码修改的状态
zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (T000001)
$ git status
On branch T000001
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
?
modified: kthrp_account/models/account_account.py
?
Untracked files:
(use "git add <file>..." to include in what will be committed)
?
todo_app/
todo_calendar/
todo_kanban/
todo_report/
todo_ui/
todo_user/
todo_wizard/
?
no changes added to commit (use "git add" and/or "git commit -a")
查看具体的哪些代码被修改了
zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (T000001)
$ git diff
diff --git a/kthrp_account/models/account_account.py b/kthrp_account/models/account_account.py
index 348afda..298d926 100644
--- a/kthrp_account/models/account_account.py
+++ b/kthrp_account/models/account_account.py
@@ -15,6 +15,10 @@ class KthrpAccountAuxiliaryType(models.Model):
_name = "kthrp.account.auxiliary.type"
_description = "Kthrp Account Auxiliary Type"
?
+
+
+
+
name = fields.Char(‘Type‘,required=True,translate=True)
code = fields.Char(‘Type Code‘,required=True)
?
代码操作完毕以后,将代码放置暂存区
zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (T000001)
$ git stash
Saved working directory and index state WIP on T000001: 634c424 Merge branch ‘T5986‘ into ‘3.5-bugfix‘
HEAD is now at 634c424 Merge branch ‘T5986‘ into ‘3.5-bugfix‘
回到任务分支
zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (T000001)
$ git checkout 3.5-bugfix
Switched to branch ‘3.5-bugfix‘
Your branch is up-to-date with ‘origin/3.5-bugfix‘.
git pull
拉取最新代码
再回到自己的分支
合并代码
zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (T000001)
$ git merge 3.5-bugfix
Already up-to-date.
取出暂存区的代码
zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (T000001)
$ git stash pop
On branch T000001
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
?
modified: kthrp_account/models/account_account.py
?
Untracked files:
(use "git add <file>..." to include in what will be committed)
?
todo_app/
todo_calendar/
todo_kanban/
todo_report/
todo_ui/
todo_user/
todo_wizard/
?
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (2e5565e706d17151b0af49d1e71500d812e7af3b)
再提交add
,commit
再push origin接自己的分支号
推送代码
在GitLab上完成提交后,到docker中pull,再重启服务
服务器内网$ ssh kthrp@192.168.1.15
外网zrq@DESKTOP-M2UFP96 MINGW64 ~/Projects/odoo/kthrp (3.5-bugfix) $ ssh kthrp@61.183.163.210 -p 115
最新的develop是12分支,集测对应的是15,现在3.6代发布版本都是15
当代码提交完成,再GitLab上获得肯定以后,登陆docker
ssh kthrp@192.168.1.12
然后输入自己的GitLab的账号和密码,然后拉取代码git pull
在确认可以重启以后,输入命令
docker-compose restart 对应的模块(例如kthrp)
操作就完成了
Administrator@B4NPUC4JH2DPWW6 MINGW64 ~/project/odoo/kthrp (develop)
$ ssh kthrp@192.168.1.12
The authenticity of host ‘192.168.1.12 (192.168.1.12)‘ can‘t be established.
ECDSA key fingerprint is SHA256:kvHOdtxtddI+92HWo1VvxP9SS6JtG7ZNOSeLQ/s5b5c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.1.12‘ (ECDSA) to the list of known hosts.
kthrp@192.168.1.12‘s password:
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-139-generic x86_64)
?
* Documentation: https://help.ubuntu.com/
?
172 packages can be updated.
0 updates are security updates.
?
?
Last login: Mon Aug 5 17:29:28 2019 from 192.168.1.1
warning: unable to access ‘/home/kthrp/.config/git/attributes‘: Permission denied
warning: unable to access ‘/home/kthrp/.config/git/ignore‘: Permission denied
On branch develop
Your branch is up-to-date with ‘origin/develop‘.
nothing to commit, working directory clean
kthrp@kthrp:/u01/kthrp/code/kthrp$ git pull
Username for ‘http://192.168.1.9‘: wangjianhang
Password for ‘http://wangjianhang@192.168.1.9‘:
remote: Counting objects: 2, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From http://192.168.1.9/kthrp/kthrp
c9e0e88..d33485d develop -> origin/develop
Updating c9e0e88..d33485d
warning: unable to access ‘/home/kthrp/.config/git/ignore‘: Permission denied
warning: unable to access ‘/home/kthrp/.config/git/attributes‘: Permission denied
Fast-forward
warning: unable to access ‘/home/kthrp/.config/git/attributes‘: Permission denied
kthrp_hr/models/employee.py | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
kthrp@kthrp:/u01/kthrp/code/kthrp$ docker-compose restart kthrp
Restarting kthrp_kthrp_1 ... done
kthrp@kthrp:/u01/kthrp/code/kthrp$ exit
logout
Connection to 192.168.1.12 closed.
?
如果操作涉及到数据库的改变,则需要升级相应模块,升级数据库。
15的环境,要在http://61.183.163.210:85/web/database/selector的SIT里面升级,12再:83里面升级
git log
找到你commit的位置,找到相应位置下方的任务号
git reset --soft 任务号
就可以回退push操作,到add后,待commit阶段
这时候使用命令
git status
可以看到你已经add的文件,如果需要再修改add之外的文件,直接更改代码,再add,commit,push就行,但是如果你需要更改已经add了的内容的话,使用命令:(撤销add操作)
git reset HEAD 对应的文件名
这时候已经add的绿色的文件就会变成红色(待add阶段),你就可以修改内容了。
最后add,commit,push的时候会提示版本冲突,需要在push的命令后面添加-f(覆盖之前的提交请求)
git push origin 任务分支 -f
git fetch
标签:change deletion script select soft web app one git pull
原文地址:https://www.cnblogs.com/pywjh/p/12907668.html