git 在终端 SSH 中获取当前路径的 url

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6538283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:16:33  来源:igfitidea点击:

Get url of current path in Terminal SSH

gitsshterminal

提问by conspicatus

I am having trouble using git on my own server. I am having trouble where I add the origin path (remote add) as I am entering the wrong url. By finding out the correct path to the .git repository on my server, I should be able to enter that into remote addand it should now find the git repository. So, what I would like to know is how can you get the current path of the folder you are browsing via SSH?

我在自己的服务器上使用 git 时遇到问题。我在添加原始路径(远程添加)时遇到了问题,因为我输入了错误的 url。通过在我的服务器上找到 .git 存储库的正确路径,我应该能够将其输入,remote add它现在应该可以找到 git 存储库。那么,我想知道的是,如何通过 SSH 获取正在浏览的文件夹的当前路径?

Thanks

谢谢

回答by Fred Foo

If the remote host is Unix-like, type pwd.

如果远程主机是类 Unix,请键入pwd.

回答by anh_ng8

I use this bash script to copy the path to any directory to clipboard

我使用这个 bash 脚本将任何目录的路径复制到剪贴板

readlink.sh

链接文件

readlink -f  | xclip -selection clipboard

Usage:

用法:

  • readlink.sh ./# current directory
  • readlink.sh /path/to/somewhere/over/the/rainbow
  • readlink.sh ./# 当前目录
  • readlink.sh /path/to/somewhere/over/the/rainbow