一.linux 安装git (服务端)

1.首先创建用户账号

useradd zlx

passwd zlx ....

2.创建目录git仓库

mkdir zlx_git.git

3.赋权限

chown zlx:git -R zlx_git.git

#####
windows
ssh://[email protected]:2468/home/data/repositories/gittest.git
#####

git clone [email protected]:/home/data/git/gittest.git
git clone ssh://[email protected]:2468/home/data/repositories/gittest.git

git remote add origin ssh://[email protected]:2468/home/data/repositories/gittest.git
git常用操作:
1.生成公钥和私钥:ssh-keygen -t rsa -C “[email protected]
2.设置本地git的用户名称:git config –global user.name “yourname”
3.设置本地git的邮箱信息:git config –global user.email“[email protected]
4.获取git仓库:git clone [email protected]:xiangrong/WeChatSmallProgram.git
5.更新本地git代码; git pull
6.本地仓库添加所有新建文件:git add .
7.本地仓库提交之前添加提交注释:git commit -m “init commit”
8.本地仓库提交代码:git push origin master
9.获取git分支仓库:git clone -b xxx .git
10.查看当前远端分支情况:git branch -a
11.选择远端xxx分支:git checkout origin/xxx
11.选择远端xxx分支:git checkout origin/xxx
12.创建本地xxx分支:git branch xxx
13.选择本地xxx分支:git checkout xxx
14.查看本地git仓库信息:git status
15.删除本地仓库中的文件:git rm xxx.txt

git 错误 fatal: This operation must be run in a work tree

由于git init –bare 方法创建一个裸仓库,在该仓库无法进行任何git操作,所以抛出错误.
解决方法:在该仓库目录下,新建文件夹,进入该文件夹,执行如下命令:
git init –bare
1. touch Readme
2. git init
3. git add Readme
4. git commit -m 'initial commit' Readme

git pull --rebase origin master

git push -u origin master

这是由于git(服务器端)默认拒绝了push操作,需要进行设置,修改.git/config文件后面添加如下代码:

[receive]
denyCurrentBranch = ignore

05-07 15:29