Git基础教学1——安装、环境配置与基本设置

简介: 点击进入Git官网选择自己电脑的操作系统安装之后进行傻瓜式安装(如果有需要更换下载路劲的自行更换),一直点下去即可。安装成功后在根目录下运行git-bash.exe或者运行根目录下bin文件夹中的bash.exe或者鼠标右击选择Git Bash Here就可以开始使用命令。

Git基础教学1——安装、环境配置与基本设置


Git基础教学1——安装、环境配置与基本设置


下载Git


点击进入Git官网选择自己电脑的操作系统安装

之后进行傻瓜式安装(如果有需要更换下载路劲的自行更换),一直点下去即可。


安装成功后在根目录下运行git-bash.exe或者运行根目录下bin文件夹中的bash.exe或者鼠标右击选择Git Bash Here就可以开始使用命令。

配置变量环境


右击此电脑(我的电脑)——属性——高级系统设置——环境变量——系统变量——Path——新建——把安装Git根目录下bin的路劲写入新建保存。


win+r输入cmd打开命令窗口输入git,有如下界面即配置成功。

C:\Users\HP>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
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.

在cmd中输入bash就可以开始使用命令。

C:\Users\HP>bash
HP@LAPTOP-JQ25M9AN MINGW64 ~
$


基本配置


打开Git Bash

设置用户信息

git config --global user.name "你的用户名"
git config --global user.email "你的邮箱"

查询用户信息

git config --global user.name 
git config --global user.email 

或者

git config -l
//查看user.name和user.email


为常用指令设置别名(可以不设置)


有些常用指令参数非常多,每次都要输入好多参数,我们可以设置别名。


打开用户目录,创建.bashrc文件。


部分windows系统不允许用户创建点号开头的文件,可以使用命令touch ~/.bashrc解决。


在.bashrc文件中输入如下内容。

#用于输入git提交日志
alias git-log='git log --pretty=oneline --all --graph --abbrev-commit'
#用于输出当前目录所有文件及基本信息
alias ll='ls -all'

打开GitBash,执行source ~/.bashrc


解决GitBashn乱码问题(不输入中文不用出现问题)


打开GitBash执行git config --global core.quotepath false

在安装Git的目录下/etc/bash.bashrc文件最后加入两行

export LANG="zh_cn.UTF_8"
export LC_ALL="zn_cn.UTF_8"


Git常用命令(基本的linux命令)


查看当前目录:ls/ll(配置过别名可以使用)

查看文件内容:cat

创建文件:touch

使用vi编辑器:vi


桌面右击Git GUI Here是GitGUI(git自带图形化界面)

相关文章
|
1月前
|
开发工具 git
Git的基本设置
Git的基本设置
|
2月前
|
开发工具 git
|
14天前
|
Unix Shell 开发工具
windows下如何安装git以及IDEA如何配置git
该文指导安装Git 2.15.0版本。首先从Git官网下载最新安装包,双击安装,依次选择Next,同意默认配置,确保勾选添加到环境变量。在配置选项中,选择在cmd中使用Git(第2项),行结束转换选Windows(第1项),终端模拟器选MinTTY(第1项)。安装完成后,通过右键菜单或直接打开Git Bash验证安装成功。最后,配置全局用户名和邮箱,并在IDEA中设置Git路径以完成集成。
|
18天前
|
Ubuntu Linux 网络安全
|
19天前
|
开发工具 数据安全/隐私保护 C++
vs2019中同步到github上的用户名错误_控制面板和vs的git全局设置重新登录
vs2019中同步到github上的用户名错误_控制面板和vs的git全局设置重新登录
17 0
|
21天前
|
安全 开发工具 git
Windows11搭建Python环境(2)- Anaconda虚拟环境中安装Git
Windows11搭建Python环境(2)- Anaconda虚拟环境中安装Git
25 0
|
23天前
|
Java 开发工具 git
云效产品使用报错问题之流水线获取git版本号后将其设置为环境变量失败如何解决
本合集将整理呈现用户在使用过程中遇到的报错及其对应的解决办法,包括但不限于账户权限设置错误、项目配置不正确、代码提交冲突、构建任务执行失败、测试环境异常、需求流转阻塞等问题。阿里云云效是一站式企业级研发协同和DevOps平台,为企业提供从需求规划、开发、测试、发布到运维、运营的全流程端到端服务和工具支撑,致力于提升企业的研发效能和创新能力。
|
25天前
|
开发工具 git
git怎么设置http代理服务器
git怎么设置http代理服务器
27 12
|
1月前
|
网络安全 开发工具 数据安全/隐私保护
git篇1:git下载安装、使用
git篇1:git下载安装、使用
|
1月前
|
开发工具 数据安全/隐私保护 git
git安装
git安装