gpt4 book ai didi

Git 起源在头后面

转载 作者:太空狗 更新时间:2023-10-29 14:35:18 25 4
gpt4 key购买 nike

我在我的点文件的 git 存储库上有两个分支,masterkimura 以及 GitLab 上的远程设置。如果我检查任一分支和 git push 我被告知我是最新的...

$ git checkout master
Already on 'master'
$ git push
Everything up-to-date
$ git checkout kimura
Switched to branch 'kimura'
$ git push
Everything up-to-date

我已经对分支 kimura 进行了更改,并提交并 merge 了 pull-requests 到 master,然后使用...将 kimura 与 master merge

$ git checkout kimura
Switched to branch 'kimura'
$ git merge origin/master
Already up to date.

但是我有电力线提示(在 ZSH 下)并且都显示我已经提交等待被推送并且当我查看历史时它显示两个分支的 origin 都在 ...

*   ef61530 - (HEAD -> kimura) Resolving conflict to merge master into kimura (2019-01-26) <slackline>
|\
| * 1ece19c - (origin/master) Reinstated sourcing of virtualenvwrapper.sh on work host (2019-01-18) <slackline>
| * 80efc48 - Merge branch 'kimura' into 'master' (2018-12-17) <nshephard>
| |\
* | | f32a089 - tweaking virtualenvwrapper.sh path for new host (2019-01-24) <slackline>
* | | d2ccb42 - Tweaking specifics for work machine. (2019-01-24) <slackline>
* | | 13fc696 - Updates to a few files (2019-01-24) <slackline>
* | | a453190 - Added gnupg to link section (2019-01-23) <slackline>
* | | c7da4ac - Added todo task and display of warnings at end of setup (2019-01-23) <slackline>
* | | 07f313b - Added gnupg (2019-01-23) <slackline>
* | | 20cf7f8 - Copying sample code from James (2019-01-23) <slackline>
* | | 4edf7b5 - updated path for /mnt/personal (2019-01-12) <slackline>
* | | 0b61635 - adding work_laptop profile (2018-12-19) <slackline>
* | | 71c7d3f - Adding config/.config/.pycodestyle (2018-12-18) <slackline>
| |/
|/|
* | 8ac383a - (origin/kimura) Starting off yapf config (2018-12-17) <slackline>
|/
* 3d6aac6 - Merge branch 'master' of gitlab.com:nshephard/dotfiles into kimura (2018-12-10) <slackline>

我不确定如何让任一分支上的 originHEAD 保持一致,如果有任何建议/指点,我将不胜感激。

编辑:

根据@Tim Biegeleisen 的建议,我尝试了以下...

$ git fetch origin
From gitlab.com:nshephard/dotfiles
* branch master -> FETCH_HEAD
$ git checkout kimura
Switched to branch 'kimura'
$ git merge origin/master
Already up to date.

然后我尝试将 kimura 分支直接与 master merge ...

$ git checkout origin/master                                                                                                                                                                                                                                                                           
error: Your local changes to the following files would be overwritten by checkout:
gnupg/.gnupg/random_seed
Please commit your changes or stash them before you switch branches.
Aborting
$ git stash
Saved working directory and index state WIP on kimura: 8464bcc Merge

将'kimura'分支为'master'

$ git checkout origin/master                                                                                                                                                                                                                                                                           
Note: checking out 'origin/master'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again.
Example:

git checkout -b <new-branch-name>

HEAD is now at 1ece19c Reinstated sourcing of virtualenvwrapper.sh on work host

...并且在分支 master origin 仍然不是最新的 HEAD 因为我现在处于分离状态已经回到origin 并且有尚未 merge 的提交...

* 1ece19c - (HEAD, origin/master) Reinstated sourcing of virtualenvwrapper.sh on work host (Fri Jan 18 10:52:17 2019 +0000) <Neil Shephard>
* 80efc48 - Merge branch 'kimura' into 'master' (Mon Dec 17 18:10:50 2018 +0000) <nshephard>
|\
| * 8ac383a - (origin/kimura) Starting off yapf config (Mon Dec 17 17:15:42 2018 +0000) <slackline>
|/
* 3d6aac6 - Merge branch 'master' of gitlab.com:nshephard/dotfiles into kimura (Mon Dec 10 10:41:47 2018 +0000) <slackline>
|\
| * 2e0a40e - Resolving conflicts in zsh/.zshrc (Mon Dec 10 10:35:45 2018 +0000) <Neil Shephard>
| |\
| | * 1b0a018 - Merge branch 'kimura' into 'master' (Thu Dec 6 10:22:25 2018 +0000) <nshephard>
| | |\
| * | | a6f3350 - Removing line that calls virtualenvwrapper on work computer (Mon Dec 10 10:32:47 2018 +0000) <Neil Shephard>
| |/ /
| * | fefb0b0 - Commenting out $PATH (Mon Dec 3 13:38:33 2018 +0000) <Neil Shephard>
| * | 2597385 - Merge branch 'kimura' into 'master' (Wed Nov 14 09:57:56 2018 +0000) <nshephard>
| |\ \
* | | | 69d1599 - Added port forwarding for mongodb to ds1 config (Fri Dec 7 10:33:52 2018 +0000) <slackline>
| |_|/
|/| |

