Git - 基础介绍

时间:2023-03-10 05:35:52
Git - 基础介绍

Git

Git - HomePage Git - CHEAT SHEET

开源的分布式版本控制系统,用于敏捷高效地管理项目版本。

下载与安装Git

https://git-scm.com/downloads

https://git-for-windows.github.io/

Git - The Simple Guide

English 中文简体

Git帮助信息

# Display the version of git.
git version # Display the brief help
git <COMMAND> -h # Display help for specific subcommand or concept.
git help <COMMAND/CONCEPT>
git <COMMAND/CONCEPT> --help git help # Prints the synopsis and a list of the most commonly used commands.
git help git # Display the git man page. git help --help # Display the help of 'git help'
git help --all # Print all available commands on the standard output.
git help --guide # Print a list of the useful Git guides on the standard output.

Git代理设置

设置全局代理

  • git config --global https.proxy https://10.144.1.10:8080
  • git config --global http.proxy http://10.144.1.10:8080

去除全局代理

  • git config --global --unset http.proxy
  • git config --global --unset https.proxy

参考信息

Git及GitHub简单使用示例

设置全局登录名称和邮箱

git config --global user.name "<Login name>"

git cofnig --global user.email "<Email address>"

创建SSH Key

ssh-keygen -t rsa –C "<Email address>"

配置GitHub

  1. 如果使用ssh方式,配置ssh认证。
  2. 创建git仓库,确认git仓库信息, 例如:https://github.com/AnlivenCoding/test.git

创建本地git仓库并推送

$ cd /d/Anliven-Running/Zen/test/        # 进入目录
$ echo "# PythonLearning" >> README.md # 创建说明文件
$ git init # 将当前目录变成本地Git仓库
$ git add * # 添加所有文件到本地仓库的暂存区(Index/Stage)
$ git commit -m "first commit" # 提交文件到本地仓库
$ git remote add origin https://github.com/AnlivenCoding/test.git # 关联本地仓库和远端仓库
$ git push -u origin master # 第一次推送本地仓库内容到远端仓库master分支
$ git push origin master # 第一次推送本地仓库内容到远端仓库master分支

which-remote-url-should-i-use

克隆远端仓库到本地

$ git clone https://github.com/AnlivenCoding/test.git
Cloning into 'test'...
remote: Counting objects: 237, done.
remote: Compressing objects: 100% (217/217), done.
remote: Total 237 (delta 11), reused 237 (delta 11), pack-reused 0
Receiving objects: 100% (237/237), 153.18 KiB | 138.00 KiB/s, done.
Resolving deltas: 100% (11/11), done.
Checking connectivity... done.