Centos7 配置Git

随笔记录

目录

1, 新建用户

2. 给用户设置密码相关操作

3. 为新用户添加sudo 权限

4. 配置Git

4.1 配置Git

4.2 查看id_ras.pub 

5, 登录Git 配置SSH 秘钥

6. Centos7 登录Git 

7. clone 指定branch到本地

8. 将新代码复制到指定路径

9. 上传指定代码

9.1 上传

9.2 添加comments

9.3 提交Git

11. Gti 上检查是否上传成功

12. 下载最新代码 

13. 下载指定分支代码


1, 新建用户

# 新建用户
root@localhost home]# useradd magx

#查看是否创建成功,去用户的家目录 home 里面去查看

[root@localhost home]# pwd
/home
[root@localhost home]# ll
total 4
drwx------. 13 magx magx 4096 Dec 12 14:32 magx         # 用户添加成功
drwxr-xr-x.  5 root root   84 Jun  4  2023 TestEvn
drwxr-xr-x.  2 root root    6 Dec 11 14:08 Tools
drwxr-xr-x.  2 root root   24 Apr 26  2023 zhangwk
[root@localhost home]#

2. 给用户设置密码相关操作


[root@localhost home]# su magx         # 切账户

[magx@localhost ~]$ passwd             # 修改当前账户密码
Changing password for user magx.
Changing password for magx.
(current) UNIX password:
New password:

3. 为新用户添加sudo 权限

[root@localhost home]# cat /etc/sudoers
## Sudoers allows particular users to run various commands as
## the root user, without needing the root password.
##
## Examples are provided at the bottom of the file for collections
## of related commands, which can then be delegated out to particular
## users or groups.
##
## This file must be edited with the 'visudo' command.

## Host Aliases
## Groups of machines. You may prefer to use hostnames (perhaps using
## wildcards for entire domains) or IP addresses instead.
# Host_Alias     FILESERVERS = fs1, fs2
# Host_Alias     MAILSERVERS = smtp, smtp2

## User Aliases
## These aren't often necessary, as you can use regular groups
## (ie, from files, LDAP, NIS, etc) in this file - just use %groupname
## rather than USERALIAS
# User_Alias ADMINS = jsmith, mikem


## Command Aliases
## These are groups of related commands...

## Networking
# Cmnd_Alias NETWORKING = /sbin/route, /sbin/ifconfig, /bin/ping, /sbin/dhclient, /usr/bin/net, /sbin/iptables, /usr/bin/rfcomm, /usr/bin/wvdial, /sbin/iwconfig, /sbin/mii-tool

## Installation and management of software
# Cmnd_Alias SOFTWARE = /bin/rpm, /usr/bin/up2date, /usr/bin/yum

## Services
# Cmnd_Alias SERVICES = /sbin/service, /sbin/chkconfig, /usr/bin/systemctl start, /usr/bin/systemctl stop, /usr/bin/systemctl reload, /usr/bin/systemctl restart, /usr/bin/systemctl status, /usr/bin/systemctl enable, /usr/bin/systemctl disable

## Updating the locate database
# Cmnd_Alias LOCATE = /usr/bin/updatedb

## Storage
# Cmnd_Alias STORAGE = /sbin/fdisk, /sbin/sfdisk, /sbin/parted, /sbin/partprobe, /bin/mount, /bin/umount

## Delegating permissions
# Cmnd_Alias DELEGATING = /usr/sbin/visudo, /bin/chown, /bin/chmod, /bin/chgrp

## Processes
# Cmnd_Alias PROCESSES = /bin/nice, /bin/kill, /usr/bin/kill, /usr/bin/killall

## Drivers
# Cmnd_Alias DRIVERS = /sbin/modprobe

# Defaults specification

#
# Refuse to run if unable to disable echo on the tty.
#
Defaults   !visiblepw

#
# Preserving HOME has security implications since many programs
# use it when searching for configuration files. Note that HOME
# is already set when the the env_reset option is enabled, so
# this option is only effective for configurations where either
# env_reset is disabled or HOME is present in the env_keep list.
#
Defaults    always_set_home
Defaults    match_group_by_gid

# Prior to version 1.8.15, groups listed in sudoers that were not
# found in the system group database were passed to the group
# plugin, if any. Starting with 1.8.15, only groups of the form
# %:group are resolved via the group plugin by default.
# We enable always_query_group_plugin to restore old behavior.
# Disable this option for new behavior.
Defaults    always_query_group_plugin

