将Git技能提升到新水平的10条提示

Recently we published a couple of tutorials to get you familiar with Git basics and using Git in a team environment. The commands that we discussed were about enough to help a developer survive in the Git world. In this post, we will try to explore how to manage your time effectively and make full use of the features that Git provides.

最近,我们发布了一些教程,以使您熟悉Git基础知识在团队环境中使用Git 。 我们讨论的命令足以帮助开发人员在Git世界中生存。 在这篇文章中,我们将尝试探索如何有效地管理您的时间并充分利用Git提供的功能。

Note: Some commands in this article include part of the command in square brackets (e.g. git add -p [file_name]). In those examples, you would insert the necessary number, identifier, etc. without the square brackets.

注意:本文中的某些命令在方括号中包含部分命令(例如git add -p [file_name] )。 在这些示例中,您将插入必要的数字,标识符等,而不带方括号。

1. Git自动完成 (1. Git Auto Completion)

If you run Git commands through the command line, it’s a tiresome task to type in the commands manually every single time. To help with this, you can enable auto completion of Git commands within a few minutes.

如果您通过命令行运行Git命令,那么每次手动键入命令是一项繁琐的任务。 为了解决这个问题,您可以在几分钟内启用Git命令的自动完成功能。

To get the script, run the following in a Unix system:

要获取脚本,请在Unix系统中运行以下命令:

cd ~
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

Next, add the following lines to your ~/.bash_profile file:

接下来, ~/.bash_profile添加到您的~/.bash_profile文件中:

if [ -f ~/.git-completion.bash ]; then
    . ~/.git-completion.bash
fi

Although I have mentioned this earlier, I can not stress it enough: If you want to use the features of Git fully, you should definitely shift to the command line interface!

尽管我之前已经提到过这一点,但我不能太强调:如果您想充分利用Git的功能,则绝对应该转向命令行界面!

2.忽略Git中的文件 (2. Ignoring Files in Git)

Are you tired of compiled files (like .pyc) appearing in your Git repository? Or are you so fed up that you have added them to Git? Look no further, there is a way through which you can tell Git to ignore certain files and directories altogether. Simply create a file with the name .gitignore and list the files and directories that you don’t want Git to track. You can make exceptions using the exclamation mark(!).

您是否对Git存储库中出现的已编译文件(例如.pyc )感到厌倦? 还是您已经厌倦了将它们添加到Git中的工作? 别无所求,您可以通过一种方法告诉Git完全忽略某些文件和目录。 只需创建一个名称为.gitignore的文件,并列出您不希望Git跟踪的文件和目录。 您可以使用感叹号(!)进行例外处理。

*.pyc
*.exe
my_db_config/

!main.pyc

3.谁对我的代码感到困惑? (3. Who Messed With My Code?)

It’s the natural instinct of human beings to blame others when something goes wrong. If your production server is broke, it’s very easy to find out the culprit — just do a git blame. This command shows you the author of every line in a file, the commit that saw the last change in that line, and the timestamp of the commit.

当出了问题时,责备别人是人类的本能。 如果您的生产服务器坏了,很容易找出罪魁祸首-只需git blame 。 此命令向您显示文件中每一

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值