广州活力数据恢复中心

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 4940|回复: 12

ubuntu git server 教程和相关信息

[复制链接]

860

主题

1784

帖子

9514

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9514
QQ
发表于 2020-3-24 11:17:30 | 显示全部楼层 |阅读模式
ubuntu git server 教程和相关信息
git命令基础:

设置git
  1. git config --global user.name "用户名"
复制代码
  1. git config --global user.email "邮箱"
复制代码



设置完后查看设置
  1. git config --list
复制代码



创建一个空白的 git 仓库,先进去新建的文件夹然后再输入命令
  1. git init
复制代码




添加当前工作目录文件到index,会监控工作区的状态树,使用它会把工作时的所有变化提交到暂存区,包括文件内容修改(modified)以及新文件(new),但不包括被删除的文件。
  1. git add .
复制代码


git add –update的缩写,仅监控已经被add的文件(即tracked file),会将被修改的文件提交到暂存区。add -u 不会提交新文件(untracked file)
  1. git add -u
复制代码


git add –all的缩写,是上面两个功能的合集
  1. git add -A
复制代码



生成一个commit
  1. git commit -m "change comments"
复制代码
多行msg
  1. git commit -F- <<EOF
  2. 活力数据恢复
  3. 硬盘数据恢复
  4. 内存卡优盘数据恢复
  5. 加密数据恢复
复制代码
上面这代码里最后还有个EOF,这里有bug输入了不会显示
或者
  1. git commit -m 'Message

  2. 活力数据恢复
  3. 硬盘数据恢复
  4. 内存卡优盘数据恢复
  5. 加密数据恢复'
复制代码


修改当前的 commit message
  1. git commit --amend
复制代码






推送到服务器
  1. git push
复制代码

从服务器origin更新代码到本地
  1. git pull origin
复制代码
  1. git pull <远程主机名> <远程分支名>:<本地分支名>
复制代码


git放弃当前的修改
放弃指定文件的修改
  1. git checkout -- filename
复制代码
或者放弃所有修改
  1. git checkout .
复制代码
  1. git reset --hard
复制代码




查看当前project分支详细git branch详细操作
  1. git branch -vv

  2. git remote show origin

  3. cat .git/config
复制代码
三个其任意一个都可以。



ssh git server debug
  1. GIT_SSH_COMMAND="ssh -v -p 数字" git clone ssh://yourip/path/name.git
复制代码


对文件进行比较(也可在版本之间进行比较,后面文件均替换为版本号)
  1. git diff 文件 1 文件 2   
复制代码


代理通道
  1. git config --global http.https://github.com.proxy socks5://127.0.0.1:1212
复制代码



取消通道
  1. git config --global --unset http.https://github.com.proxy
复制代码





常见问题:
debug发现没有调用~/.ssh的配置文件
  1. debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48: Applying options for *
复制代码





git不然后同步的文件,比如一些账户信息,本地log之类的不希望同步,可以用以下方法控制。
  1. vi .gitignore
复制代码

