社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Git

如果在提交和推送之后完成签出和合并,则Git不会将更改推送到分支

Joel G Mathew • 5 年前 • 1454 次点击  

我有一个django应用程序,我在alpha分支的localhost上工作,并以间歇的间隔合并到master。我有下面的场景。我已经在alpha中完成了几个提交,并上传到git repo,如下所示:

$ git status
On branch alpha
Your branch is up to date with 'origin/alpha'.

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:   clinic/__pycache__/views.cpython-36.pyc
    modified:   clinic/views.py

no changes added to commit (use "git add" and/or "git commit -a")

joel@hp:~/myrepo$ git commit -a
[alpha e16bb180] Fixed an issue in checking for clinic membership. There was no check for if the user was not authenticated
2 files changed, 6 insertions(+)

joel@hp:~/myrepo$ git push
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.46 KiB | 1.46 MiB/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: 
remote: Create pull request for alpha:
remote:   https://bitbucket.org/myrepo
remote: 
To bitbucket.org:user/myrepo.git
33ac1a63..e16bb180  alpha -> alpha

我现在决定这个主要的错误修复需要与主同步。所以我要:

joel@hp:~/myrepo$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
joel@hp:~/myrepo$ git merge alpha
Updating 7b0f27ad..e16bb180
Fast-forward
appointments/__pycache__/models.cpython-36.pyc                             | Bin 26755 -> 26755 bytes
appointments/__pycache__/views.cpython-36.pyc                              | Bin 53867 -> 53867 bytes
appointments/migrations/__pycache__/0058_auto_20181122_2143.cpython-36.pyc | Bin 613 -> 613 bytes
appointments/templates/site/test.html                                      |  11 +++++++++++
clinic/__pycache__/urls.cpython-36.pyc                                     | Bin 9875 -> 9875 bytes
clinic/__pycache__/views.cpython-36.pyc                                    | Bin 156447 -> 156597 bytes
clinic/templatetags/__pycache__/__init__.cpython-36.pyc                    | Bin 140 -> 140 bytes
clinic/templatetags/__pycache__/customtags.cpython-36.pyc                  | Bin 1246 -> 1246 bytes
clinic/views.py                                                            |   6 ++++++
myrepo/__pycache__/settings.cpython-36.pyc                         | Bin 4541 -> 4541 bytes
myrepo/settings.py                                                 |   2 +-
11 files changed, 18 insertions(+), 1 deletion(-)
create mode 100644 appointments/templates/site/test.html
joel@hp:~/myrepo$ git push
Total 0 (delta 0), reused 0 (delta 0)
To bitbucket.org:user/myrepo.git
7b0f27ad..e16bb180  master -> master

所以我需要把它推到远程,这样我的web服务器上的项目就同步了。

joel@hp:~/myrepo$ git push
Total 0 (delta 0), reused 0 (delta 0)
To bitbucket.org:user/myrepo.git
7b0f27ad..e16bb180  master -> master

看来,我对master的重大改变并没有被推到git回购中心。

在我的项目服务器上检查:

root@myopip:/home/joel/myappointments# git checkout alpha
Switched to branch 'alpha'
Your branch is behind 'origin/alpha' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
root@myopip:/home/joel/myappointments# git pull
Updating 33ac1a63..e16bb180
Fast-forward
clinic/__pycache__/views.cpython-36.pyc | Bin 156447 -> 156597 bytes
clinic/views.py                         |   6 ++++++
2 files changed, 6 insertions(+)
root@myopip:/home/joel/myappointments# git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
root@myopip:/home/joel/myappointments# git pull
Already up to date.

因此,虽然本地主机上的master有一个重要的错误修复程序,但它不会更新到远程服务器。 我怎样才能避免这个?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49997
 
1454 次点击  
文章 [ 1 ]  |  最新文章 5 年前
VonC
Reply   •   1 楼
VonC    6 年前

检查这些提交之间更改的文件列表:

git diff <a commit sha1>...<b commit sha2> --name-only # b is after a in time

推的时候都是: git diff 7b0f27ad..e16bb180 --name-only 当你收回第二份回购协议时: git diff 33ac1a63..e16bb180 --name-only

这将显示您是否推送了正确的文件列表(您可以删除 --name-only 检查实际变化)