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.rhkb.cn/news/219761.html

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

相关文章

堆与二叉树(上)

本篇主要讲的是一些概念&#xff0c;推论和堆的实现&#xff08;核心在堆的实现这一块&#xff09; 涉及到的一些结论&#xff0c;证明放到最后&#xff0c;可以选择跳过&#xff0c;知识点过多&#xff0c;当复习一用差不多&#xff0c;如果是刚学这一块的&#xff0c;建议打…

微信小程序---自定义组件

目录 1.局部引用组件 2.全局引用组件 3.组件和页面的区别 4.自定义组件样式 5.properties属性 6.data和properties的区别 7.数据监听器 8.纯数据字段 9.自定义组件-组件的生命周期 lifetimes节点 10.组件所在的页面的生命周期 pageLifetimes节点 11.插槽 &#x…

安全算法(二):共享密钥加密、公开密钥加密、混合加密和迪菲-赫尔曼密钥交换

安全算法&#xff08;二&#xff09;&#xff1a;共享密钥加密、公开密钥加密、混合加密和迪菲-赫尔曼密钥交换 本章介绍了共享密钥加密、公开密钥加密&#xff0c;和两种加密方法混合使用的混合加密方法&#xff1b;最后介绍了迪菲-赫尔曼密钥交换。 加密数据的方法可以分为…

Transformer的学习

文章目录 Transformer1.了解Seq2Seq任务2.Transformer 整体架构3.Encoder的运作方式4.Decoder的运作方式5.AT 与 NAT6.Encoder 和 Decoder 之间的互动7.Training Transformer 1.了解Seq2Seq任务 NLP 的问题&#xff0c;都可以看做是 QA&#xff08;Question Answering&#x…

RFID工业识别系统的优势和价值

RFID是物联网感知层最重要的组成部分之一&#xff0c;它可以通过感知物品来实现智能化识别和管理&#xff0c;实现不同设备之间的互联。本文将深入探讨RFID工业识别系统的优势和价值&#xff0c;并探讨其实际应用的案例情况。 RFID工业识别系统的优势和价值 RFID作为物联网感知…

程序人生15年人生感悟

计算机程序员并不是一件什么高大上的职业。而仅仅是一份普通的工作。就像医生能治病救人&#xff0c;我们能治蓝屏救程序&#xff0c;我们都在为这个世界默默的做出自己的贡献。刻意或无意宣扬某个职业高大上&#xff0c;其实质是对其它行业从业者的不公平。但是有些人却常常这…

[计网02] 数据链路层 笔记 总结 详解

目录 数据链路层概述 主要功能 封装成帧 透明传输 差错检测 冗余码 差错控制 检错编码 纠错编码 奇偶效验法 CRC循环冗余码 静态分配信道 频分多路复用FDM 时分多路复用TDM 波分多路复用WDM 码分多路复用CDM 随机访问介质的访问控制 ALOHA CSMA CSMA/CD CSMA/…

Python 自动化之收发邮件(一)

imapclient / smtplib 收发邮件 文章目录 imapclient / smtplib 收发邮件前言一、基本内容二、发送邮件1.整体代码 三、获取邮件1.整体代码 总结 前言 简单给大家写个如何用Python进行发邮件和查看邮件教程&#xff0c;希望对各位有所帮助。 一、基本内容 本文主要分为两部分…

Temu、Shein、OZON测评自养号,IP和指纹浏览器的优缺点分析

随着全球电子商务的飞速发展&#xff0c;跨境电商环境展现出巨大的潜力和机遇。然而&#xff0c;跨境卖家们也面临着更激烈的竞争、更严格的规定和更高的运营成本等挑战。为了在这个环境中脱颖而出&#xff0c;一些卖家尝试使用自动脚本程序进行浏览和下单。然而&#xff0c;这…

JAVA基于物联网技术的智慧校园电子班牌原生微信小程序源码

智慧校园特色应用模块&#xff1a; 通知管理、视频管理、考勤管理、评价管理、图片管理、请假管理、家长留言、值日管理、成绩管理、离校管理、考场管理。 一、智慧校园是什么&#xff1f;如何定义&#xff1f; 智慧校园的定义&#xff1a;是指以物联网为核心的智慧化的校园学习…

