如何从gitlab迁移到github和gitlab区别

公司之前的版本控制工具一直用的svn,最近开发的新,代码准备改换到了gitlab上进行管理。而我自己平时写的一些代码是放在github上进行托管的,这二者都是基于git的开源分布式版本,在本地可以通过ssh进行远程登录验证和数据传输(关于ssh的详细介绍可以参考这篇博文:)。
具体操作是利用ssh在本地生成一对公私秘钥(keys),然后将公钥添加到注册的gitlab/github账户配置ssh key的地方即可。默认情况下本地生成的秘钥位于/Users/mac用户名/.ssh/(mac平台,本文针对os x系统介绍)。
But,问题来了:默认情况下每个账户生成的秘钥位置和名称都是相同的,这样后生成的秘钥就会覆盖前面的秘钥导致其失效。解决的办法就是在生成后一个秘钥的时候对其重新命名,以避免冲突,同时将不同的秘钥配置到相对应的Host上面,这样在访问不同的远程仓库时调用不同的key,冲突也就解决了。具体操作如下:
生成gitlab秘钥
默认你已经注册了gitlab/github账户,以我自己为例,公司项目用的gitlab,自己代码托管在github。先进行公司账号的设置:
本地生成ssh keys命令:ssh-keygen -t rsa -C "注册的gitlab邮箱",生成的公司秘钥会提示是否需要重命名,公司gitlab的秘钥我们就使用默认名称,直接回车跳过,另外还会提示你设置密码,设置密码的话后续登陆会比较麻烦,也直接跳过。成功后大概是这样的:
查看 .ssh/目录,可以看到公私秘钥已经生成,名称分别为id_rsa.pub、id_rsa.
执行命令查看公钥内容:cat ~/.ssh/id_rsa.pub,或者直接用nano编辑期打开id_rsa.pub。公钥大概是这个样子:
将这部分代码添加到到gitlab账户的的SSH Keys中即可。
生成github秘钥
终端执行命令:ssh-keygen -t rsa -C "注册的github邮箱",这次一定要注意,对生成定的秘钥进行重命名,这里暂且重命名为id_rsa_home,同样不设置密码。可以看到生成的公私秘钥已经分别被重命名为id_rsa_home.pub和id_rsa_home。
可以查看公钥里面的内容:cat ~/.ssh/id_rsa_home.pub
不要忘记将其拷到github的SSH Keys里~
gitlab和github的秘钥是分开生成了,可怎么让这两份秘钥分别对应到相应的远程仓库呢?就是让id_rsa.pub认得gitlab,让id_rsa_home.pub认得github。既然不能自动识别,那就只好手动设置了:
配置config
在.ssh/目录下新建config文件:touch config;通过nano进行如下配置:
其中Host对应的名称是一个别名,命名可以随意,用来进行远程连接,当然使用真实的主机名称也是可以的。HostName和IdentityFile就是各自主机名称以及对应的秘钥文件了~
这样配置之后,两份秘钥也就对应到各自相应的仓库上了。通过设置别名,也就可以设置任意多的账户了~
最后利用别名检测下配置是否成功~
检测gitlab连接,如果提示是否建立连接,直接yes就行:
检测github连接:
不报错的话,就说明设置成功了!git - Migrate or export Github wiki to Gitlab - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
J it only takes a minute:
Currently we are working with github and we are actually quiet happy with it. But the costs will grow more and more in near future. Now we've started evaluating other git solutions and stumbled over gitlab, and i've to say, it looks very interesting for us. I've seen that there is as well a wiki feature similar to github. But one important thing is nowhere described...
The only thing i've found is this two year old entry
Does anybody know if there are any news in that matter? it looks like it is possible, but how? is there any manual or howto that could help me?
Thanks a lot!
Github wikis and GitLab wikis are both just Git repositories containing text files, so you can just pull from one and push to the other.
Go to any page on your Github wiki and click the Clone URL button. You'll get a URL like /Homebrew/homebrew.wiki.git. Clone it to your computer:
git clone /Homebrew/homebrew.wiki.git
cd homebrew.wiki
Then, on your GitLab wiki, click the Git Access tab, find the URL in the instructions (in the first line under the Clone Your Wiki heading), and push to that URL:
git push /adambrenecki/test-project.wiki.git
If you can't find the URLs, they should be roughly the same as on this page, with the usernames/repo names changed as appropriate.
I had this problem with over 100 repos with their wikis that I was porting from github to gitlab. I created a few scripts to change the file names and markdown link formatting for the wikis, and to port over all branches and tags. It works, but it's only a 90% solution for the wikis.
To run it:
$ port_repos_and_wikis_from_github_to_gitlab.sh MyGithubGroup MyGitlabGroup MyRepo
7,157103358
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled使用 GitHub / GitLab 的 Webhooks 进行网站自动化部署 – 尘埃落定[gitlab]搭建私有github仓库 - 大搜车-自娱 - ITeye技术网站
博客分类:
自己机器只有178M内存后面机器实在跑不动了,做到安装MySQL需要的Gems这一步,这里面有几点需要注意一下:1.mysqld在centos中目录/etc/init.d/mysqld start为开启服务 2.本文一直使用sudo命令用名为git账户去创建gitlab
3.需要修改ruby的使用源为淘宝的 4.你的机器内存最好在1G以上,我的只有512m执行bundle命令内存不足。
Gitlab是一个用Ruby on Rails开发的开源项目管理程序,可以通过WEB界面进行访问公开的或者私人项目。它和Github有类似的功能,能够浏览源代码,管理缺陷和注释。
下面介绍如何在 Debian/Ubuntu 和 Centos 下搭建配置 GitLab。
Debian/Ubuntu下:
sudo apt-get install -y build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate
安装python(注意需要2.5以上版本):
sudo apt-get install -y python python-docutils
安装git(注意需要1.7.10以上版本):
sudo apt-get install -y git-core
Centos下官方仓库的软件比较老旧,推荐,然后再安装依赖:
sudo yum install git patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel git python python-docutils
安装 Ruby 2.0
需要安装Ruby2.0,软件仓库中的Ruby 1.8不支持:
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar xz
cd ruby-2.0.0-p353
./configure --disable-install-rdoc
sudo make install
安装Bundler Gem:
sudo gem install bundler --no-ri --no-rdoc
配置gitlab-shell
创建git用户:
sudo adduser --system --create-home --comment 'GitLab' git
配置gitlab-shell
su - git -c "git clone /gitlabhq/gitlab-shell.git"
su - git -c "cd gitlab-shell && git checkout v1.3.0"
su - git -c "cp gitlab-shell/config.yml.example gitlab-shell/config.yml"
sed -i "s/localhost//g" /home/git/gitlab-shell/config.yml
su - git -c "gitlab-shell/bin/install"
chmod 600 /home/git/.ssh/authorized_keys
chmod 700 /home/git/.ssh
GitLab支持 MySQL 和 PostgreSQL 数据库。下面以 MySQL为例,介绍安装方法:
Debian/Ubuntu下使用如下命令安装:
sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev
Centos下使用如下命令:
sudo yum install mysql-server
sudo chkconfig mysqld on
配置MySQL:
sudo echo "CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';" | mysql -u root
sudo echo "UPDATE mysql.user SET Password=PASSWORD('123456') WHERE User='root'; FLUSH PRIVILEGES;" | mysql -u root
注意,用你的密码替换123456。
安装配置 gitlab
su - git -c "git clone /gitlabhq/gitlabhq.git gitlab"
su - git -c "git checkout 5-1-stable"
su git -c "cp config/gitlab.yml.example config/gitlab.yml"
su git -c "mkdir /home/git/gitlab-satellites"
su git -c "mkdir public/uploads"
su git -c "mkdir -p tmp/sockets/"
su git -c "mkdir -p tmp/pids/"
sed -i "s/ host: localhost/ host: /g" config/gitlab.yml
sed -i "s/from: gitlab@localhost/from: gitlab@gitlab./g" config/gitlab.yml
su git -c "cp config/puma.rb.example config/puma.rb"
su git -c 'git config --global user.name "GitLab"'
su git -c 'git config --global user.email "gitlab@gitlab."'
注意将替换为你自己的内容。
配置数据库连接:
sudo su git -c "cp config/database.yml.mysql config/database.yml"
sudo sed -i "s/secure password/mysql的root密码/g" config/database.yml
安装MySQL需要的Gems
sudo -u git -H bundle install
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
sudo chmod +x /etc/init.d/gitlab
sudo update-rc.d gitlab defaults 21
查看是否配置妥当:
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
重启GitLab:
sudo service gitlab start
Debian/Ubuntu下:
sudo apt-get install -y nginx
CentOS下:
sudo yum install nginx
下载配置文件样例:
sudo cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
sudo ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab
修改 /etc/nginx/sites-available/gitlab,特别留意将 YOUR_SERVER_FQDN 改成自己的。
重启nginx:
sudo service nginx restart
好了,你可以登录GitLab了,默认安装后的用户名:admin@local.host,密码5iveL!fe。
MyEyeOfJava
浏览: 549533 次
来自: 北京
浏览量:48522
android可以选择uc浏览器,也可以下载安装证书,原生浏览 ...
你好:Android系统4.4本版以后不能是batteryin ...
为什么不能横屏录制?也即是说如果我的应用是一个横屏的应用,那么 ...
lizhenghuan951 写道哈哈,多谢赞扬。我搜robo ...
哈哈,多谢赞扬。我搜robolectric的资料,不小心逛到你 ...

我要回帖

更多关于 github和gitlab 的文章

 

随机推荐