我有兩個本地分支,main和dev。當我嘗試提交并將更改從 dev 推送到 main 時,它說一切都是最新的,實際上什么也沒發生。此外,我的 github repo 沒有反映我本地 repo 中的最新更改,即使我嘗試將其推高并且它說它成功了。提交沒有顯示在我的新倉庫中。
當我輸入“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 add”。此命令沒有輸出。
接下來,"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
謝謝!
uj5u.com熱心網友回復:
當我嘗試提交并將更改從 dev 推送到 main 時,
您正在做的是從dev到推送origin/dev。
并且由于遠程存盤庫顯示默認分支main,因此您不會“看到”任何明顯的更改(您需要切換到網頁中的 dev 分支才能看到您的提交)。
您可以將 dev 本地合并到 main,然后推送 main:
git switch main
git merge dev
git push
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/378157.html
下一篇:在本地洗掉gitblob
