git 基础版

来源:互联网 发布:魔兽世界世界观 知乎 编辑:程序博客网 时间:2024/05/18 01:20

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


一、安装

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

appledeMacBook-Pro:~ apple$ gitusage: 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 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 <file>..." 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 "填写此次提交说明"


0 0
原创粉丝点击