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_pluginDefaults    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.comAfter doing this, you may fix the identity used for this commit with:git commit --amend --reset-author1415 files changed, 10644475 insertions(+)create mode 100644 Dyn_Init_Scripts/Init_V2.2_Basic.tarcreate mode 100644 Dyn_Init_Scripts/Init_V2.2_Basic/.idea/.gitignorecreate mode 100644 Dyn_Init_Scripts/Init_V2.2_Basic/.idea/Init0411.imlcreate mode 100644 Dyn_Init_Scripts/Init_V2.2_Basic/.idea/encodings.xml.......
.......
.......create mode 100644 Dyn_Init_Scripts/supervisorConfig/supervisord.confcreate 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.git7e9b8f0..f9b4cc6  V2 -> V2
[magx@localhost riskcop]$

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

12. 下载最新代码 

下载最新
# 先进入已下载的项目分支目录后--> 执行 git pull 下载更新的内容
[magx@server-247 riskcop]$ git branch -a
* (detached from origin/V2)V2remotes/origin/HEAD -> origin/masterremotes/origin/V1.0.1remotes/origin/V2remotes/origin/masterremotes/origin/riskcop_robotframeworkremotes/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]$

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Zigbee课程设计系列文章

Zigbee课程设计系列文章 前言题目一、智能温室大棚系统设计要求设计方法文章链接 题目二、基于Zigbee技术的智能家居系统设计要求设计方法 题目三、自习室照明节能系统设计设计要求设计方法 题目四、冷库环境监测系统的设计设计要求设计方法 题目五、扩展题目设计要求 总结 前言…

生态系统NPP及碳源、碳汇模拟、土地利用变化、未来气候变化、空间动态模拟实践技术应用

碳中和可以从碳排放&#xff08;碳源&#xff09;和碳固定&#xff08;碳汇&#xff09;这两个侧面来理解。陆地生态系统在全球碳循环过程中有着重要作用&#xff0c;准确地评估陆地生态系统碳汇及碳源变化对于研究碳循环过程、预测气候变化及制定合理政策具有重要意义。 CASA(…

云运维管理,如何更快,更准,更高效

近几年&#xff0c;云计算在国内发展如火如荼&#xff0c;得益于此&#xff0c;政企的数字化进程也得到加速发展。越来越多的在云上构建和运行核心系统&#xff0c;新的运维问题也随之而来&#xff0c;如何掌握平台部署架构&#xff0c;管理云上云下资源&#xff0c;掌握具体资…

spark的宽依赖,窄依赖

在 Apache Spark 中&#xff0c;依赖关系是指 RDD&#xff08;弹性分布式数据集&#xff09;之间的关系。依赖关系的类型对于理解 Spark 的任务调度、分区和故障恢复等方面至关重要。Spark 中主要有两种类型的依赖关系&#xff1a;窄依赖&#xff08;Narrow Dependency&#xf…

生产实践:基于K8S私有化交付要注意这几点问题

公众号「架构成长指南」&#xff0c;专注于生产实践、云原生、分布式系统、大数据技术分享 在使用 k8s 进行项目私有化部署时&#xff0c;会遇到很多问题&#xff0c;以下把作者经常遇到的一些问题以及需要注意的点分享给各位。 资源依赖问题 在进行私有化部署时&#xff0c;…

ceph-deploy 遇到的使用问题

问题一、RuntimeError: bootstrap-osd keyring not found; run ‘gatherkeys’ 当执行ceph-deploy命令时&#xff0c;提示找不到keyring文件。 解决思路&#xff1a;首先前往部署文件夹/etc/ceph-cluster/&#xff0c;检查密钥文件是否存在&#xff0c;不存在的话执行gatherkey…

期刊缩写查询网站

背景&#xff1a; 参考文献需要期刊缩写 问题描述 期刊不同缩写不同 解决方案&#xff1a; 网址一 网址二 网址三

字符设备驱动开发基础

一. 简介 本文简单了解一下&#xff0c;在字符设备驱动开发开始前对其一些基本认识。简单了解一下&#xff0c;应用程序与驱动的交互原理&#xff0c;以及字符设备驱动开发流程。 二. 字符设备驱动开发流程 1. 在 Linux 中一切皆为文件&#xff0c;驱动加载成功以后会在“…

数据爬虫:获取申万一级行业数据

目录 1. 获取访问接口 2. 链接网址 3. 链接名单 免责声明&#xff1a;本文由作者参考相关资料&#xff0c;并结合自身实践和思考独立完成&#xff0c;对全文内容的准确性、完整性或可靠性不作任何保证。同时&#xff0c;文中提及的数据仅作为举例使用&#xff0c;不构成推荐…

