mac配置gitlab

使用ssh方式拉取gitlab仓库代码

背景

在公司mac电脑上需要将gitee仓库代码迁移到公司gitlab代码仓库中,而我习惯使用ssh方式关联git仓库。我也喜欢使用下面简单粗暴的方式来配置git,之前玩git在window10系统上玩的比较多,各种操作都玩过,比如:创建分支、切换分支、分支代码合并、单文件历史查看、当前文件与上一个版本文件进行比对、各个分支各自的用处等。
再扯点,我使用过idea和Android提交代码,并且它们提交的方式差不多,我也使用svn提交代码,但觉得并不优雅。我通常使用两种方式来提交代码,一种是命令方式、一种是可视化方式,点点就行。高级一点的方式就是Sourcetree。

执行步骤

1、配置

以下命令都是在终端中进入 /Users/用户/.ssh目录下执行下面的命令:

1.1手动方式配置
config文件

.ssh/目录下,如果没有config文件,需要创建一个config
创建命令方式:touch config

# gitlab
Host gitlab.com
  HostName gitlab.com 
  IdentityFile ~/.ssh/id_rsa_gitlab
  User usertest

.gitconfig文件

用户目录下,根据实际情况查找

[user]
	name = usertest
	email = test@qq.com
[core]
	autocrlf = input

windows 和 Mac 协同开发,会碰到一个问题:
提示修改 git core.autocrlf,
这个是由于编辑器的不同或者Windows程序员在跨平台项目中的文件行尾加入了回车换行符, 一些细微的空格变化会不经意地进入大家合作的工作或提交的补丁中。

参考:https://blog.csdn.net/u012364372/article/details/123215289

在Mac上设置 autocrlf = input, 在Windows上设置autocrlf = true(默认值)

1.2 命令方式:

git config --global user.name "your_name" 
git config --global user.email "your_email@qq.com"

2、生成秘钥

生成秘钥:

ssh-keygen -t rsa -C "your_email@qq.com"

具体git配置ssh秘钥请移步:git账号多配置

3、验证是否成功

ssh git@gitlab.com

自建的gitlab仓库地址不同,根据实际情况更改。

4、在gitlab远程仓库配置ssh秘钥

参考:Mac 配置Git与常用命令_mac git配置

不同版本的gitlab的SSH keys秘钥配置位置有细微的差别,自行在设置中找到

附件

参考:https://blog.csdn.net/nxg0916/article/details/135911954

git账号多配置

git提交代码到本地分支

再啰嗦点:

提交代码最关键的几步:

git status
git pull
git status
git add .
git commit -m "描述"
git push

注意:在提交代码之前,先拉取代码,再提交代码。

posted @   所遇所思  阅读(584)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起
🔑
  1. 1 404 not found REOL
  2. 2 偏爱 张芸京
  3. 3 Glimpse of Us Joji
Glimpse of Us - Joji
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : Connor McDonough/Alexis Kesselman/Castle/Riley McDonough/George Miller

作曲 : Connor McDonough/Alexis Kesselman/Castle/Riley McDonough/George Miller

She’d take the world off my shoulders

She’d take the world off my shoulders

If it was ever hard to move

She’d turn the rain to a rainbow

When I was living in the blue

Why then if she is so perfect

Do I still wish that it was you

Perfect don’t mean that it’s working

So what can I do

When you’re out of sight

When you’re out of sight

In my mind

Cause sometimes

Cause sometimes

I look in her eyes and

That’s where I find

A glimpse of us

And I try

To fall for her touch

But I’m thinking of

The way it was

Said I’m fine

And said I moved on

I’m only here passing time in her arms

Hoping I’ll find

A glimpse of us

Tell me he savors your glory

Tell me he savors your glory

Does he laugh the way I did

Is this a part of your story

One that I had never lived

Maybe one day you’ll feel lonely

And in his eyes you’ll get a glimpse

Maybe you’ll start slipping slowly

And find me again

When you’re out of sight

When you’re out of sight

In my mind

Cause sometimes

Cause sometimes

I look in her eyes and

That’s where I find

A glimpse of us

And I try

To fall for her touch

But I’m thinking of

The way it was

Said I’m fine

And said I moved on

I’m only here passing time in her arms

Hoping I’ll find

A glimpse of us

Oooh

Oooh

Oooh-ooh-ooh

Oooh

Oooh-oooh-oooh-ooh-ooh

Cause sometimes

Cause sometimes

I look in her eyes and

That’s where I find

A glimpse of us

And I try

To fall for her touch

But I’m thinking of

The way it was

Said I’m fine

And said I moved on

I’m only here passing time in her arms

Hoping I’ll find

A glimpse of us