Git、GitHub、Gitee、GitLab

Git、GitHub、Gitee、GitLab

Git

Git,分布式版本管理工具

Linux 源码安装
# 下载源代码
wget -c https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.43.0.tar.gz .
tar zxvf git-2.43.0.tar.gz

./configure  # 安装位置默认即可
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
checking for gcc... no
checking for cc... no
checking for cl.exe... no
checking for clang... no
configure: error: in `/root/git/git-2.43.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
# 缺少gcc
yum install gcc-c++
# 再次运行 ./configure
make
# In file included from oss-fuzz/fuzz-commit-graph.c:1:0:
# ./git-compat-util.h:1495:18: fatal error: zlib.h: No such file or directory
# include <zlib.h>
# 解决:yum install zlib-devel
make install

git --version
# git version 2.43.0
常用命令
命令名称作用
git config --global user.name lizhengnan设置用户签名
git config --global user.email lzn122614@vip.qq.com设置用户签名
git init初始化本地库
git status查看本地库状态
git add file添加文件到暂存区
git rm --cached file删除暂存区的文件
git commit -m “description” file将暂存区的文件提交到本地库
git reflog查看版本信息
git log查看版本详细信息
git reset --hard version版本穿梭
分支操作
命令名称作用
git branch 分支名创建分支
git branch -v查看分支
git checkout 分支名切换分支
git merge 分支名把指定的分支合并到当前分支上

合并冲突(两个分支对同一个文件同一处做了不同修改),需要查看文件,手动合并—> git add filename —> git commit -m “description” (此处不加文件名)

GitHub

GitHub,代码远程库。

  • 创建远程库
远程库常用操作命令
命令作用
git remote -v查看当前所有远程地址别名
git remote add 库别名 远程库地址给远程库创建别名
git push 远程库别名/地址 分支名称推送本地分支到远程库
git pull 远程库别名/地址 远程库分支名将远程库的某个分支最新内容拉取下来后与当前本地分支直接合并
git remote add Rplot https://github.com/zhengnanlee/R_Plot.git

git push Rplot master
# git: 'remote-https' is not a git command. See 'git --help'.
# 解决
# 安装 libcurl-devel、curl-devel ,然后重新编译 git (系统:CentOS Linux release 7.9.2009)
yum install libcurl-devel
yum install curl-devel
make clean
rm -r /usr/local/bin/git /usr/local/libexec/git-core
# 安装后重新编译安装 git 

git push Rplot master
# Username for 'https://github.com': zhengnanlee
# Password for 'https://zhengnanlee@github.com': 
# remote: Support for password authentication was removed on August 13, 2021.
# remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
# fatal: Authentication failed for 'https://github.com/zhengnanlee/R_Plot.git/'

  • 生成ssh密钥
ssh-keygen -t rsa -C 'lzn122614@vip.qq.com'
# 连续3次回车
cat ~/.ssh/id_rsa.pub
# 拷贝
# GitHub --> settings --> SSH and GPG keys --> New SSH key
wget -c https://github.com/git-ecosystem/git-credential-manager/releases/download/v2.4.1/gcm-linux_amd64.2.4.1.tar.gz .

tar -xvf gcm-linux_amd64.2.4.1.tar.gz  -C /usr/local/bin

git-credential-manager configure
# Process terminated. Couldn't find a valid ICU package installed on the system. Please install libicu (or icu-libs) using your package manager and try again. Alternatively you can set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support. Please see https://aka.ms/dotnet-missing-libicu for more information.
yum install -y libicu
# 再次运行
git-credential-manager configure

安装完GCM后,再次进行psuh/pull等操作

# 添加远程库别名
git remote add Rplot-ssh git@github.com:zhengnanlee/R_Plot.git
# push
git push Rplot-ssh master
# pull
git pull Rplot-ssh master

Gitee

  • 账号创建
  • 远程库创建
  • pycharm 安装gitee插件并登录
  • 命令操作与GitHub一样
  • 从GitHub中导入仓库到Gitee

GitLab

GitLab,,局域网内使用Git作为代码管理工具的web服务。

  • 安装 方法

https://about.gitlab.com/install/#centos-7

  • 命令操作与GitHub一样
  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值