JAVA 导出报表 大数据量 sxssfworkbook的使用

sxssfworkbook 之前报表导出使用得是XSSFWorkbook 但是导出数据量过大的时候经常出现OOM&#xff0c;现在发现使用sxssfworkbook 减少内存压力 官网是这样介绍的&#xff1a; SXSSF (package: org.apache.poi.xssf.streaming) is an API-compatible streaming extension of X…

网站高性能架构设计——高性能数据库集群

从公众号转载&#xff0c;关注微信公众号掌握更多技术动态 --------------------------------------------------------------- 一、高性能数据库简介 1.高性能数据库方式 读写分离&#xff1a;将访问压力分散到集群中的多个节点&#xff0c;没有分散存储压力 分库分表&…

Maven 私服搭建

文章目录 配置模板servermirror RELEASE、SNAPSHOT版本区别发行版&#xff08;RELEASE&#xff09;快照&#xff08;SNAPSHOT&#xff09; mvn deploy 配置模板 server <!--第一个server-id要和下面的mirror中的id一致&#xff0c;代表拉取是也需要进行身份校验--> <…

Unity_使用FairyGUI搭建登录页面

Unity_使用FairyGUI搭建登录页面 1. 使用FairyGUI准备一个UI界面&#xff0c;例如&#xff1a;以下登录 2. 发布导出&#xff08;发布路径设置为Unity的Asset下任何路径&#xff09; 3. Unity编辑器安装FairyGUI包资源&#xff08;在资源商店找见并存储为我的资源&#xff0c;…

百度智能云战略与咨询高级总监詹颖:每个人都能在大模型驱动的数字化生态中找到立足之地

“ 大模型是皇冠上的明珠。 ” 整理 | 王娴 编辑 | 云舒 出品&#xff5c;极新 2023年11月28日&#xff0c;极新AIGC行业峰会在北京东升国际科学园顺利召开&#xff0c;百度智能云战略与咨询高级总监詹颖女士在会上做了题为《生成式 AI 驱动企业应用创新》的演讲。 重点…

了解宝宝健康第一步:做好华大基因无创产前筛查检测

近年来&#xff0c;高龄产妇明显增加&#xff0c;多因素的影响导致出生缺陷发生率呈总体上升趋势&#xff0c;出生缺陷已经成为重大公共卫生问题之一&#xff0c;更是影响人口质量的重要风险因素。孕前、孕期到产后的出生缺陷综合防控三级体系中&#xff0c;做好产前筛查是阻断…

python的运行原理

Python本身不能直接调动电脑的运行。但是&#xff0c;Python可以利用操作系统提供的接口来与计算机进行交互。比如&#xff0c;Python可以使用操作系统提供的API来执行某些任务&#xff0c;如创建、读取、修改、删除文件&#xff0c;启动程序或服务等。Python也可以利用第三方模…

通过fpmarkets与自媒体导师学习经验,避免踩坑

举一个例子&#xff0c;从fpmarkets与自媒体导师学习的负面经验&#xff0c;避免各位投资者踩坑。这个要从fpmarkets刚踏入外汇交易市场的第二年说起&#xff0c;偶然的一次&#xff0c;当fpmarkets看到一个可以不用花钱就可以学习交易培训课程时&#xff0c;就如同中了大奖一样…

高效记住GDI+常用绘图

1. 绘图质量&#xff1a;设置Graphics属性 主要有&#xff1a;根据首字母简写为&#xff1a;ISCT (您可以记为: Is CT?——引伸记忆&#xff1a;是否CT检查&#xff1f; 【CT为医院的“CT检查”&#xff0c;这里为检查绘图质量】 比如要获得最高质量的图像&#xff0c;可以…

股票关键指标

股票市场有许多关键指标&#xff0c;投资者通常使用这些指标来评估一支股票的潜在价值、风险和投资机会。以下是一些常见的股票关键指标&#xff1a; 1. 市盈率&#xff08;P/E比&#xff09;&#xff1a; 衡量一支股票当前价格与每股收益之比&#xff0c;是评估股票相对估值的…

【STM32单片机】贪吃蛇游戏设计

文章目录 一、功能简介二、软件设计三、实验现象联系作者 一、功能简介 本项目使用STM32F103C8T6单片机控制器&#xff0c;使用IIC OLED模块、按键等。 主要功能&#xff1a; 系统运行后&#xff0c;OLED显示游戏界面&#xff0c;可通过K1-K4键控制蛇的方向&#xff0c;当蛇吃…