Defaults    env_reset
Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS"
Defaults    env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults    env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"

#
# Adding HOME to env_keep may enable a user to run unrestricted
# commands via sudo.
#
# Defaults   env_keep += "HOME"

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
magx    ALL=(ALL)       ALL                # 为新用户添加 sudo 权限
## Allows members of the 'sys' group to run networking, software,
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL

## Allows members of the users group to mount and unmount the
## cdrom as root
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
[root@localhost home]#

4. 配置Git

4.1 配置Git
[magx@localhost ~]$ cd git_test/
[magx@localhost git_test]$ ls
[magx@localhost git_test]$ ll
total 0
[magx@localhost git_test]$
[magx@localhost git_test]$ git init
Initialized empty Git repository in /home/magx/git_test/.git/
[magx@localhost git_test]$
[magx@localhost git_test]$ git config --global user.name "magx"
[magx@localhost git_test]$ git config --global user.mail "maguox14@hotmail.com"
[magx@localhost git_test]$ git config --global --list
user.name=magx
user.mail=maguox14@hotmail.com
[magx@localhost git_test]$
[magx@localhost git_test]$ ssh-keygen -t rsa -C "maguox14@hotmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/magx/.ssh/id_rsa):
/home/magx/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/magx/.ssh/id_rsa.
Your public key has been saved in /home/magx/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:KtSQ7V6FScA3IJ2FZTPnU0p5GTgcPo7FXjxYOvnq8vY maguox14@hotmail.com
The key's randomart image is:
+---[RSA 2048]----+
|    .ooBB.+++o   |
|     +=oo@=Oo    |
|    o ..o.#o+    |
|     +   * * .   |
|    . o S o .    |
|   . . o   .     |
|    . o   .      |
|     .  ...      |
|         +o.E    |
+----[SHA256]-----+
[magx@localhost git_test]$

4.2 查看id_ras.pub 
[magx@localhost git_test]$
[magx@localhost git_test]$
[magx@localhost git_test]$ cat /home/magx/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCELdrSXB29lX0u0kVIKekTAc1c8+8Ss9vHe9XwOpk2sq8UcWpdNHfL9nLUnN.......
.......
UTicjdzzEO8DIGWQNLjHbub5TxRV6k8jWOY5bxqGtc3dAPbAZ3n maguox14@hotmail.com
[magx@localhost git_test]$

5, 登录Git 配置SSH 秘钥

将4.2id_ras.pub 秘钥 贴入 Git

6. Centos7 登录Git 

[magx@localhost git_test]$ ssh -T git@192.168.2.114
Enter passphrase for key '/home/magx/.ssh/id_rsa':   # 输入id_ras 
Welcome to GitLab, @maguoxia!
[magx@localhost git_test]$
[magx@localhost git_test]$

7. clone 指定branch到本地

[magx@localhost git_test]$ git clone -b V2 git@192.168.2.114:zhangwk/riskcop.git
Cloning into 'riskcop'...
Enter passphrase for key '/home/magx/.ssh/id_rsa':
remote: Enumerating objects: 561, done.
remote: Counting objects: 100% (561/561), done.
remote: Compressing objects: 100% (224/224), done.
remote: Total 5063 (delta 347), reused 521 (delta 322)
Receiving objects: 100% (5063/5063), 638.23 MiB | 24.08 MiB/s, done.
Resolving deltas: 100% (3329/3329), done.
Checking out files: 100% (1731/1731), done.
[magx@localhost git_test]$
[magx@localhost git_test]$

8. 将新代码复制到指定路径

将git 项目分支 V2:riskcop clone 到本地后,将要上传代码文件复制到 此路径

[root@localhost TestEvn]# cp -r Dyn_Init_Scripts/ /home/magx/git_test/riskcop/
[root@localhost TestEvn]#

9. 上传指定代码