...关于如何 merge 所有内容并使 originHEAD 内联,我再次感到困惑。

编辑 2:

根据@torek 的要求...

$ git rev-parse --abbrev-ref master@{upstream}
fatal: upstream branch 'refs/heads/master' not stored as a remote-tracking branch

我的 git 配置看起来像...

user.email=xxxxx@gmail.com
user.name=slackline
push.default=simple
credential.helper=cache
pack.window=0
pack.windowmemory=100m
pack.packsizelimit=100m
pack.threads=1
color.ui=auto
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@gitlab.com:nshephard/dotfiles.git
remote.origin.pushurl=git@gitlab.com:nshephard/dotfiles.git
remote.origin.push=+refs/heads/*:refs/heads/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.master.pushremote=origin
submodule.tmux/.tmux/plugins/tpm.url=https://github.com/tmux-plugins/tpm
submodule.tmux/.tmux/plugins/tpm.active=true
submodule.oh-my-zsh/.oh-my-zsh.url=https://github.com/robbyrussell/oh-my-zsh
submodule.oh-my-zsh/.oh-my-zsh.active=true
submodule.emacs/emacs.url=git@gitlab.com:nshephard/emacs.git
submodule.emacs/emacs.active=true
submodule.emacs/.emacs.d.url=git@gitlab.com:nshephard/emacs.git
submodule.emacs/.emacs.d.active=true
submodule.fonts.url=https://github.com/powerline/fonts
submodule.fonts.active=true
branch.kimura.remote=origin
branch.kimura.merge=refs/heads/kimura
branch.kimura.fetch=+refs/heads/*:refs/heads/*

当前日志/图表看起来像...

*   564630f - (HEAD -> kimura, master) Merge branch 'kimura' into 'master' (Mon Jan 28 16:01:30 2019 +0000) <nshephard>
|\
| * c6c75ba - Updating to use RSA keys as seahorse doesn't like ed25519 keys (Mon Jan 28 16:00:35 2019 +0000) <slackline>
|/
* 8464bcc - Merge branch 'kimura' into 'master' (Sat Jan 26 09:32:05 2019 +0000) <nshephard>
|\
| * ef61530 - Resolving conflict to merge master into kimura (Sat Jan 26 09:30:54 2019 +0000) <slackline>
| |\
| | * 1ece19c - (origin/master) Reinstated sourcing of virtualenvwrapper.sh on work host (Fri Jan 18 10:52:17 2019 +0000) <Neil Shephard>
| | * 80efc48 - Merge branch 'kimura' into 'master' (Mon Dec 17 18:10:50 2018 +0000) <nshephard>
| | |\
* | | \ 6138abc - Merge branch 'kimura' into 'master' (Thu Jan 24 11:39:35 2019 +0000) <nshephard>
|\ \ \ \
| |/ / /
| * | | f32a089 - tweaking virtualenvwrapper.sh path for new host (Thu Jan 24 11:39:04 2019 +0000) <slackline>
| * | | d2ccb42 - Tweaking specifics for work machine. (Thu Jan 24 11:37:48 2019 +0000) <slackline>
| * | | 13fc696 - Updates to a few files (Thu Jan 24 07:09:41 2019 +0000) <slackline>
| * | | a453190 - Added gnupg to link section (Wed Jan 23 13:08:29 2019 +0000) <slackline>
| * | | c7da4ac - Added todo task and display of warnings at end of setup (Wed Jan 23 11:01:08 2019 +0000) <slackline>
| * | | 07f313b - Added gnupg (Wed Jan 23 10:58:22 2019 +0000) <slackline>
| * | | 20cf7f8 - Copying sample code from James Ridgway https://github.com/jamesridgway/dotfiles/blob/master/setup (Wed Jan 23 10:57:32 2019 +0000) <slackline>
| * | | 4edf7b5 - updated path for /mnt/personal (Sat Jan 12 07:55:45 2019 +0000) <slackline>
| * | | 0b61635 - adding work_laptop profile (Wed Dec 19 12:34:16 2018 +0000) <slackline>
| * | | 71c7d3f - Adding config/.config/.pycodestyle (Tue Dec 18 16:32:52 2018 +0000) <slackline>
| | |/
| |/|
| * | 8ac383a - (origin/kimura) Starting off yapf config (Mon Dec 17 17:15:42 2018 +0000) <slackline>
| |/
| * 3d6aac6 - Merge branch 'master' of gitlab.com:nshephard/dotfiles into kimura (Mon Dec 10 10:41:47 2018 +0000) <slackline>

最佳答案

我从未见过您执行 git fetchgit pull,所以很可能您的本地分支与远程分支不同步。以下应该有效:

git fetch origin
git checkout kimura
git merge origin/master

git fetch 调用应该使用来自远程的最新更改更新您的本地跟踪分支 origin/master。你也可以直接与 master merge ,假设你已经 pull 了那个分支:

git checkout master
git pull origin master
git checkout kimura
git merge master

关于Git 起源在头后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54400086/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com