開源日報 每天推薦一個 GitHub 優質開源項目和一篇精選英文科技或編程文章原文,堅持閱讀《開源日報》,保持每日學習的好習慣。
今日推薦開源項目:《機器學習 PyTorch》
今日推薦英文原文:《Say Hello to the New GitHub CLIs》

今日推薦開源項目:《機器學習 PyTorch》 傳送門:GitHub鏈接
推薦理由:PyTorch 是一個開源的、基於 Python 的可續計算包,提供兩個高級功能:具有強大的GPU加速的張量計算(如NumPy),和包含自動求導系統的的深度神經網路。
今日推薦英文原文:《Say Hello to the New GitHub CLIs》 作者:Calvin Nguyen
原文鏈接:https://medium.com/better-programming/say-hello-to-the-new-github-clis-7e2612fb3918
推薦理由:顧名思義,本文介紹了一些使用 Git Hub CLI 的方法。如果你是 Git Hub 的忠實用戶但是又覺得網頁和終端轉換繁瑣的話,不妨試試這個吧。

Say Hello to the New GitHub CLIs

All you need to know about using GitHub from your terminal

(Source by Github)
GitHub tools are all great, but sometimes, I get exhausted as I』m coding and have to switch from my terminal/text editor to do many clicks in the browser, just to create or view a PR.

Luckily, on March 6th, 2020, GitHub released a new cool GitHub CLI, with which you can do everything you do on github.com on your local terminal. There are three main commands in this beta version that I will discuss below:

  1. Issue
  2. Pull Request (PR)
  3. Repo

macOS: Easy Install With brew

brew install github/gh/gh

Upgrade

brew update && brew upgrade gh

Windows

gh is available via Scoop:
scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop install gh
For Linux and other platforms, please refer to this GitHub page.

1. gh issue [create, list, view, status]

Create an issue

~/Documents/MyProject (master)$ gh issue create
Creating issue in calvinqc/MERN-template
? Title Deployment To Google App Engine
? Body <Received>
? What's next? Submit
https://github.com/calvinqc/MERN-template/issues/1
Or, if you still prefer editing in the browser, quickly enter:
$ gh issue create --web

List all issues

$ gh issue list
Issues for calvinqc/MERN-template

#1  Deployment To Google App Engine

View an issue

$ gh issue view 1
Then, it will redirect me to the issue link. Or you can preview it in your local as well:
$ gh issue view 1 --preview

Status

$ gh issue status
Relevant issues in calvinqc/MERN-template
Issues assigned to you
  There are no issues assigned to you
Issues mentioning you
  There are no issues mentioning you
Issues opened by you
  #1 Deployment To Google App Engine about 9 minutes ago

2. gh pr [status, list, view, checkout, create]

Create a PR

~/Documents/project/MyProject (gh-testing)$ gh pr create
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 4 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 444 bytes | 444.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To github.com:calvinqc/MERN-template.git
   1c179cb..7953ecc  HEAD -> gh-testing
Branch 'gh-testing' set up to track remote branch 'gh-testing' from 'origin'.
Creating pull request for gh-testing into master in calvinqc/MERN-template
? Title Change sha256 to bcrypt
? Body <Received>
? What's next? Submit
https://github.com/calvinqc/MERN-template/pull/2
As you can see, if there』s one thing that I love about gh pr create, it is that it will push your commit to your working branch and create a PR within a few seconds.

List/view/status with PR (same with the issue)

$ gh pr list
Pull requests for calvinqc/MERN-template
#2  Change sha256 to bcrypt  gh-testing
$ gh pr view 2
Opening https://github.com/calvinqc/MERN-template/pull/2 in your browser
$ gh pr status
Relevant pull requests in calvinqc/MERN-template
Current branch
  #2  Change sha256 to bcrypt [gh-testing]
   - Checks passing
Created by you
  #2  Change sha256 to bcrypt [gh-testing]
   - Checks passing
Requesting a code review from you
  You have no pull requests to review

Checkout a PR

This is very similar to a regular branch checkout.
$ gh pr checkout 2

3. gh repo [clone, create, fork, view]

Clone a repo

$ gh repo clone [email protected]:calvinqc/MERN-template.git

Create/view a repo

$ gh repo create gh-cli-is-awesome
$ gh repo view calvinqc/gh-cli-is-awesome
Opening github.com/calvinqc/gh-cli-is-awesome in your browser.

Fork a repo

$ gh repo fork calvinqc/MERN-template

Future Improvement

Since this is still in beta version and I have not found any bugs yet, I believe that these cool Git CLIs will help improve productivity for many developers.

That』s it for this beta version. It makes my development better, and I like it!

With GitHub CLIs; less clicking, more typing — the more productive I am.

Thanks for reading and I hope it makes you feel happier!


下載開源日報APP:https://openingsource.org/2579/
加入我們:https://openingsource.org/about/join/
關注我們:https://openingsource.org/about/love/