文件内容设定为你需要作出限制的
  1. .DS_Store
  2. *.swp
  3. log/*.log
复制代码


.gitignore只会对建立这个文档之后限制的新增文件才会生交, 如果想要对所有的限制生效, 需要运行命令:
  1. git rm --cached file_name
复制代码
从暂存区里删掉文件

手动掉指定文件夹
  1. git rm -r --cached bin/
复制代码


一次性清除被ignore的文件
  1. git clean -fX
复制代码



git故障和解决方案:git pull速度非常慢, 要等一两分钟才有反应, 可以试试以下命令。
  1. git reset --hard
复制代码

查看tracking文件
  1. git ls-tree -r master --name-only
复制代码



git log详细文件修改信息
  1. git log -p
复制代码






硬盘数据恢复/优盘内存卡数据恢复/服务器数据恢复
data recovery service www.rflashdata.com 数据热线+86 18620923827(微信whatsapp)
buffalo 隨身碟數據救援 bitlocker WDV2 lacie EFS等加密硬盘数据恢复,指纹爱国者加密优盘数据恢复 +86 18620923827
回复

使用道具 举报

92

主题

104

帖子

688

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
688
发表于 2020-8-31 08:12:51 | 显示全部楼层
synology git server

初始化git仓
  1. cd /volume1/git/
  2. git --bare init <repo-name>.git
  3. chown -R gituser:users <repo-name>.git
  4. cd <repo-name>.git
  5. git update-server-info
复制代码



git clone,如果你有改过端口,需要把port改成你现在的端口. 红色部分一般是需要修改的. 按你的实际信息填上.
  1. git clone ssh://gituser@diskstation.local:port/volume1/git/<repo-name>.git
复制代码


首次提交git需要
  1. git push -u origin master
复制代码










报错:
1. error: src refspec master does not match any.
error: failed to push some refs to 'url'

原因是没有commit.


2. ssh_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


ssh没有正常连上或者权限问题.


一体优盘数据恢复 www.rflashdata.com
硬盘ROM损坏焊爆丢失配ROM服务
回复 支持 反对

使用道具 举报

860

主题

1784

帖子

9514

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9514
QQ
 楼主| 发表于 2020-10-10 14:00:33 | 显示全部楼层
新建git,在git server上操作
  1. mkdir test.git
  2. cd test.git
  3. git --bare init
  4. git update-server-info
复制代码
硬盘数据恢复/优盘内存卡数据恢复/服务器数据恢复
data recovery service www.rflashdata.com 数据热线+86 18620923827(微信whatsapp)
回复 支持 反对

使用道具 举报

860

主题

1784

帖子

9514

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9514
QQ
 楼主| 发表于 2020-10-14 12:32:00 | 显示全部楼层
linux上安装git
  1. sudo apt update
  2. sudo apt install git
复制代码


查看git版本
  1. git --version
复制代码



配置git
  1. git config --global user.name "用户名"
  2. git config --global user.email "用户名@rflashdata.com"
复制代码
查看配置
  1. git config --list
复制代码


硬盘数据恢复/优盘内存卡数据恢复/服务器数据恢复
data recovery service www.rflashdata.com 数据热线+86 18620923827(微信whatsapp)
回复 支持 反对

使用道具 举报

860

主题

1784

帖子

9514

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9514
QQ
 楼主| 发表于 2021-1-21 05:09:09 | 显示全部楼层
git clone到本地指定文件夹里
  1. git clone git@github.com:xxx/xxx.git local-folder-path
复制代码


硬盘数据恢复/优盘内存卡数据恢复/服务器数据恢复
data recovery service www.rflashdata.com 数据热线+86 18620923827(微信whatsapp)
回复 支持 反对

使用道具 举报

860

主题

1784

帖子

9514

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9514
QQ
 楼主| 发表于 2021-1-23 08:42:25 | 显示全部楼层
坑是这么挖的,刚开始在本地git init, 添加到远程
  1. git remote add origin git.....
复制代码

报错:
  1. git push --set-upstream origin master
  2. load pubkey "....": invalid format
  3. Total 0 (delta 0), reused 0 (delta 0)
  4. remote: error: refusing to update checked out branch: refs/heads/master
  5. remote: error: By default, updating the current branch in a non-bare repository
  6. remote: is denied, because it will make the index and work tree inconsistent
  7. remote: with what you pushed, and will require 'git reset --hard' to match
  8. remote: the work tree to HEAD.
  9. remote:
  10. remote: You can set the 'receive.denyCurrentBranch' configuration variable
  11. remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
  12. remote: its current branch; however, this is not recommended unless you
  13. remote: arranged to update its work tree to match what you pushed in some
  14. remote: other way.
  15. remote:
  16. remote: To squelch this message and still keep the default behaviour, set
  17. remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
  18. To git.....
  19. ! [remote rejected] master -> master (branch is currently checked out)
  20. error: failed to push some refs to 'git.....'
复制代码


解决方法:
  1. git init --bare xx.git
复制代码
然后本地


  1. git status
复制代码
报错:

  1. fatal: this operation must be run in a work tree
复制代码
而其它电脑clone又不会出现这个error
解决方法:
  1. git config --unset core.bare
复制代码


XD

硬盘数据恢复/优盘内存卡数据恢复/服务器数据恢复
data recovery service www.rflashdata.com 数据热线+86 18620923827(微信whatsapp)
回复 支持 反对

使用道具 举报

860

主题

1784

帖子

9514

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9514
QQ
 楼主| 发表于 2021-1-24 06:28:36 | 显示全部楼层
生成当前project requirements.txt



介绍两种方法:
1. pip freeze,生成当前python环境所有包
  1. pip freeze > requirements.txt
复制代码


2. pipreqs,只生成当前项目所需要的包
先安装
  1. pip install pipreqs
复制代码
生成
  1. pipreqs ./ --encoding=utf-8
复制代码



转台安装所需要的环境
  1. pip install -r requirements.txt
复制代码






硬盘数据恢复/优盘内存卡数据恢复/服务器数据恢复
data recovery service www.rflashdata.com 数据热线+86 18620923827(微信whatsapp)
回复 支持 反对

使用道具 举报

860

主题

1784

帖子

9514

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9514
QQ
 楼主| 发表于 2021-1-26 22:39:18 | 显示全部楼层
git pull报错xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

原因是需要更新commandlinetools
解决方法:
  1. xcode-select --install
复制代码


硬盘数据恢复/优盘内存卡数据恢复/服务器数据恢复
data recovery service www.rflashdata.com 数据热线+86 18620923827(微信whatsapp)
回复 支持 反对

使用道具 举报

860

主题

1784

帖子

9514

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9514
QQ
 楼主| 发表于 2021-1-26 22:39:18 | 显示全部楼层
git pull报错xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

原因是需要更新commandlinetools
解决方法:
  1. xcode-select --install
复制代码


硬盘数据恢复/优盘内存卡数据恢复/服务器数据恢复
data recovery service www.rflashdata.com 数据热线+86 18620923827(微信whatsapp)
回复 支持 反对

使用道具 举报

860

主题

1784

帖子

9514

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9514
QQ
 楼主| 发表于 2021-1-30 00:49:44 | 显示全部楼层
git区分大小写问题


改了文件大小写push了,发现一直没有生效. 经检查发现原来设置了
  1. core.ignorecase=true
复制代码



改成区分大小写
  1. git config core.ignorecase false
复制代码
因为在ubuntu下需要区分大小写. 如果git不跟着会造成麻烦.
硬盘数据恢复/优盘内存卡数据恢复/服务器数据恢复
data recovery service www.rflashdata.com 数据热线+86 18620923827(微信whatsapp)
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|硬盘FLASH数据恢复论坛

GMT+8, 2024-5-14 07:06 , Processed in 0.065365 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表