当我尝试使用时,我的控制台上出现此错误git pull:
远程:2021 年 8 月 13 日移除了对密码身份验证的支持。请改用个人访问令牌。远程:请参阅https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/了解更多信息。致命:无法访问“...”:请求的 URL 返回错误:403
这很奇怪,因为我两周前只是按照文档在 GitHub 上创建了一个令牌,该令牌将于 2021 年 10 月 26 日星期二到期。为什么今天删除了它?
刚刚在Windows上安装了git.我将GIT_DIR变量设置为c:\ git \并验证此环境变量是由cygwin维护的(即echo $ GIT_DIR应该是什么).我去了我想创建git存储库的文件夹,让我们说c:\ www,然后运行:
git init
git add .
Run Code Online (Sandbox Code Playgroud)
然后我得到错误:
fatal: This operation must be run in a work tree
Run Code Online (Sandbox Code Playgroud)
我不确定出了什么问题,但是c:\ git目录有一个配置文件,上面写着:
[core]
repositoryformatversion = 0
filemode = false
bare = true
symlinks = false
ignorecase = true
Run Code Online (Sandbox Code Playgroud)
我很确定这不应该是裸露的,这是我们的问题.
出于可访问性的原因,我试图将一些本地未版本控制的代码推送到存储库中并将其发布到 GitHub 上。
我遵循了这里的建议
cd <local_dir>
git init
git add .
git commit -m "initial commit"
Run Code Online (Sandbox Code Playgroud)
然后我在 github 上创建了一个新的存储库并执行了
git remote add origin https://github.com/...
git pull origin master --allow-unrelated-histories
git push --force-with-lease
Run Code Online (Sandbox Code Playgroud)
但我现在在 github 上看到我有 2 个分支“main”和“master”,我猜 github 在创建存储库时创建了“main”,而当我从本地存储库同步时创建了“master”
我两者都需要吗?
我可以将 master 合并到 main 然后删除 master 吗?
目前这让我很困惑
注意:我现在已经尝试过(本地)
git branch -m master main
git push origin HEAD
Run Code Online (Sandbox Code Playgroud)
但我收到错误
To https://github.com/<the-repo>
! [rejected] HEAD -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/<the-repo>'
hint: Updates were …Run Code Online (Sandbox Code Playgroud) 这就是这个问题的TortoiseGit版本
如果我有一个现有的项目,我想添加它添加到Git版本控制并立即"检查出来",那么TortoiseGit命令是什么?
我搜索了tortoisegit"在这里创建存储库",发现没什么用处.
我有一个目录说cplusplus_learn,我的用户名是git 中的apex_user(比如说)。在 cplusplus_learn 里面,有一些我正在练习 C++ 语言的文件和目录。我想创建一个与cplusplus_learn同名的存储库,并将所有内容推送到 GITHUB网站。有人可以向我解释这样做的完整步骤。我浏览了各种链接,但完全困惑。主要是说已经有回购了。
github-error-repository-not-found-fatal
注意:我想从终端做的所有事情。
$ cd cplusplus_learn
$ git init .
$ git commit -m 'My first commit'
$ git remote add origin https://github.com/apex-user.git
fatal: remote origin already exists.
$ git push -u origin master
fatal: repository 'https://github.com/apex-user/' not found
Run Code Online (Sandbox Code Playgroud)
上面给出的是我尝试过的。我知道有问题,但我无法弄清楚。