在自己的 linux 服务器上建立仓库(repository)

在自己的 linux 服务器上建立仓库(repository)

服务器端:

在这里使用 ssh 方式登陆:

ssh username@server_address(建议用超级用户登陆)

提示输入密码:......

进入某个文件夹(如果没有 /git 文件夹,则自己创建)

cd /git 

在 /git 文件夹下创建 git 仓库文件夹

mkdir testRepository.git 

查看文件的详细信息:

ls -l 

修改 testRepository.git 的用户组:

chgrp group testRepository.git

ls -l

修改 testRepository.git 的 mod 权限

chmod -R 770 testRepository.git/(770代表 owner权限:7,用户组权限:7,other用户权限:0)

初始化服务端 git 仓库:

cd testRepository.git/

git --bare init

本机端:

在自己的文件夹下(例如 testRepository),打开git bash

初始化为一个本地仓库:

cd testRepository

git init

这时候会生成一个 .git 的隐藏文件,打开里面的 config :

[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true

与连接到远程仓库,也就是让本地仓库与服务器仓库连接起来:

git remote add origin username@server_address/git/testRepository.git

这时候从新打开 config:

[core]
  repositoryformatversion = 0
  filemode = false
  bare = false
  logallrefupdates = true
  symlinks = false
  ignorecase = true
[remote "origin"]
  url = ssh://username@server_address/git/XAC_Libs.git
  fetch = +refs/heads/*:refs/remotes/origin/*

添加追踪文件:

git add -A

提交:

git commit -m 'first commit'

第一次把本地仓库的内容推送到服务器仓库:

git push -u origin master

以后修改提交只要:

git push

 

猜你喜欢

转载自www.cnblogs.com/ibingshan/p/10006946.html