赞
踩
https://github.com/git/git/tags cd /usr/local wget https://github.com/git/git/archive/refs/tags/v2.36.0.tar.gz tar -zxvf v2.36.0.tar.gz yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker cd git-2.36.0 make prefix=/usr/local/git install make && make install git --version ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # 将git指令添加到bash中 vi /etc/profile # 在最后一行添加 export PATH=$PATH:/usr/local/git/bin # esc 然后:wq,让该配置文件立即生效 source /etc/profile ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # 配置用户连接 git config --list git config --global user.name Shirmay git config --global user.email ********@qq.com git config --global ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # 配置ssh登录下载 cd ~ ssh-keygen -t rsa -C ********@qq.com cd .ssh cat id_rsa.pub # 复制id_rsa.pub文件内容,登录github>settings>SSH and GPG keys # New SSH key输入复制的密钥信息,创建一个密钥 # 然后到一个空的文件夹下比如code文件夹下 git clone git@github.com:shirmay/commprj.git
fatal: could not create work tree dir ‘xxxx’: Permission denied
:sudo chmod o+w 当前目录的名字git config --list
git config --global user.name Shirmay1
git config --global user.email ********@qq.com
git config --global
ssh登录
来解决每次push文件时再次输入账号和密码的步骤,具体步骤见末尾首先github先建立一个新的仓库
仓库建立好后会跳出如下界面,之后本地新建一个空白文件夹,打开git bash窗口然后直接复制如下命令,然后敲个回车即可,此时完成了一次上传文件的步骤
如上第一次提交git的时候,用了-u
参数,之后可直接用git push代替git push -u
,即git push origin master,比如,接下来新传一个dada.xlsx,大概的执行命令如下,先git add 然后 git commit 然后 git push origin main
,git push 的 -u 参数含义
rm -rf test.py
: 删除工作区的某个文件git status
:查看工作区和暂存区的区别git diff
:显示工作区与暂存区的区别git add
提交所有文件相关命令)
git add .
:提交所有文件至暂存区git add test.py
:提交具体的某个文件到暂存区git add file_floder/
:提交具体的某个文件夹到暂存区git rm --cached test.py
:删除暂存区的某个文件git mv [file-original] [file-renamed]
:给某个文件改名git commit -m
相关命令)
git commit -m '描述内容' test.py
:描述某个文件提交信息git commit -m '描述内容' file_floder/
:描述某个文件夹提交信息git rm test.py
: 删除本地仓库中的某个文件git init
, git remote add origin 'https://github.com/MoreMoreLearn232.git'
:第一种建立与远程仓库连接方式:先初始化本地目录,然后建立与远程仓库的连接,其中https://github.com/MoreMoreLearn232.git是具体地址,origin是对这个地址起的别名git clone https://github.com/Spider_Case.git
:第二种建立与远程仓库连接方式:直接建一个空文件夹,然后使用clone命令即可git pull origin master
:相当于从远程获取最新版本并merge到本地 git push origin master
:提交本地仓库的所有改动至远程仓库,(ps:是推送到origin这个别名地址上的master分支上).git目录中存放的是本地库相关的子目录和文件,不要删除与胡乱修改
==git config --global user.name Shirmay
git config --global user.email ******@qq.com
git config --list
git config --global
此时都未推送到远程库,推送到远程库需要执行push命令
git add test.py
git add test.py
git commit -m "修改了文件并提交到仓库了" test.py
注意:前面修改后git add>git commit 可以不经过git add直接使用git commit -a提交;但是不经过暂存区提交的修改,就不能撤销了
。rm -rf test.py
git rm --cached test.py
git rm test.py
git commit -m '第一次通过git删除文件' test.py
git remote add origin [远程仓库地址]
:本地目录初始化git init后,与远程仓库连接git push -u origin master
:将本地仓库内容推送到远程仓库(ps:是推送到origin这个别名地址上的master分支上)git clone [仓库地址]
git clone https://github.com/Shirmay1/Spider_Case.git
git push [别名] [分支]
: 如git push origin master
git pull [别名] [分支]
:如git pull origin master
相当于是从远程获取最新版本并merge到本地git fetch [远程库地址别名][远程分支名]
:相当于是从远程获取最新版本到本地,不会自动合并git merge [远程库地址别名/远程分支名]
:合并数据git fetch origin master
:首先从远程的origin的master主分支下载最新的版本到origin/master分支上git log -p master…origin/master
:然后比较本地的master分支和origin/master分支的差别git merge origin/master
:最后进行合并git branch -v 查看当前所有分支
git branch [分支名] 创建一个新的分支
git checkout [分支名] 切换到某个分支上, 其中根据当前命令行显示可以看出在哪个分支下面
合并分支:目的是把其余的小分支合并到主流的master分支上,所以第一步先切换到master分支上,然后再git merge 另一个分支名(其中子分支也一定是经过了git add git commit的操作了)
git remote add origin https://github.com/Shirmay/Spider_Case333.git
git pull --rebase origin master
git push -u origin master
进入当前用户的家目录: cd ~
删除.ssh目录 :rm -r .ssh
运行密钥生成.ssh密钥目录:ssh-keygen -t rsa -C ********@qq.com
进入.ssh目录查看文件列表:cd .ssh
查看id_rsa.pub内容:cat id_rsa.pub
复制id_rsa.pub文件内容,登录github>settings>SSH and GPG keys
New SSH key输入复制的密钥信息
github已建立好项目
,可以通过git clone的方法复制对应项目的ssh的链接,直接新建一个空的文件夹,然后在当前空文件夹下,输入git clone git@github.com:Shirmay1/yyj.git
,此时线上的项目被拉取下来
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。