美文网首页常用开发工具🛠git
git的使用(二) —— git常用命令(一)

git的使用(二) —— git常用命令(一)

作者: 刀客传奇 | 来源:发表于2022-04-05 16:06 被阅读0次

版本记录

版本号 时间
V1.0 2022.04.05 星期二 清明节

前言

git是程序员常用的工具,用来进行代码的管理工作。大家可以看下git的官网。接下来这几篇我们就一起学习git。感兴趣的可以看下面几篇。
1. git的使用(一) —— git的配置(一)

写在前面:这个日子,对于很多家庭都会很难受吧,有些亲人再也回不来了。

git命令总览

我们在终端中输入git,然后回车,系统就会提示所有的git指令。

xxxMacBook-Pro ~ % git 
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <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
   restore           Restore working tree files
   rm                Remove files from the working tree and from the index
   sparse-checkout   Initialize and modify the sparse-checkout

examine the history and state (see also: git help revisions)
   bisect            Use binary search to find the commit that introduced a bug
   diff              Show changes between commits, commit and working tree, etc
   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
   commit            Record changes to the repository
   merge             Join two or more development histories together
   rebase            Reapply commits on top of another base tip
   reset             Reset current HEAD to the specified state
   switch            Switch branches
   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.
See 'git help git' for an overview of the system.

git config 查看配置信息

config 配置有system级别 global(用户级别)和local(当前仓库)三个设置先从system -> global -> local 底层配置会覆盖顶层配置,分别使用--system/global/local 可以定位到配置文件。

查看系统config

git config --system --list

查看当前用户(global)配置

git config --global  --list

下面是我的电脑的一个输出示例

xxx@xxxMacBook-Pro ~ % git config --global --list
core.excludesfile=/Users/xxx/.gitignore_global
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
mergetool.sourcetree.trustexitcode=true
user.name=xxx
user.email=xxx@xxx.com
commit.template=/Users/xxx/.stCommitMsg
http.version=HTTP/1.1

查看当前仓库配置信息

git config --local    --list

设置用户名和邮箱

git config --global user.name "xxx"
git config --global user.email "xxx@xxx.com"

直接打开局部git config文件

在一个git仓库里,点一下command + shift + .命令,然后就可以看见git文件夹下一级里有一个config的文件夹

直接打开

可以看见,就是core、remotebranch信息等。

直接打开系统git config文件

直接执行command + shift + .命令

其实,系统级别的config文件在如下路径里。

// xxxx就是电脑用户名
/Users/xxxx/.gitconfig

我们直接打开


创建新仓库 - Create a new repository

git clone git@git.xxx.git
cd 一个本地文件夹
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

已经存在的文件夹推送到远端 - Existing folder

cd existing_folder
git init
git remote add origin git@git.xxx.git
git add .
git commit -m "Initial commit"
git push -u origin master

已经存在的git仓库推送到远端 - Existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin git@git.xxx.git
git push -u origin --all
git push -u origin --tags

参考文章

1. git config 查看配置信息

后记

本篇主要讲述了git常用的命令,这个会持续进行更新,感兴趣的给个赞或者关注~~~~

相关文章

  • iOS 开发 之 Git的基本使用(命令篇)

    一、Git的使用 二、Git常用命令

  • Github

    Github使用教程一Github使用教程二Github使用教程三 Git常用命令Git之使用GitHub搭建远程仓库

  • git 操作以及submodule模式详解,附加jenkins对

    git常用命令 注意:请确保已经安装里git客户端 git使用帮助 git --help //git使用帮助,可...

  • Git&Github入门教程笔记(2)

    六. 使用Git创建本地git文件 1.Git常用命令 git config --global user.name...

  • git 常用指令

    如何使用git管理代码 git 常用命令速查 创建版本库 git clone (url) #克隆远程版本库 git...

  • GIT小记

    开始使用Git来进行版本控制,常用命令如下: git init creates a new Git reposit...

  • Git操作记录

    Git的使用常用命令GitHub远程仓库 Git的使用 常用命令 创建仓库 添加命令 提交命令 查看状态 查看修改...

  • Git的学习使用笔记

    一. 重要的参考资料 git干货系列 二. 常用命令汇总 git初始设置 git config --global ...

  • git常用命令及使用技巧

    git常用命令及使用技巧.md git 客户端安装 Git客户端 下载地址: https://www.git-sc...

  • git相关教程汇总

    1. git常用命令 git常用命令总结git常用命令讲解 2. git教程相关网站 廖雪峰的git教程猴子都能懂...

网友评论

    本文标题:git的使用(二) —— git常用命令(一)

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