本文共 5772 字,大约阅读时间需要 19 分钟。
github 生产环境
by Darren Burns
达伦·伯恩斯(Darren Burns)
With the recent announcement by GitHub of , let’s take a few minutes before we push our code we don’t want anyone else to see to the cloud, and make sure we’re making the most of what GitHub has to offer.
GitHub最近发布了 ,让我们花几分钟时间在发布代码之前,不要让其他人看到云,并确保我们充分利用GitHub所提供的功能。
GitHub is built with some extremely helpful shortcuts and productivity-boosting features. From personal experience, however, it’s clear that these often fall under the radar amongst developers.
GitHub具有一些非常有用的快捷方式和提高生产力的功能。 但是,从个人经验来看,很明显,这些通常会在开发人员中受到关注。
If I’ve ever witnessed a specific GitHub feature surprise or assist someone, it’s on this page. That said, what follows is by no means an exhaustive list.
如果我目睹过某个特定的GitHub功能令人惊讶或为某人提供了帮助,请访问此页面。 也就是说,以下内容绝不是详尽的清单。
This is, without doubt, the fastest way to browse a repository when you know what you’re looking for. Open up any repository and press t
. You can now search for the name of any file in the repository, and use the arrow keys on your keyboard to move through the results. Press Enter
to open the file.
毫无疑问,这是您知道要查找的内容时浏览存储库的最快方法。 打开任何存储库,然后按t
。 现在,您可以在存储库中搜索任何文件的名称,然后使用键盘上的箭头键在结果中移动。 按Enter
打开文件。
When commenting on a piece of code in a pull request, you can suggest alternative code using the “Suggested Changes” feature. The author of the pull request will be able to apply your suggestion instantly without leaving GitHub. To make the suggestion, surround a code snippet with a multi-line Markdown snippet and add the tag “suggestion”:
在请求请求中注释一段代码时,您可以使用“建议的更改”功能建议其他代码。 拉取请求的作者将能够立即应用您的建议,而无需离开GitHub。 要提出建议,请在代码段周围加上多行Markdown代码段,并添加标签“ suggestion”:
Now that you’ve made the suggestion, the author of the pull request can immediately apply it to their branch, without the hassle of manually changing the file!
现在,您已经提出了建议,pull请求的作者可以立即将其应用于其分支,而无需手动更改文件!
This one requires an unofficial Chrome extension, but it’s a slightly more familiar way to navigate your code, compared to the default interface. The lets you browse GitHub repositories with a sidebar tree view similar to what you get in applications like VS Code.
这需要一个非官方的Chrome扩展程序,但是与默认界面相比,它是一种稍微熟悉些的代码浏览方式。 使您可以使用侧边栏树状视图浏览GitHub存储库,类似于在VS Code等应用程序中获得的视图。
Unless you’re reviewing a single function, a code review often involves a lot of jumping between function calls and their definitions (and therefore a lot of scrolling up and down). GitHub lets you jump to a symbol by pressing t
when you’re looking at files in a pull request.
除非您查看单个功能,否则代码查看通常会涉及到函数调用及其定义之间的大量跳转(因此,会导致上下滚动)。 在查看拉取请求中的文件时,GitHub允许您通过按t
跳至符号。
When viewing a file or directory, press y
, and the URL will be converted to a permalink, which you can share safely in the knowledge that the contents of the file will never change.
查看文件或目录时,按y
,URL将被转换为永久链接,您可以安全地共享该链接,前提是文件的内容永远不会改变。
If you send a link to a file or directory on GitHub without making it into a permalink, you’ll need to accept the possibility that the file could disappear tomorrow, breaking the link!
如果您将链接发送到GitHub上的文件或目录而没有使其成为永久链接,则您需要接受该文件明天可能消失并断开链接的可能性!
When viewing a file, you can press b
to view the Git blame and a heatmap showing how recently each line was changed. It’ll tell you who most recently changed each line of code, and give you a clickable link taking you to the full commit the change was part of.
查看文件时,您可以按b
键查看Git责备和一个热图,该热图显示每行的更改时间。 它会告诉您最近谁更改了每一行代码,并提供了一个可单击的链接,使您可以进行更改的完整提交。
On the right-hand side of the gutter (which contains the commit message and author), you’ll notice an orange vertical bar. The more vivid this bar is, the more recent the change, meaning you can easily scan the file to find the freshest code!
在装订线的右侧(包含提交消息和作者),您会注意到橙色的竖线。 该栏越生动,说明更改越新,这意味着您可以轻松地扫描文件以找到最新的代码!
GitHub indexes most code and offers powerful search functionality over it. If you need to find something in a repository, but don’t plan on making any changes to it. There’s usually no need to check the repository out. Press /
to search all the code in the repository.
GitHub将大多数代码编入索引,并提供强大的搜索功能。 如果您需要在存储库中找到某些内容,但是不打算对其进行任何更改。 通常无需检出存储库。 按/
搜索存储库中的所有代码。
If your search contains multiple words and you want to search for occurrences of your specific search query, put the quotations around the query. You can filter your searches by other things too, such as file size, extension, the path the file is on, and much more.
如果您的搜索包含多个单词,并且要搜索特定搜索查询的出现次数,请在查询前后加上引号。 您还可以通过其他内容来过滤搜索,例如文件大小,扩展名,文件所在的路径等等。
If you ever find yourself repeating the same comments, you’ll save some time by creating a . The next time you find you’re going to type that comment again, you can instead just select it from a drop-down menu:
如果您发现自己重复了同样的评论,可以通过创建节省一些时间。 下次发现要再次键入该评论时,您可以从下拉菜单中选择它:
To perform the above action without using my mouse, I can do ctrl
+ /
followed by ctrl
+ 1
.
不使用我的鼠标执行上述动作,我可以做ctrl
+ /
随后ctrl
+ 1
。
Thanks for reading. I hope you found at least one thing on this page that will make you a more productive GitHub user. If you enjoyed this post or have any feedback in general, let me know!
谢谢阅读。 希望您在此页面上找到至少一件事,这将使您成为更有效率的GitHub用户。 如果您喜欢这篇文章或总体上有任何反馈意见,请告诉我!
If you’re interested in more content like this, follow me on .
如果您对类似这样的更多内容感兴趣,请在关注我。
Originally posted on my .
最初发布在我的 。
P.S. You can make your own Octocat for sharing like the one in the cover photo at !
PS:您可以像封面照片中的照片一样制作自己的Octocat进行共享!
翻译自:
github 生产环境
转载地址:http://rfewd.baihongyu.com/