我想在路径中添加一个带有变量的子模块,以便每个人都可以使用相同的 .gitmodules。
即...git submodule add $USER/pub/repo.git我不希望 $USER 在 .gitmodules 内扩展。我尝试过git submodule add '$USER/pub/repo.git',但找不到存储库。当尝试使用环境变量添加远程时,我看到了相同的行为。
我使用的存储库既存在于 github 上,又存在于内部 gitlab 上。我设置了两个遥控器:origin(github) 和gitlab.
我如何轻松地与master两个遥控器的分支进行交互?
我尝试过的:
git checkout --track gitlab/master-> 错误:A branch named 'master' already exists.git checkout -b master-gitlab --track gitlab/master-> 工作了,我现在有一个本地分支master-gitlab,控制台输出告诉我:master-gitlab set up to track remote branch master from gitlab.-> 完美,这就是我想要的!git push gitlab master-gitlab-> 这会在远程创建一个新的远程分支 ,这不是我想要的,并且与上一个命令的输出不一致。master-gitlabgitlabgit push gitlab master-gitlab:master推送master-gitlab操作。但我总是忘记如何做到这一点,而且不是很直观。mastergitlab有没有更简单的方法来跟踪master不同遥控器的分支并推送到它?
这是一个 git-bug 吗?它首先 (3) 告诉我跟踪master并随后在推送时创建一个新分支?
我正在使用 raspberrypi 终端,在窗口中使用 vnc 查看器,并且我正在尝试克隆 Git 存储库。但我不断收到此错误消息。
ssh: Could not resolve hostname github.com: Temporary failure in name resolution fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我一整天都在尝试解决这个错误,但我仍然无法解决这个错误。如果知道这个问题的解决方案,那就太好了。谢谢
Git 非分支引用(不是分支、标签、远程和注释)在本地计算机中工作得很好,但我在将它们推送到远程时遇到了麻烦:
$ git update-ref refs/exp/ee01 6a534fb5f9aad615ebeeb9d01ebe558a679a3cd1
Run Code Online (Sandbox Code Playgroud)
就创建成功了:
$ cat .git/refs/exp/ee01
6a534fb5f9aad615ebeeb9d01ebe558a679a3cd1
$ git for-each-ref refs/exp
6a534fb5f9aad615ebeeb9d01ebe558a679a3cd1 commit refs/exp/ee01
Run Code Online (Sandbox Code Playgroud)
推动它:
$ git push origin exp/ee01
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/dmpetrov/example-get-started-exp.git
* [new branch] refs/exp/ee01 -> refs/exp/ee01
Run Code Online (Sandbox Code Playgroud)
但是,当我克隆此存储库时,我没有看到它:
$ git clone https://github.com/dmpetrov/example-get-started-exp.git
$ cd example-get-started-exp/
$ git for-each-ref refs/exp # it returns nothing
Run Code Online (Sandbox Code Playgroud)
如何正确推送非分支引用?
编辑:我可以通过名称将其获取到 FETCH_HEAD。理想情况下,我应该在不提前知道名称的情况下查看\获取所有新参考文献。
$ git fetch origin exp/ee01
From https://github.com/dmpetrov/example-get-started-exp
* branch refs/exp/ee01 -> FETCH_HEAD
Run Code Online (Sandbox Code Playgroud) 我在 Github CLI 第一个版本发布后就开始使用它,这是一个很棒的工具。我一直在从事一个项目,该项目需要远程位于不同的地方,例如在两个存储库中。我可以添加另一个遥控器来推送更改,但 gh 只能控制第一个遥控器。例如,gh pr status具有两个或多个遥控器的存储库中的命令将仅显示原始遥控器的数据。我如何在遥控器之间切换以查看每个遥控器上的所有操作,例如问题和公关?
这里是超级基本问题,但我找不到有同样问题的论坛。我正在尝试将本地 git 存储库从 HTTPS 切换到 SSH,但是当我按照记录的步骤操作时:
$ git remote -v
> origin https://github.com/USERNAME/REPOSITORY.git (fetch)
> origin https://github.com/USERNAME/REPOSITORY.git (push)
$ git remote set-url origin git@github.com:USERNAME/REPOSITORY.git
$ git remote -v
> origin git@github.com:USERNAME/REPOSITORY.git (fetch)
> origin git@github.com:USERNAME/REPOSITORY.git (push)
Run Code Online (Sandbox Code Playgroud)
这对我来说是这样的:
E:\Example>git remote -v
origin https://github.com/Kornosky/RotaryAnimation.git (fetch)
origin https://github.com/Kornosky/RotaryAnimation.git (push)
E:\Example>git remote set-url origin git@github.com:Kornosky/RotaryAnimation.git
E:\Example>git remote -v
origin https://github.com/Kornosky/RotaryAnimation.git (fetch)
origin https://github.com/Kornosky/RotaryAnimation.git (push)
Run Code Online (Sandbox Code Playgroud)
无论我运行什么命令,我都无法将其更改为 SSH。此外,我已经从 git config 文件中删除了所有信息,并且运行了此命令以及许多类似的命令:
git config --global url.ssh://git@github.com/.insteadOf https://github.com/
Run Code Online (Sandbox Code Playgroud)
有什么建议么?我一直在用这个把头发拔出来。最终目标是解决我的推送挂起的问题。我尝试通过更改 HTTPS 设置来进行诊断,但没有成功推送我的文件(没有文件甚至接近 100MB 的单个文件限制)。
编辑:即使我尝试创建新的存储库,我似乎也无法切换到 SSH。也许这可能是一个帐户设置?
在 Visual Studio 代码中
我为此花费了更多时间,我正在尝试将来自第一个帐户 github 的已删除项目推送到 新的另一个帐户中的现有存储库中,但我收到如下错误:
$ git push -u origin main
remote: Permission to username/project_name.git denied to first_account_username.
fatal: unable to access 'https://github.com/user_name/project_name.git/': The requested URL returned error: 403
Run Code Online (Sandbox Code Playgroud)
我尝试使用这些命令行将现有存储库推送到新帐户中,请让我知道我错过了什么?
git remote add origin https://github.com/user_name/project_name.git
git branch -M main
git push -u origin main
Run Code Online (Sandbox Code Playgroud) 我确信这是一个非常简单的解决方案,但我不确定为什么我推送到GitHub失败了.
现在它看起来像:
$ git push origin master
To git@github.com:user_name/project_name.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:user_name/project_name.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
和:
$ git remote show origin
* remote origin
Fetch URL: git@github.com:user_name/project_name.git
Push URL: git@github.com:user_name/project_name.git
HEAD branch: master
Remote branch:
master tracked
Local ref configured for 'git push': …Run Code Online (Sandbox Code Playgroud) 我在笔记本电脑上有一个git存储库,以及GiHub上的远程存储库(运行'git clone'时创建的直接配置).
我正在使用SSH传输协议.即远程地址是:git@github.com:MyName/MyProg.git
我现在处于端口23被阻塞的网络环境中(据我所知,只有端口80和443打开).我需要获取/合并服务器上可用的最新更改.我有什么选择?如果可能的话,我想避免使用http协议创建一个新的远程分支(这与我已经拥有的远程分支基本相同).
git-remote ×10
git ×8
github ×3
git-branch ×2
git-push ×2
branch ×1
git-config ×1
git-fetch ×1
git-pull ×1
github-cli ×1
hostname ×1
https ×1
repository ×1
resolve ×1
ssh ×1