
git
sprites_young
这个作者很懒,什么都没留下…
展开
-
将本地的公钥复制到服务器的authorized_keys文件
ssh git@ip 'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub原创 2021-03-07 20:56:17 · 2605 阅读 · 1 评论 -
git本地分支和远程分支关联
刚开始建立git项目,可能会出现本地没有master分支的情况,那么只需要执行:git add.git commit -m 'test'git push origin master这时候使用命令:git branch就会发现多出一个master分支。这时候,我们开始关联:git branch --set-upstream-to=origin/master master再查看git配置:cd .gitvim config会发现多出一项配置:[branch "master"]原创 2020-12-05 16:36:31 · 1605 阅读 · 1 评论 -
如何修改远程git仓库地址
公司仓库地址变更,重新检出一份同样的代码会浪费时间。这里提供以下几种修改方法:1. 直接设置git remote set-url origin 远程仓库地址2.先删除,再设置git remote rm origingit remote add origin 远程仓库地址3.修改git配置文件进入项目的.git目录vim config会看到如下信息:[core] repositoryformatversion = 0 filemode = false bare = false原创 2020-12-05 16:19:45 · 551 阅读 · 0 评论 -
git操作
git diff : 对比工作区(未 git add)和暂存区(git add 之后)git diff --cached: 对比暂存区(git add 之后)和版本库(git commit 之后)git diff HEAD: 对比工作区(未 git add)和版本库(git commit 之后)原创 2020-12-05 15:43:05 · 113 阅读 · 0 评论 -
git还原本地某个文件
在使用git的时候,我们经常会修改文件,如果修改的不满意,想回到版本库的版本,我们现在分为两种情况:第一种:要修改的文件已经添加到暂存区:就是git add .过了,我们需要做如下操作:先找到该文件某次提交的hash:git log file_path2.恢复文件到该版本:git checkout hash file_path这样文件就回到原版本了第二种:要修改的文件未添加到暂存区:就是文件处于untracked状态:git checkout file_path这样就可以了原创 2020-11-30 11:35:30 · 17628 阅读 · 1 评论 -
git checkout -- <file>和git rm --cached <file>
git checkout -- <file> 表示将文件从暂存区的file版本替换到工作区的file版本,如果暂存区没有,就从版本库中的file版本替换工作区的file版本;git rm --cached <file> 只表示将暂存区的file文件删除。...原创 2020-09-27 16:04:27 · 702 阅读 · 0 评论 -
git clone 出现fatal:Could not read from remote repository.
git错误:fatal:Could not read from remote repository.Please make sure you have the correct access rights这是由于没有配置SSH密钥导致的。将自己的公钥id_rsa.pub的字符串复制到github的ssh设置中再次git clone就可以了。...原创 2018-08-25 12:02:41 · 1921 阅读 · 0 评论