9.1 上传
[root@localhost riskcop]# ll
total 936212
drwxr-xr-x. 9 root root      4096 Dec 12 15:21 Dyn_Init_Scripts
-rw-rw-r--. 1 magx magx        63 Dec 12 15:12 README.md
drwxrwxr-x. 4 magx magx        47 Dec 12 15:12 Risk_Init_V2
drwxrwxr-x. 6 magx magx       114 Dec 12 15:12 V2.1
drwxrwxr-x. 3 magx magx        32 Dec 12 15:12 V2.2
drwxrwxr-x. 4 magx magx      4096 Dec 12 15:12 V2.3
-rw-rw-r--. 1 magx magx 859176960 Dec 12 15:12 Version_testing_0706.tar
-rw-rw-r--. 1 magx magx  99490044 Dec 12 15:12 Version_testing_0706.tar.gz
[root@localhost riskcop]# su magx
[magx@localhost riskcop]$
[magx@localhost riskcop]$ git add /home/magx/git_test/riskcop/Dyn_Init_Scripts
9.2 添加comments
[magx@localhost riskcop]$
[magx@localhost riskcop]$ git commit -m "初始化(V2.2+V2.3 业务测试+性能测试+Djangox                                                                                                     项目)"
[V2 f9b4cc6] 初始化(V2.2+V2.3 业务测试+性能测试+Djangox项目-备份)
 Committer: magx <magx@localhost.localdomain>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1415 files changed, 10644475 insertions(+)
 create mode 100644 Dyn_Init_Scripts/Init_V2.2_Basic.tar
 create mode 100644 Dyn_Init_Scripts/Init_V2.2_Basic/.idea/.gitignore
 create mode 100644 Dyn_Init_Scripts/Init_V2.2_Basic/.idea/Init0411.iml
 create mode 100644 Dyn_Init_Scripts/Init_V2.2_Basic/.idea/encodings.xml

.......
.......
.......

 create mode 100644 Dyn_Init_Scripts/supervisorConfig/supervisord.conf
 create mode 100644 "Dyn_Init_Scripts/\345\210\235\345\247\213\345\214\226\350\204\                                                                                                     232\346\234\254\344\273\213\347\273\215.txt"
[magx@localhost riskcop]$


[magx@localhost riskcop]$ git commit -m "初始化(V2.2+V2.3 业务测试+性能测试+Djangox项目)"
# On branch V2
# Your branch is ahead of 'origin/V2' by 1 commit.
#   (use "git push" to publish your local commits)
#
nothing to commit, working directory clean
[magx@localhost riskcop]$
9.3 提交Git
[magx@localhost riskcop]$ git push origin V2:V2            # 提交Git
Enter passphrase for key '/home/magx/.ssh/id_rsa':
Counting objects: 571, done.
Delta compression using up to 80 threads.
Compressing objects: 100% (569/569), done.
Writing objects: 100% (570/570), 376.25 MiB | 1.24 MiB/s, done.
Total 570 (delta 296), reused 12 (delta 1)
remote: Resolving deltas: 100% (296/296), completed with 1 local object.
remote:
remote: To create a merge request for V2, visit:
remote:   http://192.168.2.114/zhangwk/riskcop/merge_requests/new?merge_request%5Bsource_branch%5D=V2
remote:
To git@192.168.2.114:zhangwk/riskcop.git
   7e9b8f0..f9b4cc6  V2 -> V2
[magx@localhost riskcop]$

11. Gti 上检查是否上传成功

12. 下载最新代码 

下载最新
# 先进入已下载的项目分支目录后--> 执行 git pull 下载更新的内容
[magx@server-247 riskcop]$ git branch -a
* (detached from origin/V2)
  V2
  remotes/origin/HEAD -> origin/master
  remotes/origin/V1.0.1
  remotes/origin/V2
  remotes/origin/master
  remotes/origin/riskcop_robotframework
  remotes/origin/v1.0.0
[magx@server-247 riskcop]$ git pull origin V2
Enter passphrase for key '/home/magx/.ssh/id_rsa':
From 192.168.2.114:zhangwk/riskcop
 * branch            V2         -> FETCH_HEAD
Already up-to-date.
[magx@server-247 riskcop]$

13. 下载指定分支代码

#下载 V2 分支代码

