今天上午由于 SouceTree 一直无法 push 成功,无奈开始搜寻新的 git 客户端,试过 Tower和 GitHub Desktop 后,还是觉得 GitUP 最简单、易用。
官网这样描述它的优点:
- 使用 GitUp,您将获得一个真正高效的 Mac 版 Git 客户端:
- 一个实时的交互式回购图(修改,重新排列,修正,合并提交…)
- 几乎所有操作(甚至变基和合并)的无限撤消/重做
- Time Machine 之类的快照,用于一键回滚到以前的 repo 状态
- 在 Git 中本机不存在的功能,如可视化提交拆分器或统一的 reflog 浏览器
- 即时搜索整个存储库,包括差异内容,
- 一个快得离谱的 UI,通常比命令行更快。
下载后,打开界面有两种添加仓库的方式,一种是直接添加本地仓库,根据我的实践:
- 当本地仓库是从远端克隆下来的时候,此时对仓库进行操作后,可以正常推送到远端,如果是新建的空白仓库,则无法 push(不知道是不是我还没找到在哪里设置 upstream,不过我找了半天,大概率应该是没有)。
- 通过 ssh or https 直接添加远程仓库。这种方式是我现在正在用的,缺点是需要先在 github 上面新建一个空白仓库。
遇到的问题
添加远程仓库,修改完成提交时,又遇到了无法 push 的问题,好在 GitUp 的错误提示界面非常友好(我下了很多 git 软件,只有 GitUp 在不能 push 时告诉我,可能是因为没有添加 SSH 代理),谷歌了解决方式如下:
Set up SSH on macOS/Linux
Use this section to create a default identity and SSH key on macOS or Linux. By default, the system adds keys to the /Users/
Step 1. Set up your default identity
- From the terminal, enter ssh-keygen at the command line. The command prompts you for a file to save the key in:
1 |
|
- Press the Enter or Return key to accept the default location.
We recommend you keep the default key name unless you have a reason to change it.
To create a key with a name or path other than the default, specify the full path to the key. For example, to create a key called my-new-ssh-key, enter a path like the one shown at the prompt:
1
2
3$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/emmap1/.ssh/id_rsa): /Users/emmap1/.ssh/my-new-ssh-key
- Enter and re-enter a passphrase when prompted. The command creates your default identity with its public and private keys. The whole interaction will look similar to the following:
1 |
|
- List the contents of ~/.ssh to view the key files.
1 |
|
The command displays two files, one for the public key (for example id_rsa.pub) and one for the private key (for example, id_rsa).
Step 2. Add the key to the ssh-agent
If you don’t want to type your password each time you use the key, you’ll need to add it to the ssh-agent.
-
To start the agent, run the following:
1
2$ eval `ssh-agent` Agent pid 9700
-
Enter ssh-add followed by the path to the private key file:
macOS $ ssh-add -K ~/.ssh/
Linux $ ssh-add ~/.ssh/
-
(macOS only) So that your computer remembers your password each time it restarts, open (or create) the ~/.ssh/config file and add these lines to the file:
1
2
3Host * UseKeychain yes
最后在相应平台(我是 GitHUb)的设置界面把刚才生成的 SSH 添加上就可以了,在这里可以使用
1 |
|
指令快速将 SSH 复制到剪切板。
然后就可以愉快的玩耍啦~