git命令的使用

一.安装git`
1.判断是否安装了git

git

安装过则会输出:

WMBdeMacBook-Pro:~ WENBO$ git
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>]

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

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

2、通过homebrew安装Git
(1)未安装homebrew,需安装homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

(2)安装git

brew install git

3、通过Xcode安装
直接从AppStore安装Xcode,Xcode集成了Git,不过默认没有安装,你需要运行Xcode,选择菜单“Xcode”->“Preferences”,在弹出窗口中找到“Downloads”,选择“Command Line Tools”,点“Install”就可以完成安装了。

二、创建ssh key、配置git
1、设置username和email

git config --global user.name "yangqian"
git config --global user.email "2507365065@qq.com"

2.通过终端命令创建ssh key

ssh-keygen -t rsa -C "2507365065@qq.com"

3.会要求输入密码(自行设置)
输入以下命令,以后就不需要重复输入密码

ssh-add -K

4.复制.ssh/id_rsa.pub文件内容

pbcopy < ~/.ssh/id_rsa.pub

5.在gitlab/github上新建一个ssh key,将上面复制的东西粘贴进去
6.验证链接

ssh -T git@github.com 

三.从远程拉取代码
1.到你想要到的目录下

cd workspace

2.拉取代码(找到你要拉取的项目clone下ssh)

git clone git@xxxx

3.展示所有分支
带*是代表你当前所处的分支

git branch --all
* YQ_test
  develop/DEV_7.2.3
  test

当你要在本地创建分支的时候需要远程也有对应的分支
4.创建本地分支并且关联远程

git checkout -b YQ_test origin/YQ_test

5.拉取代码成功后
(1)将你所需要的组件添加到白名单,可以跳过长时间的编译

vim podfileConfig

填入你需要的组件

podWhiteList = ['gifHomeModule','gifGlobalModule','gifFeedModule','gifFeedBaseModule','gifUICommonModule','gifLiveBaseModule','gifThanosBaseModule']

(2)更新下第三方库

pod install

(3)补充清理代码的命令

pod cache clean --all
pod install --clean-install
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值