文档章节

Git Commands Tutorial - Part 1

Kolosek
 Kolosek
发布于 2018/04/03 16:09
字数 585
阅读 6
Git">收藏 0

There are many different ways to use Git. The most common are the original command line tools and GUI (Graphical User Interfaces). Here, we will cover the most important commands you should know about when you are working with Git.

The command line is the only place you can run all Git commands. If you know how to run the command-line version you can probably also figure out how to run the GUI version. Also, while your choice of graphical client is a matter of personal taste, all users will have the command-line tools installed and available. You can read more on gits official online book.

Before we start, be sure to know how to use the Terminal in Mac or Command Prompt or Powershell in Windows and have git installed on your system.

Introduction

First, you might ask yourself what is Git actually and what can you do with it? Git is a fast, scalable, distributed revision control system with a rich command set that provides both high-level operations and full access to internals.

In Kolosek, we use Git for every application we create, including Ruby on Rails projects, to make it easier to work as a team and achieve our goal.

You can learn a lot about individual Git commands by running $git help command in the Terminal. This should appear:

git-help-command

Everything can be added to your git repositories even your Controller tests!

Git Options

We will cover the most commonly used command lines, starting from Git options. This will explain everything you need to know about Git on your local machine:

usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path]
           [--info-path] [-p | --paginate | --no-pager]
           [--no-replace-objects] [--bare] [--git-dir=<path>]
           [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
  • $git --version: Find out your current Git suite version using this command.

  • $git --help: Every good programmer should know about this option, it will show you the most used Git Commands, it can also print all available commands with --all or -a.

  • $git -C <path>: Instead of running Git from the current working directory, you can run it from the given <path> instead.

-C <path> command affects other options that expect path names like --git-dir and --work-tree because their path names would be made relative to the working directory caused by the -C option.

  • $git -c <name>=<value>: You can very easily override values from your configuration files. The <name> has to be in the same format as listed by git config, while the <value> is your new parameter value.

  • $git --exec-path[=<path>]: This command helps you find the path where your core Git programs are installed. Another way to do this is by setting the GIT_EXEC_PATH environment variable.

  • $git --git-dir=<path>: Always use this option, whenever you need to set a path to the repository or set the GIT_DIR environment variable. 

We often used these Git options when we were setting up CarrierWave example to Git. Did you have a similar experience?

  • $git --work-tree=<path>: In this way, you can set the path to the current working tree. You can do this as well by setting the GIT_WORK_TREE environment variable.

  • $git --namespace=<path>: Set your Git namespace with this command or by using GIT_NAMESPACE environment variable.

And, that's it! For now, to be exact.

This was only the first part of the tutorial! In the next one, we will cover all the other Git commands, be sure to stay tuned.

This post is originally published on Kolosek Blog.

© 著作权归作者所有

Kolosek
粉丝 0
博文 29
码字总数 20461
作品 0
塞尔维亚
CEO
私信 提问
CI/CD Pipeline Using GitHub, Docker, CircleCI, and Heroku

This post will walk you through how to setup a Continuous Integration & Continuous Deployment (CI/CD) pipeline with CircleCI, Docker & Heroku easily. In the end of this tutorial......

Mohamed Labouardy
2017/12/21
0
0
Installing Odoo 8 on CentOS 6 with Python 2.7

This tutorial will walk you through the process of installing the latest version of Odoo on CentOS 6. It is intended for those who might not be experienced Linux administrators ......

Ericklee
2015/02/10
0
0
英文PDF文档分享:包括 Python、Ruby、MySQL 等等

Tutorials in PDF Format: Python Tutorial in PDF - Download quick Python tutorial in PDF format. Ruby Tutorial in PDF - Download quick Ruby tutorial in PDF format. Java Tutorial ......

红薯
2011/06/06
857
1
Tig 1.0 发布,文本模式的Git浏览器

Tig 是一个 git 资源库浏览器,采用 ncurses 开发。 Tig 1.0 改进记录包括: Improvements: Use git-log(1)s default commit ordering. The old behavior can be restored by adding set co......

oschina
2012/05/11
1K
5
Git LFS 2.1.0 发布,Git 对大文件的支持

Git LFS 2.1.0 发布了。 Git LFS 现在会告知 LFS 是否在跟踪大文件,还是在由 Git 存储,或是两者的结合。Git LFS 2.1.0 通过 .gitconfig 或 .lfsconfig 引入对 URL 样式配置的支持。 对于适...

达尔文
2017/04/29
711
1

没有更多内容

加载失败,请刷新页面

加载更多

elasticsearch查询20公里以内的数据并按距离升序排序data es写法

NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder();BoolQueryBuilder boolQueryBuilder=new BoolQueryBuilder();//这暂wei加入业务查询条件 queryBuilder.withQue......

为何不可1995
10分钟前
0
0
superset在线pip部署

1、安装依赖sudo yum install gcc libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel报错:没有可用软件包 python-pip。没有可用软件包 ......

阿伦哥-
14分钟前
1
0
photoshop简单使用

PS基本操作与图片格式 photoshop工具 组成 菜单项 工具栏 辅助面板 图片格式 jpg png gif 注: psd photoshop CC链接: https://pan.baidu.com/s/1LVa5R_btSjczLBwskCZidQ 提取码:sc3v 快捷...

studywin
16分钟前
0
0
springboot 整合pageHelper

今天跟大家聊聊springboot整合pageHelp,首先pageHelper是一个缓存式分页,分页步骤如下: 1 pom文件添加依赖 <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelp......

gaofei123
17分钟前
1
0
《DNS攻击防范科普系列1》—你的DNS服务器真的安全么?

DNS服务器,即域名服务器,它作为域名和IP地址之间的桥梁,在互联网访问中,起到至关重要的作用。每一个互联网上的域名,背后都至少有一个对应的DNS。对于一个企业来说,如果你的DNS服务器因...

大涛学弟
18分钟前
1
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部