我在GitHub上拖了一個有幾個福克的項目,但忘記了它是哪個福克。
当前回答
使用 git 远程显示起源,您必须在项目目录中,但如果您想从其他地方确定 URL 您可以使用:
cat <path2project>/.git/config | grep url
如果您需要这个命令经常,您可以在 MacOS 中的.bashrc 或.bash_profile 中定义一个 alias。
alias giturl='cat ./.git/config | grep url'
因此,您只需要在 Git 根文件夹中呼叫 giturl 以便简单地获得其 URL。
如果你延伸这个 alias 如此
alias giturl='cat .git/config | grep -i url | cut -d'=' -f 2'
你只得到平坦的URL没有先前的
“URL”
在
url=http://example.com/repo.git
您在使用中获得更多机会:
例子
在 Mac 上,您可以打开 $(giturl) 以在默认浏览器中打开 URL。
或Chrome $(giturl)在Linux上使用Chrome浏览器打开它。
其他回答
只需获取远程URL:
git config --get remote.origin.url
如果您需要完整的输出,并且您正在网络上,可以到达原产地的远程雷波:
git remote show origin
当使用 git clone (从 GitHub,或任何源存储器为该材料) 的默认名称为 clone 的来源是“起源”。使用 git 远程显示将显示有关这个远程名称的信息。
C:\Users\jaredpar\VsVim> git remote show origin
* remote origin
Fetch URL: git@github.com:jaredpar/VsVim.git
Push URL: git@github.com:jaredpar/VsVim.git
HEAD branch: master
Remote branches:
如果你想在脚本中使用值,你会使用这个答案中列出的第一个命令。
我认为你可以找到它在.git/config 和远程[“起源”] 如果你没有操纵它。
这只提供URL,这对脚本目的有用:
git config --get remote.origin.url
我更喜欢这个,因为更容易记住:
git config -l
它将列出所有有用的信息,如:
user.name=Your Name
user.email=your.name@notexisting.com
core.autocrlf=input
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/mapstruct/mapstruct-examples
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
要总结一下,至少有四种方式:
使用官方 Linux 存储库:
最小信息:
$ git config --get remote.origin.url
https://github.com/torvalds/linux.git
和
$ git ls-remote --get-url
https://github.com/torvalds/linux.git
更多信息:
$ git remote -v
origin https://github.com/torvalds/linux.git (fetch)
origin https://github.com/torvalds/linux.git (push)
更多信息:
$ git remote show origin
* remote origin
Fetch URL: https://github.com/torvalds/linux.git
Push URL: https://github.com/torvalds/linux.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
推荐文章
- “node_modules”文件夹应该包含在git存储库中吗
- 为什么git-rebase给了我合并冲突,而我所做的只是压缩提交?
- 如何运行一个github-actions步骤,即使前一步失败,同时仍然失败的工作
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 在GitHub repo上显示Jenkins构建的当前状态
- 如何从远程分支中挑选?
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?
- HEAD和master的区别
- GIT克隆在windows中跨本地文件系统回购
- RPC失败;卷度传输已关闭,剩余未完成的读取数据
- 我应该在.gitignore文件中添加Django迁移文件吗?
- 错误:您对以下文件的本地更改将被签出覆盖
- Git rebase—即使所有合并冲突都已解决,仍然会继续报错
- 在Git中,我如何知道我的当前版本是什么?