【C 剑指offer】有序整型矩阵元素查找 {杨氏矩阵}

目录 题目内容&#xff1a; 思路&#xff1a; 图形演示&#xff1a; 复杂度分析 C源码&#xff1a; /** *************************************************************************** ******************** ********************* ******…

使用Log4j与log4j2配置mybatisplus打印sql日志

环境&#xff1a;项目非完全spring项目&#xff0c;没有spring的配置文件。执行sql时老是不打印sql语句。因此进行修改&#xff0c;过程比较坎坷&#xff0c;记录一下。 我尝试使用log4j和log4j2进行配置 最终把这两种全部配置记录上 Log4j配置 如果项目用的是log4j需要进行配置…

超详细 | 哈里斯鹰优化算法原理、实现及其改进与利用(Matlab/Python)

测试函数为F9 在MATLAB中执行程序结果如下&#xff1a; 在Python中执行程序结果如下&#xff1a; 哈里斯鹰优化算法(Harris Hawks Optimization , HHO)是 Heidari等[1]于2019年提出的一种新型元启发式算法&#xff0c;设计灵感来源于哈里斯鹰在捕食猎物过程中的合作行为以及突…

路由器原理

目录 一.路由器 1.路由器的转发原理 2.路由器的工作原理 二.路由表 1.路由表的形成 2.路由表表头含义 直连&#xff1a; 非直连&#xff1a; 静态 静态路由的配置 负载均衡&#xff08;浮动路由&#xff09; 默认路由 动态 三.交换与路由对比 一.路由器 1.路由器…

【物联网】EMQX(二)——docker快速搭建EMQX 和 MQTTX客户端使用

一、前言 在上一篇文章中&#xff0c;小编向大家介绍了物联网必然会用到的消息服务器EMQ&#xff0c;相信大家也对EMQ有了一定的了解&#xff0c;那么接下来&#xff0c;小编从这篇文章正式开始展开对EMQ的学习教程&#xff0c;本章节来记录一下如何对EMQ进行安装。 二、使用…

人工智能与自动驾驶:智能出行时代的未来之路

一、前言 首先&#xff0c;我们先来说下什么是人工智能&#xff0c;人工智能&#xff08;Artificial Intelligence&#xff0c;简称AI&#xff09;是一门研究如何使计算机系统能够模拟、仿真人类智能的技术和科学领域。它涉及构建智能代理&#xff0c;使其能够感知环境、理解和…

【Windows】windows11右键默认显示更多选项的办法

Windows11系统的右键菜单显示&#xff0c;需要多点一次“显示更多选项”才能看到所有菜单内容&#xff0c;按下面步骤简单设置一下就能恢复成Windows经典的右键菜单显示。 1. 2.输入命令【reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a…

YOLOv3-YOLOv8的一些总结

0 写在前面 这个文档主要总结YOLO系列的创新点&#xff0c;以YOLOv3为baseline。参考(抄)了不少博客&#xff0c;就自己看看吧。有些模型的trick不感兴趣就没写进来&#xff0c;核心的都写了。 YOLO系列的网络都由四个部分组成&#xff1a;Input、Backbone、Neck、Prediction…

C++ 二叉搜索树(BST)的实现(非递归版本与递归版本)与应用

C 二叉搜索树的实现与应用 一.二叉搜索树的特点二.我们要实现的大致框架三.Insert四.InOrder和Find1.InOrder2.Find 五.Erase六.Find,Insert,Erase的递归版本1.FindR2.InsertR3.EraseR 七.析构,拷贝构造,赋值运算符重载1.析构2.拷贝构造3.赋值运算重载 八.Key模型完整代码九.二…

antd-table:通过rowClassName实现斑马条纹样式+通过rowSelection实现单选功能效果——基础积累

斑马条纹 对于element-ui是有个stripe斑马条纹的属性的&#xff0c;最终呈现的效果如下&#xff1a; antd-table中是没有这个属性的&#xff0c;但是可以通过rowClassName&#xff1a;可以给对应行添加指定类名。 实现方法&#xff1a; <a-table:rowClassName"getRo…