[magx@server-247 git_test]$ git clone -b V2 git@192.168.2.114:zhangwk/riskcop.git
Cloning into 'riskcop'...
Enter passphrase for key '/home/magx/.ssh/id_rsa':        #私钥短语 yusur666
remote: Enumerating objects: 543, done.
remote: Counting objects: 100% (543/543), done.
remote: Compressing objects: 100% (182/182), done.
remote: Total 4227 (delta 412), reused 482 (delta 355)
Receiving objects: 100% (4227/4227), 497.75 MiB | 31.78 MiB/s, done.
Resolving deltas: 100% (2718/2718), done.
[magx@server-247 git_test]$
[magx@server-247 git_test]$
[magx@server-247 git_test]$ ll
total 0
drwxrwxr-x 6 magx magx 138 Jul 14 13:49 riskcop
[magx@server-247 git_test]$
[magx@server-247 git_test]$
[magx@server-247 git_test]$ cd riskcop/
[magx@server-247 riskcop]$ ll
total 936208
-rw-rw-r-- 1 magx magx        63 Jul 14 13:49 README.md
drwxrwxr-x 6 magx magx       114 Jul 14 13:49 V2.1
drwxrwxr-x 3 magx magx        24 Jul 14 13:49 V2.2
drwxrwxr-x 4 magx magx      4096 Jul 14 13:49 V2.3
-rw-rw-r-- 1 magx magx 859176960 Jul 14 13:49 Version_testing_0706.tar
-rw-rw-r-- 1 magx magx  99490044 Jul 14 13:49 Version_testing_0706.tar.gz
[magx@server-247 riskcop]$

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/240929.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

2023年11月国产数据库大事记-墨天轮

本文为墨天轮社区整理的2023年11月国产数据库大事件和重要产品发布消息。 11月国产数据库大事记 TOP10 11月国产数据库大事记&#xff08;时间线&#xff09; 11月1日消息&#xff0c;近日&#xff0c;由金仓数据库支撑的某大型运营商B域一级BOSS枢纽系统顺利升级上线。金仓数…

四川技能大赛——2023年四川网信人才技能大赛(网络安全管理员赛项)决赛

四川技能大赛——2023年四川网信人才技能大赛&#xff08;网络安全管理员赛项&#xff09;决赛 文章目录 四川技能大赛——2023年四川网信人才技能大赛&#xff08;网络安全管理员赛项&#xff09;决赛C1-比64少的bas - DONEC2-affine - DONEC3-简单的RSA - DONEM1-不要动我的f…

关于String.Format混合$符号格式化引发的问题

之前一个老项目是用string.Format()进行格式化的&#xff0c;.net 4.5之后的版本 引入 $"字符串" 格式化标识符&#xff0c; 如下代码&#xff1a; string barcode "1234567{#0.000}ABCDE";barcode "12345START{0:#000}ABCDE";try{string sFo…

【网络安全技术】电子邮件安全PGP,SMIME

一、PGP&#xff08;Pretty Good Privacy&#xff09; PGP是一种邮件加密手段&#xff0c;他在发邮件一方加密&#xff0c;然后发给发送方邮件服务器&#xff0c;发送方邮件服务器再发送给接收方邮件服务器&#xff0c;然后接收方再从接收方邮件服务器pop出来&#xff0c;这整…

vue实现自动打字效果(带光标效果)

代码介绍(其实就是通过字符串截取加定时拼接完成的,我相信有时间都能琢磨出来,来这里就是为了省事) 上vue页面代码: <template><div idApp><h2>{{text}}<span ref"fou" class"fousdis">{{_}}</span></h2></div>…

CentOS 7 部署frp穿透内网

本文将介绍如何在CentOS 7.9上部署frp&#xff0c;并通过示例展示如何配置和测试内网穿透。 文章目录 &#xff08;1&#xff09;引言&#xff08;2&#xff09;准备工作&#xff08;4&#xff09;frps服务器端配置&#xff08;5&#xff09;frpc客户端配置&#xff08;6&#…

工信部举行发布会 数字化产业推动元宇宙发展取得良好成效

据官方消息&#xff0c;工业和信息化部12日举行“发挥国家高新区作用 加快推进新型工业化”新闻发布会。 在数字化建设方面取得了良好的成绩&#xff1a; 一是数字经济加速发展。国家高新区着力推动人工智能、大数据、云计算、区块链和元宇宙等新产业新业态蓬勃发展&#xff…

1688订单详情接口使用指南:含代码实现获取订单信息

一、引言 随着电子商务的飞速发展&#xff0c;越来越多的企业开始通过1688平台进行采购和销售。为了更好地管理订单&#xff0c;提高客户满意度&#xff0c;许多企业选择使用1688订单详情接口来获取订单信息。本文将详细介绍如何使用1688订单详情接口&#xff0c;并提供示例代…

2023 年山东省职业院校技能大赛(高等职业教育) “信息安全管理与评估”样题

