Git Bash - Git 显示分支是最新的,而实际上它们不是
Git Bash - Git is showing branches as being up to date when they actually aren't
我有两个本地分支,main 和 dev。当我尝试将更改从 dev 提交并推送到 main 时,它说一切都是最新的,实际上什么也没有发生。此外,我的 github 存储库没有反映我本地存储库中的最新更改,即使我已经尝试将其向上推送并且它说它成功了。提交未显示在我的新存储库中。
当我键入“git remote show origin”时,这是输出:
$ git remote show origin
* remote origin
Fetch URL: <myRepo'sURL>
Push URL: <myRepo'sURL>
HEAD branch: main
Remote branches:
dev tracked
main tracked
Local branch configured for 'git pull':
main merges with remote main
Local refs configured for 'git push':
dev pushes to dev (fast-forwardable)
main pushes to main (up to date)
我是 git 的新手,所以边走边学。有人知道我为什么会遇到这个问题吗?如果需要,我可以 运行 其他命令来提供更多信息
要推送更改,这是我遵循的过程:
首先,git状态。输出是这样的:
On branch dev
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: __pycache__/app.cpython-39.pyc
modified: app.py
no changes added to commit (use "git add" and/or "git commit -a")
然后,我运行“git添加。”此命令没有输出。
接下来,“git commit -m “test”。这是输出:
$ git commit -m "test"
[dev 5af52ce] test
2 files changed, 4 insertions(+), 8 deletions(-)
最后,“git push origin main”。这是输出:
$ git push origin dev
Enumerating objects: 20, done.
Counting objects: 100% (20/20), done.
Delta compression using up to 16 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (16/16), 1.77 KiB | 1.77 MiB/s, done.
Total 16 (delta 10), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (10/10), completed with 3 local objects.
To <myRepo'sURL>
0f1504d..5af52ce dev -> dev
谢谢!
When I try commiting and pushing changes from dev to main,
您正在做的是从 dev
推到 origin/dev
。
由于远程存储库显示默认分支 main
,您不会“看到”任何明显的更改(您需要切换到网页中的 dev 分支才能看到您的提交)。
可以在本地合并dev到main,然后push main:
git switch main
git merge dev
git push
我有两个本地分支,main 和 dev。当我尝试将更改从 dev 提交并推送到 main 时,它说一切都是最新的,实际上什么也没有发生。此外,我的 github 存储库没有反映我本地存储库中的最新更改,即使我已经尝试将其向上推送并且它说它成功了。提交未显示在我的新存储库中。
当我键入“git remote show origin”时,这是输出:
$ git remote show origin
* remote origin
Fetch URL: <myRepo'sURL>
Push URL: <myRepo'sURL>
HEAD branch: main
Remote branches:
dev tracked
main tracked
Local branch configured for 'git pull':
main merges with remote main
Local refs configured for 'git push':
dev pushes to dev (fast-forwardable)
main pushes to main (up to date)
我是 git 的新手,所以边走边学。有人知道我为什么会遇到这个问题吗?如果需要,我可以 运行 其他命令来提供更多信息
要推送更改,这是我遵循的过程:
首先,git状态。输出是这样的:
On branch dev
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: __pycache__/app.cpython-39.pyc
modified: app.py
no changes added to commit (use "git add" and/or "git commit -a")
然后,我运行“git添加。”此命令没有输出。
接下来,“git commit -m “test”。这是输出:
$ git commit -m "test"
[dev 5af52ce] test
2 files changed, 4 insertions(+), 8 deletions(-)
最后,“git push origin main”。这是输出:
$ git push origin dev
Enumerating objects: 20, done.
Counting objects: 100% (20/20), done.
Delta compression using up to 16 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (16/16), 1.77 KiB | 1.77 MiB/s, done.
Total 16 (delta 10), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (10/10), completed with 3 local objects.
To <myRepo'sURL>
0f1504d..5af52ce dev -> dev
谢谢!
When I try commiting and pushing changes from dev to main,
您正在做的是从 dev
推到 origin/dev
。
由于远程存储库显示默认分支 main
,您不会“看到”任何明显的更改(您需要切换到网页中的 dev 分支才能看到您的提交)。
可以在本地合并dev到main,然后push main:
git switch main
git merge dev
git push