diff --git a/sources/tech/20201228 Practice programming in C-- by writing a simple game.md b/sources/tech/20201228 Practice programming in C-- by writing a simple game.md deleted file mode 100644 index 6ddf918a41..0000000000 --- a/sources/tech/20201228 Practice programming in C-- by writing a simple game.md +++ /dev/null @@ -1,175 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Practice programming in C++ by writing a simple game) -[#]: via: (https://opensource.com/article/20/12/learn-c-game) -[#]: author: (Seth Kenlon https://opensource.com/users/seth) - -Practice programming in C++ by writing a simple game -====== -The C++ language is complex, but it can teach you a lot about data -types, memory management, and code linking. -![A bunch of question marks][1] - -There are a couple of ways to learn a programming language. If you're new to coding, you usually learn some basic computer coding concepts and try to apply them. If you already know how to code in another language, you relearn how coding concepts are expressed in the new language. - -In either case, a convenient way to learn these new principles is to create a simple guessing game. This forces you to understand how a language receives input and sends output, how it compares data, how to control a program's flow, and how to leverage conditionals to affect an outcome. It also ensures that you know how a language structures its code; for instance, Lua or [Bash][2] can easily run as a script, while [Java][3] requires you to create a class. - -In this article, I'll demonstrate how to implement a guessing game for the terminal in [C++][4]. - -### Install dependencies - -To follow along with this article, you need C++ and a compiler. - -You can get everything you need on Linux by installing the Qt Creator IDE from your distribution's software repository. - -On Fedora, CentOS, or RHEL: - - -``` -`$ sudo dnf install qt-creator` -``` - -On Debian, Ubuntu, Chromebook, or similar: - - -``` -`$ sudo apt install qtcreator` -``` - -This article doesn't utilize the Qt Creator IDE, but it's an easy way to get everything you need installed, and for complex C++ projects (including those with a GUI), it's an essential tool to have. On macOS or Windows, follow the [installation instructions][5] on Qt's website. - -### Set up includes and namespace - -C++'s core language is minimal. Even a simple application requires the use of additional libraries. This application uses [iostream][6] to gain access to the `cout` and `cin` keywords. - -Also, ensure that the program uses the `std` namespace: - - -``` -#include <iostream> - -using namespace std; -``` - -This isn't strictly necessary, but without setting the namespace to `std`, all keywords from the iostream library require a namespace prefix. For instance, instead of writing `cout`, I would have to write `std::cout`. - -Statements in C++ terminate with a semicolon. - -### Create a function - -Every C++ application requires at least one function. The primary function of a C++ application must be called `main`, and it must return an integer (`int`), which corresponds to the [POSIX][7] expectation that a process returns 0 upon success and something else upon failure. You create a new function by providing its return type and then its name: - - -``` -int main() { - // code goes here -} -``` - -### Implement program logic - -The game code must first produce a random number for the player to guess. You do this in C++ by establishing a _seed_ for pseudo-random number generation. A simple seed is the current time. Once the seed starts, you retrieve a number between 1 and 100 by calling the `rand` function with an upper constraint of 100. This generates a random number from 0 to 99, so add 1 to whatever number is chosen and assign the result to a variable called `number`. You must also declare a variable to hold the player's guess. For clarity, I'm calling this variable `guess`. - -This sample code also includes a debug statement that tells you exactly what the random number is. This isn't very good for a guessing game, but it makes testing a lot faster. Later, you can remove the line or just comment it out by prefacing it with `//`: - - -``` - srand (time(NULL)); - int number = rand() % 100+1; - int guess = 0; - - cout << number << endl; //debug -``` - -### Add do-while and if statements - -A `do-while` statement in C++ starts with the keyword `do` and encloses everything that you want C++ to do in braces. Close the statement with the `while` keyword followed by the condition that must be met (in parentheses): - - -``` -do { - // code here -} while ( number != guess ); -``` - -The game code occurs within an `if` statement with an `else if` and `else` statements to provide the player with hints. - -First, prompt the player for a guess with a `cout` statement. The `cout` function prints output onto `stdout`. Because the `cout` statement isn't appended with the `endl` (endline) function, no linebreak occurs. Immediately following this `cout` statement, tell C++ to wait for input by using the `cin` function. As you might surmise, `cin` waits for input from `stdin`. - -Next, the program enters the `if` control statement. If the player's guess is greater than the pseudo-random number contained in the `number` variable, then the program prints out a hint followed by a newline character. This breaks the `if` statement, but C++ is still trapped within the `do-while` loop because its condition (the `number` variable being equal to `guess`) has not yet been met. - -If the player's guess is less than the pseudo-random number contained in the `number` variable, then the program prints out a hint followed by a newline character. This again breaks the `if` statement, but the program remains trapped within the `do-while` loop. - -When `guess` is equal to `number`, the key condition is finally met, the `else` statement is triggered, the `do-while` loop ends, and the application ends: - - -``` -do { -  cout << "Guess a number between 1 and 100: "; -  cin >> guess; - -  if ( guess > number) { cout << "Too high.\n" << endl; } -  else if ( guess < number ) { cout << "Too low.\n" << endl; } -  else { -    cout << "That's right!\n" << endl; -    exit(0); -  } // fi - } while ( number != guess ); -return 0; -} // main -``` - -### Building the code and playing the game - -You can build your application with GCC: - - -``` -`$ g++ -o guess.bin guess.cpp` -``` - -Run the binary to try it out: - - -``` -$ ./guess.bin -74 -Guess a number between 1 and 100: 76 -Too high. - -Guess a number between 1 and 100: 1 -Too low. - -Guess a number between 1 and 100: 74 -That's right! -``` - -Success! - -### Give C++ a try - -The C++ language is complex. Writing C++ applications for terminals can teach you a lot about data types, memory management, and code linking. Try writing a useful utility in C++ and see what you can discover! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/12/learn-c-game - -作者:[Seth Kenlon][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/seth -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_question_B.png?itok=f88cyt00 (A bunch of question marks) -[2]: https://opensource.com/article/20/12/learn-bash -[3]: https://opensource.com/article/20/12/learn-java-writing-guess-number-game -[4]: https://www.cplusplus.com/ -[5]: https://www.qt.io/product/development-tools -[6]: http://www.cplusplus.com/reference/iostream/ -[7]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains diff --git a/sources/tech/20201231 10 things to love about Git.md b/sources/tech/20201231 10 things to love about Git.md deleted file mode 100644 index b9194534b6..0000000000 --- a/sources/tech/20201231 10 things to love about Git.md +++ /dev/null @@ -1,88 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (lxbwolf) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (10 things to love about Git) -[#]: via: (https://opensource.com/article/20/12/git) -[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) - -10 things to love about Git -====== -Knowing more about how Git works makes working with Git easier. Learn -more in our readers' favorite Git articles of the year. -![Business woman on laptop sitting in front of window][1] - -Git is an essential tool in the open source developer's toolkit. This powerful version-control system has a lot of complex features. Not all of the features are necessary to use Git, but knowing more about how Git works makes working with Git easier. - -During 2020, Opensource.com published many excellent articles about Git, including the top 10 covered below. Each article provides tips and tricks for improving and enhancing your Git experience. - -### How to resolve a git merge conflict - -This tutorial by Brian Breniser begins by defining `git merge` and explaining what merge conflicts are. Then he provides a detailed tutorial about how to [work through a merge conflict][2] when one arises. Breniser also provides a few suggestions for where you can go to learn more about resolving merge conflicts and other Git functions. - -### 4 Git scripts I can't live without - -Vince Power shares his [most important Git scripts][3]. These scripts come from the Git Extras package, which provides over 60 scripts for enhancing Git. Power's favorite scripts are `git-ignore` for editing `.git-ignore` without opening a text editor; `git-info` for providing a summary about a Git repository; `git-mr` and `git-pr` for dealing with merge requests on GitLab and pull requests on GitHub; and `git-release`, which combines Git's `commit`, `tag`, and `push` into a single command. - -### The life-changing magic of git rebase -i - -Learn how to use [git rebase -i to revise your Git history][4] in this article by Dave Neary. Neary starts by explaining how Git handles the history of commits to a repository and the differences between `git commit` and `git rebase`. Next, he explains how to use `git rebase -i` to alter the history of a Git repository to make things cleaner. This allows you to move changes from "fixed typo" commits into other commits and merge similar smaller commits into combined larger commits. - -### Make Git easy with Git Cola - -Opensource.com editor Seth Kenlon demonstrates [how to use Git Cola][5]. Git is a command-line tool, which might turn some people off from using it. Git Cola provides a graphical interface to Git, so users who are not comfortable working on the command line can still take advantage of Git's features. In this article, Kenlon shows how to install Git Cola and accomplish many Git commit tasks using Git Cola's graphical user interface. - -### 6 best practices for teams using Git - -By design, Git is a collaborative tool, but many of the specifics about how to collaborate are left up to teams to decide. Ravi Chandran provides suggestions that any team could adopt [to use Git more effectively][6]. The six best practices, which Chandran explains in the article, are "formalize Git conventions," "merge changes properly," "rebase your feature branch often," "squash commits before merging," "use tags," and "make the software executable print the tag." - -### 7 Git tricks that changed my life - -Rajeev Bera shares [seven Git tricks][7] that improve the user experience when working with Git. The article explores Git's autocorrect option, counting commits, repo optimization, backing up untracked files, knowing the `.git` folder, viewing a file on another branch, and searching in Git. - -### Customizing my Linux terminal with tmux and Git - -Moshe Zadka demonstrates how he [used tmux and Git][8] to customize his Linux terminal. Zadka's article is a fascinating exploration of one person's workflow. He uses GNOME Terminal but enhances it by using tmux and features that allow him to see the status of a Git repository quickly. If files need to be committed or a commit needs to be pushed, a single letter indicates that. - -### Make advanced Git tasks simple with Lazygit - -Jesse Duffield explains how to use [Lazygit, a terminal interface that makes using Git easier][9]. Duffield, who developed Lazygit, details how to use the interface to stage files, rebase interactively, do cherry-picking, search through commits, and open a pull request. - -### Managing Git projects with submodules and subtrees - -Submodules and subtrees are two different ways to include nested subprojects in a Git repository. In [_Managing Git projects with submodules and subtrees_][10], Manaswini Das explains how the two options work and how they differ. - -### Don't love diff? Use Meld instead - -Ben Nuttall shows how to [use Meld instead of diff][11] to compare and merge changes. Meld is a graphical alternative to `diff` with output that is easier to understand. Nuttall demonstrates the difference between comparing two files using `diff` and Meld. He also explains how Meld is Git-aware, which means it can be used to explore changes made to a file since the last time it was committed in Git. - -* * * - -What do you want to learn about Git? Please share your ideas in the comments, and if you have knowledge to share, please [consider writing about it for Opensource.com][12]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/20/12/git - -作者:[Joshua Allen Holm][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/holmja -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating) -[2]: https://opensource.com/article/20/4/git-merge-conflict -[3]: https://opensource.com/article/20/4/git-extras -[4]: https://opensource.com/article/20/4/git-rebase-i -[5]: https://opensource.com/article/20/3/git-cola -[6]: https://opensource.com/article/20/7/git-best-practices -[7]: https://opensource.com/article/20/10/advanced-git-tips -[8]: https://opensource.com/article/20/7/tmux-git -[9]: https://opensource.com/article/20/3/lazygit -[10]: https://opensource.com/article/20/5/git-submodules-subtrees -[11]: https://opensource.com/article/20/3/meld -[12]: https://opensource.com/how-submit-article diff --git a/translated/tech/20201228 Practice programming in C-- by writing a simple game.md b/translated/tech/20201228 Practice programming in C-- by writing a simple game.md new file mode 100644 index 0000000000..199cd5fed4 --- /dev/null +++ b/translated/tech/20201228 Practice programming in C-- by writing a simple game.md @@ -0,0 +1,168 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Practice programming in C++ by writing a simple game) +[#]: via: (https://opensource.com/article/20/12/learn-c-game) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +编写一个简单的游戏来练习用 C++ 编程 +====== + +> C++ 语言很复杂,但它可以教会你很多关于数据类型、内存管理和代码链接的知识。 + +![一堆问号][1] + +学习一门编程语言有几种方法。如果你是编码新手,你通常会学习一些基本的计算机编码概念,并尝试应用它们。如果你已经知道如何用另一种语言进行编码,你可以重新学习编码概念在新语言中是如何表达的。 + +不管是哪种情况,学习这些新原理的便捷方法是创建一个简单的猜谜游戏。这会迫使你了解一门语言如何接收输入和发送输出,如何比较数据,如何控制程序的流程,以及如何利用条件来影响结果。它还确保你知道一门语言是如何组织其代码的;例如,Lua 或 [Bash][2] 可以很容易地作为脚本运行,而 [Java][3] 则需要你创建一个类。 + +在本文中,我将演示如何用 [C++][4] 实现终端上的猜谜游戏。 + +### 安装依赖关系 + +要跟上本文的步伐,你需要 C++ 和一个编译器。 + +在 Linux 上,你可以通过从你的发行版软件仓库中安装 Qt Creator IDE 来获得你所需要的一切。 + +在 Fedora、CentOS 或 RHEL 上: + +``` +$ sudo dnf install qt-creator +``` + +在 Debian、Ubuntu、Chromebook 或类似的发行版上: + +``` +$ sudo apt install qtcreator +``` + +本文并没有使用 Qt Creator IDE,但它是一个安装你所需要的一切的简单方法,对于复杂的 C++ 项目(包括那些带有 GUI 的项目),它是一个必不可少的工具。在 macOS 或 Windows 上,按照 Qt 网站上的[安装说明][5]进行安装。 + +### 设置包含和命名空间 + +C++ 的核心语言是精简的。即使是一个简单的应用程序也需要使用额外的库。这个应用程序使用 [iostream][6] 来获得对 `cout` 和 `cin` 关键字的访问。 + +另外,确保程序使用 `std` 命名空间: + +``` +#include + +using namespace std; +``` + +这并不是绝对必要,但如果不将命名空间设置为 `std`,所有来自 `iostream` 库的关键字都需要一个命名空间前缀。例如,我不能写 `cout`,而是要写 `std::cout`。 + +C++ 中的语句以分号结束。 + +### 创建一个函数 + +每个 C++ 应用程序至少需要一个函数。一个 C++ 应用程序的主函数必须称为 `main`,它必须返回一个整数(`int`),这符合 [POSIX][7] 的期望,即一个进程在成功时返回 0,而在失败时返回其他值。你可以通过为它提供返回类型和名称来创建一个新函数。 + +``` +int main() { + // code goes here +} +``` + +### 实现程序逻辑 + +游戏代码必须首先产生一个随机数供玩家猜测。在 C++ 中,你可以通过建立一个用于生成伪随机数的*种子*来实现。一个简单的种子就是当前的时间。一旦有了种子,你就可以得到一个在 1 和 100 之间的数字。通过调用 `rand` 函数,并设置上限值 100 来产生一个从 0 到 99 的随机数,所以无论选择了什么数字都要加 1,并将结果分配给一个名为 `number` 的变量。你还必须声明一个变量来保存玩家的猜测值。为了清楚起见,我称这个变量为 `guess`。 + +这个示例代码还包括一个调试语句,告诉你随机数到底是什么。这对于猜测游戏来说不是很好,但它使测试速度快了很多。以后,你可以删除这一行,或者直接在行前面用 `//` 注释出来: + +``` + srand (time(NULL)); + int number = rand() % 100+1; + int guess = 0; + + cout << number << endl; //debug +``` + + +### 增加 do-while 和 if 语句 + +C++ 中的 `do-while` 语句以关键字 `do` 开头,并将你希望 C++ 做的所有事情用括号括起来。用 `while` 关键字结束语句,后面是必须满足的条件(括号内): + +``` +do { + // code here +} while ( number != guess ); +``` + +游戏代码出现在 `if`、`else if` 和 `else` 语句之间,为玩家提供提示。 + +首先,用 `cout` 语句提示玩家猜测。`cout` 函数将输出打印到 `stdout` 上。因为 `cout` 语句没有连着 `endl`(endline)函数,所以没有换行。紧接着这个 `cout` 语句,通过使用 `cin` 函数告诉 C++ 等待输入。正如你所猜测的那样,`cin` 等待来自 `stdin` 的输入。 + +接下来,程序进入 `if` 控制语句。如果玩家的猜测大于 `number` 变量中包含的伪随机数,那么程序就会打印出一个提示,后面是一个换行符。这就中断了 `if` 语句,但 C++ 仍然被困在 `do-while` 循环中,因为它的条件(`number` 变量等于 `guess`)还没有满足。 + +如果玩家的猜测小于 `number` 变量中包含的伪随机数,那么程序就会打印出一个提示,后面是一个换行符。这再次中断了 `if` 语句,但程序仍然被困在 `do-while` 循环中。 + +当 `guess` 等于 `number` 时,最终满足关键条件,触发 `else` 语句,`do-while` 循环结束,程序结束: + +``` +do { + cout << "Guess a number between 1 and 100: "; + cin >> guess; + + if ( guess > number) { cout << "Too high.\n" << endl; } + else if ( guess < number ) { cout << "Too low.\n" << endl; } + else { + cout << "That's right!\n" << endl; + exit(0); + } // fi + } while ( number != guess ); +return 0; +} // main +``` + +### 构建代码和玩游戏 + +你可以用 GCC 构建你的应用程序: + +``` +$ g++ -o guess.bin guess.cpp +``` + +运行二进制文件试试: + +``` +$ ./guess.bin +74 +Guess a number between 1 and 100: 76 +Too high. + +Guess a number between 1 and 100: 1 +Too low. + +Guess a number between 1 and 100: 74 +That's right! +``` + +成功了! + +### 试试 C++ 吧 + +C++ 语言很复杂。为终端编写 C++ 应用程序可以让你学到很多关于数据类型、内存管理和代码链接的知识。试着用 C++ 编写一个有用的实用程序,看看你能发现什么! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/12/learn-c-game + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_question_B.png?itok=f88cyt00 (A bunch of question marks) +[2]: https://opensource.com/article/20/12/learn-bash +[3]: https://opensource.com/article/20/12/learn-java-writing-guess-number-game +[4]: https://www.cplusplus.com/ +[5]: https://www.qt.io/product/development-tools +[6]: http://www.cplusplus.com/reference/iostream/ +[7]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains diff --git a/translated/tech/20201231 10 things to love about Git.md b/translated/tech/20201231 10 things to love about Git.md new file mode 100644 index 0000000000..77415f27e9 --- /dev/null +++ b/translated/tech/20201231 10 things to love about Git.md @@ -0,0 +1,87 @@ +[#]: collector: "lujun9972" +[#]: translator: "lxbwolf" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " +[#]: subject: "10 things to love about Git" +[#]: via: "https://opensource.com/article/20/12/git" +[#]: author: "Joshua Allen Holm https://opensource.com/users/holmja" + +让你爱上 Git 的 10 件事 +====== +你对 Git 了解得越多,使用 Git 就会越容易。一起来学习下年度最佳 Git 文章。 +![Business woman on laptop sitting in front of window][1] + +Git 是开源开发者工具箱中最基本的工具。这个强大的版本空值系统有很多复杂的功能。使用 Git 不需要了解它所有的功能,但是对 Git 了解得越多,使用 Git 就会越容易。 + +Opensource.com 在 2020 年发布了一些优秀的 Git 文章,其中包括下面的 top 10。每篇文章都提供了一些奇技淫巧来提升和增强你的 Git 技能。 + +### 怎么解决 git 合并时的冲突 + +Brian Breniser 的这篇教程从 `git merge` 的定义以及解释什么是冲突开始。然后他详细解释了在合并时如果有冲突[如何解决冲突][2]。Breniser 还提了一些能学习更多关于解决冲突和其他 Git 功能的建议。 + +### 我最爱的 4 个 Git 脚本 + +Vince Power 分享了他[最重要的 Git 脚本][3]。这些脚本可以从 Git Extras 包中获得,该包提供了 60 多个 Git 增强脚本。Power 最爱的脚本有:在无需打开文本编辑器的情况下编辑 `.git-ignore` 的 `git-ignore` ;用来处理 GitLab 的合并请求和 GitHub 的 PR 的`git-pr`;把 Git 的 `commit`、`tag` 和 `push` 合为一体的 `git-release`。 + +### git rebase -i 的魔力 + +在 Dave Neary 的这篇文章中可以学习[使用 git rebase -i 来修改你的 Git 提交历史][4]。Neary 从解释 Git 是如何把提交历史记录到仓库中的以及 `git commit` 和 `git rebase` 的区别。之后,他又解释了如何使用 `git rebase -i` 让 Git 仓库的提交历史变得清晰。这个命令能让你把“修复书写错误”的提交合进其他的提交里,把几个相似的小提交合并成一个大的提交。 + +### Git Cola 让使用 Git 变得简单 + +Opensource.com 的主编 Seth Kenlon 演示了[如何使用 Git Cola][5]。Git 是个命令行工具,这对于有些人来说是有学习门槛的。Git Cola 提供了一个图形界面,因此不习惯用命令行的用户也可以使用 Git。在此文中,Kenlon 展示了如何安装 Git Cola,使用 Git Cola 的图形用户界面完成了很多 Git 提交任务。 + +### 团队使用 Git 的 6 个最佳实践 + +从设计上讲,Git 是个协同工具,但是关于如何协同的很多细节是由团队自行决定的。Ravi Chandran 提了一些团队应该采用的[更高效地使用 Git][6]的一些建议。Chandran 在文中列出的 6 个最佳实践是:“使约定正式化”,“适当地合并修改”,“经常更新你的开发分支”,“在合并之前把你的提交合并成一条”,“使用标签”,“让软件的可执行程序打印标签”。 + +### 改变世界的 7 个 Git 技巧 + +Rajeev Bera 分享了 [7 个 Git 技巧][7],这些技巧能提升 Git 的用户体验。文章考察了 Git 的自动更正、提交计数、仓库优化、备份未追踪的文件、了解 `.git` 目录、在另一个分支查看文件以及在 Git 下搜索。 + +### 使用 tmux 和 Git 定制化我的 Linux 终端 + +Moshe Zadka 展示了他是如何[使用 tmux 和 Git][8]定制化他的 Linux 终端的。Zadka 的文章是个人工作流的优秀探索。他使用 GNOME 终端,用 tmux 和一些能让他快速查看 Git 仓库状态的功能来增强终端。他只需要用一个字母就可以提交文件或把提交推送到远程仓库。 + +### 使用 Lazygit 让复杂的 Git 任务简单化 + +Jesse Duffield 解释了如何使用[Lazygit,一个能让使用 Git 变得简单的终端接口][9]。Lazygit 的开发者 Duffield 详细阐述了如何使用这个接口来暂存文件、以交互方式变基、进行筛选、搜索提交以及创建一个 PR。 + +### 使用子模块和子树来管理 Git 项目 + +子模块和子树是两种在 Git 仓库中引入嵌套的子项目的方式。在[使用子模块和子树来管理 Git 项目][10]中,Manaswini Das 解释了两个选项的工作原理和区别。 + +### 不喜欢 diff?那么试试 Meld + +Ben Nuttall 展示了如何[使用 Meld 代替 diff][11]来进行对比和合并修改。Meld 是图形化的 `diff`,输出更容易理解。Nuttall 演示了使用 `diff` 和 Mel 的进行对比的区别。他还解释了 Meld 是如何识别 Git 项目的,这意味着在 Git 中一个文件被提交之后,可以用 Meld 来搜索修改。 + +* * * + +你想学习关于 Git 的什么内容?请在评论去分享你的想法,如果你想分享你的技能,请[考虑为 Opensource.com 投稿][12]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/12/git + +作者:[Joshua Allen Holm][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF "Woman using laptop concentrating" +[2]: https://opensource.com/article/20/4/git-merge-conflict +[3]: https://opensource.com/article/20/4/git-extras +[4]: https://opensource.com/article/20/4/git-rebase-i +[5]: https://opensource.com/article/20/3/git-cola +[6]: https://opensource.com/article/20/7/git-best-practices +[7]: https://opensource.com/article/20/10/advanced-git-tips +[8]: https://opensource.com/article/20/7/tmux-git +[9]: https://opensource.com/article/20/3/lazygit +[10]: https://opensource.com/article/20/5/git-submodules-subtrees +[11]: https://opensource.com/article/20/3/meld +[12]: https://opensource.com/how-submit-article