博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git 基础版
阅读量:4300 次
发布时间:2019-05-27

本文共 1405 字,大约阅读时间需要 4 分钟。

本文主要是简单介绍下git的基本用法

一、安装

linux中安装很简单,用apt-get install git(centos用yum) 就完成了安装。os x的话,用brew install git。安装好后,在终端敲git,显示如下表示安装成功。

appledeMacBook-Pro:~ apple$ gitusage: git [--version] [--help] [-C 
] [-c name=value] [--exec-path[=
]] [--html-path] [--man-path] [--info-path] [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] [--git-dir=
] [--work-tree=
] [--namespace=
]
[
]
安装后再配置下用户和密码

git config --global user.name "Your Name"git config --global user.email "email@example.com"

二、创建第一个仓库

appledeMacBook-Pro:~ apple$ mkdir test_gitappledeMacBook-Pro:~ apple$ cd test_gitappledeMacBook-Pro:test_git apple$ git initInitialized empty Git repository in /Users/apple/test_git/.git/

查看当前目录下是否有个.git目录

appledeMacBook-Pro:test_git apple$ ls -ah.  .. .git

三、提交代码到仓库

添加文件到Git仓库,分两步:

appledeMacBook-Pro:test_git apple$ git add first.pyappledeMacBook-Pro:test_git apple$ git statusOn branch masterInitial commitChanges to be committed:  (use "git rm --cached 
..." to unstage) new file: first.pyappledeMacBook-Pro:test_git apple$ git commit -m "my first commit"[master (root-commit) a5813c6] my first commit 1 file changed, 1 insertion(+) create mode 100644 first.py

首先,你先将要提交的文件用git add  <file_name> 加入缓存区(这时候你可以查看缓存区现在有什么东西改变),确定修改后用git commit -m "填写此次提交说明"

转载地址:http://havws.baihongyu.com/

你可能感兴趣的文章
Python区间库python-intervals
查看>>
django admin 登录用户名密码错误提示
查看>>
python3 AttributeError: 'function' object has no attribute 'func_name'
查看>>
解决ubuntu下修改my.cnf设置字符集导致mysql无法启动
查看>>
根据进程的PID查询对应端口号
查看>>
Ubuntu安装指定版本的docker
查看>>
MySQL show processlist过滤
查看>>
Python日志logging的levelname格式化参数1.1s小记
查看>>
ubuntu虚拟机VMware桥接模式无法自动化获取IP的解决方法
查看>>
Python debug 报错:SystemError: unknown opcode
查看>>
Python将树结构转换成字典形式的多级菜单结构,写入json文件
查看>>
关闭linux防火墙让windows宿主机访问ubuntu虚拟机web服务以及docker
查看>>
pycharm 找不到同目录文件,但是终端中正常的小记
查看>>
安装了grpc但是无法导入:ImportError: No module named 'grpc'
查看>>
Python中logging模块的基本用法
查看>>
Python查看第三方库、包的所有可用版本,历史版本
查看>>
一键将Python2代码转成Python3小记,
查看>>
Python要求O(n)复杂度求无序列表中第K的大元素
查看>>
Python 各种进制互相转换的函数
查看>>
python的单例理解、__new__、新式类object以及python2和python3下__new__的区别。
查看>>