2023 年山东省职业院校技能大赛&#xff08;高等职业教育&#xff09; “信息安全管理与评估”样题 目录 任务 1 网络平台搭建&#xff08;50 分&#xff09; 任务 2 网络安全设备配置与防护&#xff08;250 分&#xff09; 模块二 网络安全事件响应、数字取证调查、应用程序安…

Guava的注解处理机制

第1章&#xff1a;引言 Guava不仅仅是一个工具库&#xff0c;它更像是Java程序员的瑞士军刀&#xff0c;提供了一系列强大的功能&#xff0c;从集合操作到函数式编程&#xff0c;再到今天咱们要深入探讨的——注解处理机制。 注解&#xff08;Annotations&#xff09;&#x…

14:00面试,14:08就出来了,问的问题有点变态。。。。。。

从小厂出来&#xff0c;没想到在另一家公司又寄了。 到这家公司开始上班&#xff0c;加班是每天必不可少的&#xff0c;看在钱给的比较多的份上&#xff0c;就不太计较了。没想到5月一纸通知&#xff0c;所有人不准加班&#xff0c;加班费不仅没有了&#xff0c;薪资还要降40%…

uniapp+vite+ts+express踩坑总结

1 关于引入express包报 import express from "express"; ^^^^^^ SyntaxError: Cannot use import statement outside a module的问题。 解决方案&#xff1a; 在package.json中添加type&#xff1a;“module”选项 2 Response is a type and must be imported …

Visio中如何在字母上打出上波浪线

1. 如何打出这样的带有波浪线的文字 我们在使用visio中&#xff0c;有时候遇见了特殊符号&#xff0c;比如下方这个带有波浪线的X&#xff0c;如何在visio打出这样的带有波浪线的文字&#xff1f; 2. 操作 首先输入你想打上上波浪线的字母&#xff0c;如下图所示 光标一定…

jmeter里如何添加Referer

按照此实例添加即可。 例如&#xff1a;接口

Flutter实现Android拖动到垃圾桶删除效果-Draggable和DragTarget的详细讲解

文章目录 Draggable介绍构造函数参数说明使用示例 DragTarget 介绍构造函数参数说明使用示例 DragTarget 如何接收Draggable传递过来的数据&#xff1f; Draggable介绍 Draggable是Flutter框架中的一个小部件&#xff0c;用于支持用户通过手势拖动一个子部件。它是基于手势的一…

常州经开区大学生音乐节——常州首届校园乐队比赛

2023年12月9日下午&#xff0c;由江苏省文化馆指导、常州经开区社会事业局主办、常州柒号文化传播有限公司承办、百吉琴行协办的青春制“燥”大学生音乐节——常州首届校园乐队比赛&#xff0c;在常州经开区文化活动中心顺利举办。 常州经开区社会事业局副局长 方姣 为本次比赛…

光栅化渲染:顶点属性插值及透视校正

要使基础的光栅化器正常工作&#xff0c;我们需要做的就是知道如何将三角形投影到屏幕上&#xff0c;将投影坐标转换为光栅空间&#xff0c;然后光栅化三角形&#xff0c;并可能使用深度缓冲区来解决可见性问题。 这已经足以创建 3D 场景的图像&#xff0c;这些图像既是透视正确…

非标设计之中间继电器

目录 一、简介&#xff1a;二、结构和原理&#xff1a;三、中间继电器分类四、中间继电器作用&#xff1a;五、线路图&#xff1a; 一、简介&#xff1a; 在很多的家用电器上(如自动洗衣机、电炉加温等等)&#xff0c;为了防止电流过大而损伤电器&#xff0c;因此在电器上面安装…

大学生创新创业平台竞赛管理子系统论文

摘 要 现代经济快节奏发展以及不断完善升级的信息化技术&#xff0c;让传统数据信息的管理升级为软件存储&#xff0c;归纳&#xff0c;集中处理数据信息的管理方式。本大学生创新创业平台竞赛管理子系统就是在这样的大环境下诞生&#xff0c;其可以帮助管理者在短时间内处理完…

16:00的面试,16:07就出来了,问的问题过于变态了。。。

从小厂出来&#xff0c;没想到在另一家公司又寄了。 到这家公司开始上班&#xff0c;加班是每天必不可少的&#xff0c;看在钱给的比较多的份上&#xff0c;就不太计较了。没想到六月一纸通知&#xff0c;所有人不准加班&#xff0c;加班费不仅没有了&#xff0c;薪资还要降40…