美文网首页iOS开发者日记
Mac 下 Git 的基础命令行操作

Mac 下 Git 的基础命令行操作

作者: DeadRabbit | 来源:发表于2016-10-18 16:46 被阅读258次

因为Mac下已经自带了git,所以我们跳过此步骤,如果你是Linux的其他系统,可以使用一下代码进行安装:

sudo apt-get install git-core //安装Git

用户配置

git config --global user.name "Your Name" //配置用户名称
git config --global user.email "Your Email" //配置用户邮箱
git config --list //查看配置信息

第一次初始化git版本库
开始一个新的项目,初始化新的代码仓库,要对现有的某个项目开始用 Git 管理,只需到此项目所在的目录,执行:

git init

会在当前目录下生成一个.git目录,包含了所有git需要的数据和资源
进行git添加,提交,推送操作

touch README //创建README
git add . //添加左右新增或者改动过的文件
git commit -a -m "添加README" //提交变更到本地版本库
git push origin <branch name> //推送本地版本库到远程仓库

git克隆远程仓库

//Git本身的源代码你既可以用 git:// 协议来访问:
git clone git@git.jianshu.net:******/****.git
//也可以通过http 协议来访问:
git clone https://git.jianshu.net/******/****.git
//自定义目录名称,如果不自定义,默认为远程仓库的项目目录名称
git clone https://git.jianshu.net/******/****.git mygrit

Git分支操作

查看分支 git branch
创建分支 git branch <branch name>
切换分支 git checkout branch
合并分支 git merge <branch name> //合并某分支到当前分支
删除分支git branch -d <branch name>

mac git --help
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)

clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)

add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)

bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status

grow, mark and tweak your common history

branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
tag Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)

fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects

相关文章

  • Mac 下 Git 的基础命令行操作

    因为Mac下已经自带了git,所以我们跳过此步骤,如果你是Linux的其他系统,可以使用一下代码进行安装: sud...

  • mac上git使用操作

    记录一下,用git命令行进行基础操作的一些操作;原文链接 Git的应用 1.新建文件 初始化git仓库 ...

  • Git篇

    git 的基础命令行操作 touch xxx git init ==> 初始化本地仓库git add

  • 2019-02-20

    命令行基础 安装使用 Windws: 安装git, 打开 gitbash Linux 打开终端 Mac 打开终端 ...

  • Tips for Git

    Tips for Git Git 版本跟 Git 基础操作 一致 快速补全命令 Tab键在命令行输入 git c...

  • 命令行基础

    命令行基础 名词 图形界面:比如 Mac 下的 Finder 就是图形界面,一般用户可以在这里操作文件。 命令行:...

  • GitHub笔记记录

    基础操作 0、本地安装git ---Mac中自带有git,所以不用自己安装 1、设置git的名字和邮箱(配置git...

  • Git-初识git及运用

    版本管理工具(VCS) 1.Git的基础命令行操作 Basic Commands 2.Git的安装方法 Macht...

  • Android Studio + Git(JetBrain全家桶

    观察了下身边同事操作git基本上都是用git命令行或者tortoise git。但是在windows下使用命令行得...

  • MAC系统更新到Mojave后idea中git报错xcrun:

    近期将Mac操作系统更新到了Mojave后IDEA运行git命令报错,命令行运行git命令正常,报错信息如下图...

网友评论

    本文标题:Mac 下 Git 的基础命令行操作

    本文链接:https://www.haomeiwen.com/subject/yqdtuttx.html