‘壹’ linux下Git和GitHub基本使用
1.创建Github账号,linux创建SSH密钥:ssh-keygen2.将公钥加入到Github账户信息Account
Settings,测试验证是否成功。ssh
-T
[email protected]
onovps!
You've
successfully
authenticated,
but
GitHub
does
not
provide
shell
access.3.GitHub创建项目。4.本地配置,新建Git项目并提交到Github。git
config
--global
user.name
'onovps'git
config
--global
user.email
'[email protected]'
#全局联系方式,可选touch
README.mdgit
init
#初始化git
add
README.md
#添加文件到本地仓库git
commit
-m
first
commit
#提交并备注git
remote
add
onovps
[email protected]:onovps/test.git
#增加一个远程服务器端版本库,名称为onovpsgit
push
-u
onovps
master
#将本地文件提交到Github。5.复制项目到本地:git
clone
git://github.com:onovps/test.git6.删除GitHub文件:git
rm
README.md
#本地倒库内删除git
commit
-m
rm
README.md
#提交到本地git
push
onovps
master
#提交到Github
‘贰’ 怎样在linux webstorm配置github
用webstorm 怎么更新git代码1.详细说下webstorm下设置,首先确认webstorm是否为最新版,然后点击(file->setting->github)
这里是表示你有了github的账号,你可以点击Test测试看是否有效,然后需要再次输入密码保存!
2.配置你的git
这里需要注意,webstrom自带的目录是git.exe 然而这里是运行不了的,lz也是多方摸索 不停的卡在这个问题上,也向一些有这方面的经验的群里请教,虽然lz本人态度诚恳,
带着十二分的敬意,然而并没有所谓的大神愿意支援一下 罢了(期望国内的开源之风 更加盛行!),如今都迎刃而解了 故分享给各位朋友,希望能帮到大家!
上面说了一点废话,继续刚刚说的问题,因为我们电脑是默认没有装git的所以你需要先安装git 是个什么东东呢?
如图:
好 记住安装的目录 然后进入——》bin ——》找到git.exe 然后如图2配置好 同时会再次输入你的github账号密码!
3.这一步是可以把你的项目分享到github上 如下图:
4 然后会提示你是否分享成功 注意这里需要你点击提交注释,然后命名不要用中文,中文不给通过。。。,如果成功如下图:
‘叁’ 如何在Linux上搭建一个Git中央仓库
本教程只面向那些个人开发者,想要自己在linux上搭建一个git中央仓库用来上传发布自己的项目。但是对于团队来说可能有更高的要求,可以使用gitlab搭建一个可视化的类似github的版本管理系统
‘肆’ 怎么在linux底下搭建gitlab
插入数据:db.集合名.insert({name:'test',age:1});
删除:db.test.remove();sql="db.test.insert({name:'test',age:1});"//定义执行的sqlecho "$sql"|/home/test/mongodb/mongodb-2.2.3/bin/mongo 127.0.0.1:8888/test --shell
注意,echo命令中的格式必须这样写,管线命令后面的是是数据库安装地址 然后是ip:端口号,斜线后是数据库名称,--shell表示通过shell交互!
‘伍’ 如何在linux搭建git远程版本库
服务端配置
1、安装git
2、新建一个用户,只能用来上传代码,而不能通过ssh登录,比如git用户
adser git
chsh -s $(command -v git-shell) git
使用git-shell替换bash ,这样git用户就不能通过ssh登录
这一步会有警告,提示git-shell不在shell列表里,不用担心。
3、添加ssh公钥,在/home/git/.ssh/authorized_keys里添加客户端的公钥,一行一个。
如果没有文件,可以新建
mkdir /home/git/.ssh
touch /home/git/.ssh/authorized_keys
客户端生成公钥的方法是 ssh-keygen,
windows的在C:\Users\用户名\.ssh\ 目录下,打开id_rsa.pub
4、初始化一个空的git仓库
cd /var
git init --bare sample.git
chown -R git:git sample.git
这一步是让目录可以被git用户修改,否则会出现“permission denied”错误。
客户端
1、可以git clone了
git clone git@服务器:/var/sample.git 即服务器上的文件路径
或者ssh,建议ssh,方便设置端口号
git clone ssh://git@服务器:端口号/var/sample.git
‘陆’ 如何在自己的linux服务器上搭建网站
1.根据机器的用途,许多服务是不需要的。如果Linux只是一个桌面,那么就不需要sendmail、HTTPD和许多其他服务。
如果您的服务器只是一个Web服务器,您还可以关闭许多服务。为此,转到administration菜单并检查服务项。只需撤消您不想启动的任何服务选项。
‘柒’ linux搭建git服务器后怎么使用
linux搭建git服务器后怎么使用GitHub就是一个免费托管开源代码的远程仓库。但是对于某些视源代码如生命的商业公司来说,既不想公开源代码,又舍不得给GitHub交保护费,那就只能自己搭建一台Git服务器作为私有仓库使用。linux搭建git服务器后怎么使用
‘捌’ linux 怎么git github
linux 怎么git github
一、使用包管理器安装GitGit已经被所有的主流Linux发行版所支持。所以安装它最简单的方法就是使用各个Linux发行版的包管理器。
1、Debian, Ubuntu, 或 Linux Mint
$ sudo apt-get install git
2、Fedora, CentOS 或 RHEL
$ sudo yum install git或$ sudo dnf install git
3、Arch Linux
$ sudo pacman -S git
4、OpenSUSE
$ sudo zypper install git
‘玖’ 如何搭建linux git服务器
首先我们分别在Git服务器和客户机中安装Git服务程序(刚刚实验安装过就不用安装了):
[root@linuxprobe ~]# yum install git
Loaded plugins: langpacks, proct-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package git-1.8.3.1-4.el7.x86_64 already installed and latest version
Nothing to do
然后创建Git版本仓库,一般规范的方式要以.git为后缀:
[root@linuxprobe ~]# mkdir linuxprobe.git
修改Git版本仓库的所有者与所有组:
[root@linuxprobe ~]# chown -Rf git:git linuxprobe.git/
初始化Git版本仓库:
[root@linuxprobe ~]# cd linuxprobe.git/
[root@linuxprobe linuxprobe.git]# git --bare init
Initialized empty Git repository in /root/linuxprobe.git/
其实此时你的Git服务器就已经部署好了,但用户还不能向你推送数据,也不能克隆你的Git版本仓库,因为我们要在服务器上开放至少一种支持Git的协议,比如HTTP/HTTPS/SSH等,现在用的最多的就是HTTPS和SSH,我们切换至Git客户机来生成SSH密钥:
[root@linuxprobe ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
65:4a:53:0d:4f:ee:49:4f:94:24:82:16:7a:dd:1f:28 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| .o+oo.o. |
| .oo *.+. |
| ..+ E * o |
| o = + = . |
| S o o |
| |
| |
| |
| |
+-----------------+
将客户机的公钥传递给Git服务器:
[root@linuxprobe ~]# ssh--id 192.168.10.10
[email protected]'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.10.10'"
and check to make sure that only the key(s) you wanted were added.
此时就已经可以从Git服务器中克隆版本仓库了(此时目录内没有文件是正常的):
[root@linuxprobe ~]# git clone [email protected]:/root/linuxprobe.git
Cloning into 'linuxprobe'...
warning: You appear to have cloned an empty repository.
[root@linuxprobe ~]# cd linuxprobe
[root@linuxprobe linuxprobe]#
初始化下Git工作环境:
[root@linuxprobe ~]# git config --global user.name "Liu Chuan"
[root@linuxprobe ~]# git config --global user.email "[email protected]"
[root@linuxprobe ~]# git config --global core.editor vim
向Git版本仓库中提交一个新文件:
[root@linuxprobe linuxprobe]# echo "I successfully cloned the Git repository" > readme.txt
[root@linuxprobe linuxprobe]# git add readme.txt
[root@linuxprobe linuxprobe]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached ..." to unstage)
#
# new file: readme.txt
#
[root@linuxprobe linuxprobe]# git commit -m "Clone the Git repository"
[master (root-commit) c3961c9] Clone the Git repository
Committer: root
1 file changed, 1 insertion(+)
create mode 100644 readme.txt
[root@linuxprobe linuxprobe]# git status
# On branch master
nothing to commit, working directory clean
但是这次的操作还是只将文件提交到了本地的Git版本仓库,并没有推送到远程Git服务器,所以我们来定义下远程的Git服务器吧:
[root@linuxprobe linuxprobe]# git remote add server [email protected]:/root/linuxprobe.git
将文件提交到远程Git服务器吧:
[root@linuxprobe linuxprobe]# git push -u server master
Counting objects: 3, done.
Writing objects: 100% (3/3), 261 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/root/linuxprobe.git
* [new branch] master -> master
Branch master set up to track remote branch master from server.
为了验证真的是推送到了远程的Git服务,你可以换个目录再克隆一份版本仓库(虽然在工作中毫无意义):
[root@linuxprobe linuxprobe]# cd ../Desktop
[root@linuxprobe Desktop]# git clone [email protected]:/root/linuxprobe.git
Cloning into 'linuxprobe'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[root@linuxprobe Desktop]# cd linuxprobe/
[root@linuxprobe linuxprobe]# cat readme.txt
I successfully cloned the Git repository
这篇是详细介绍Git的,中间有一部分是怎么去搭建,你可以看下
‘拾’ linux如何搭建git
1、环境准备
服务器:CentOS 7.3 + git (1.8.3.1)
客户端:win10 + git (2.17.0.windows.1)
2、服务器安装git
yum install -y git
3、创建git用户,管理 git服务
[root@localhost home]# useradd git
[root@localhost home]# passwd git
4、服务器创建git 仓库
设置/home/git/repository-git 为git 服务器仓库,然后把 git 仓库的 owner 修改为 git 用户。
复制代码
[root@localhost git]# mkdir repository-git
[root@localhost git]# git init --bare repository-git/
Initialized empty Git repository in /home/git/repository-gt/
[root@localhost git]# chown -R git:git repository-git/
5、客户端安装git
下载 Git for Windows,地址:https://git-for-windows.github.io/
安装完之后,可以使用 Git Bash 作为命令行客户端。
5.1、选择一个目录 F:\project\sell 作为本地仓库,右键进入Git Bash 命令行模式
初始化本地仓库:git init
5.2、尝试克隆一个服务器的空仓库到本地仓库
git clone [email protected]:/home/git/repository-gt
第一次连接到目标 Git 服务器时会得到一个提示:
The authenticity of host '192.168.116.129(192.168.116.129)' can't be established.
RSA key fingerprint is SHA256:Ve6WV/.
Are you sure you want to continue connecting (yes/no)?
选择 yes:
Warning: Permanently added '192.168.116.129' (RSA) to the list of known hosts.
此时 C:\Users\用户名\.ssh 下会多出一个文件 known_hosts,以后在这台电脑上再次连接目标 Git 服务器时不会再提示上面的语句。