Centos7 配置Git

news2024/11/15 23:52:34

随笔记录

目录

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]$

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

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

相关文章

基于ssm电影网站源码和论文

随着Internet的发展&#xff0c;人们的日常生活已经离不开网络。未来人们的生活与工作将变得越来越数字化&#xff0c;网络化和电子化。它将是直接管理电影网站的最新形式。本论文是以构建电影网站为目标&#xff0c;使用 java技术制作&#xff0c;由管理员和用户两大部分组成。…

GEM5 McPAT NoC教程: xml设置汇总-2023版

简介 McPAT的xml有一些参数需要设置&#xff0c;noc的部分很多Gem5ToMcpatparser没有设置&#xff0c;也没有给出如何设置的条件。尤其是和活动相关的total access&#xff0c;不知道具体怎么设置&#xff0c;也不知道如何从gem5 stats.txt中导出。本文提供了2023年的收集到ge…

【强化学习-读书笔记】表格型问题的 Model-Free 方法

参考 Reinforcement Learning, Second Edition An Introduction By Richard S. Sutton and Andrew G. Barto无模型方法 在前面的文章中&#xff0c;我们介绍的是有模型方法&#xff08;Model-Based&#xff09;。在强化学习中&#xff0c;"Model"可以理解为算法…

【CSS】前端点点点加载小点样式css动画过程实现

对话的 ... 加载动画&#xff0c;直接用 CSS 就可以实现&#xff0c;样式可以自己改&#xff0c;逻辑大差不差 <div class"loading-text"><span class"dot1"></span><span class"dot2"></span><span class&quo…

动态面板简介以及ERP原型图案列

动态面板简介以及ERP原型图案列 1.Axure动态面板简介2.使用Axure制作ERP登录界面3.使用Asure完成左侧菜单栏4.使用Axuer完成公告栏5.使用Axuer完成左边侧边栏 1.Axure动态面板简介 在Axure RP中&#xff0c;动态面板是一种强大的交互设计工具&#xff0c;它允许你创建可交互的…

pgAdmin 4的安装与使用

一、pgAdmin 4安装 ①访问pgAdmin官网&#xff0c;下载路径如下&#xff1a; pgAdmin下载 ②选择个人电脑所对应的系统&#xff0c;我的电脑是Windows10系统&#xff0c;所以选择Windows ③选择所需要的pgAdmin版本&#xff0c;我选择的是最新的v7.3版本 ④下载完成后双击pg…

Bootstrap在弹框Povoper中显示图片

项目开发需要实现这个效果&#xff0c;当鼠标划过这个按钮的时候&#xff0c;会显示出指定的图片出来 HTML代码 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><meta name"viewport" content"…

《Linux C编程实战》笔记:文件读写

Linux c下文件读写可用creat&#xff0c;open&#xff0c;close&#xff0c;read&#xff0c;write&#xff0c;lseek等函数。对于跨平台的程序还是用C标准库的fopen等。 open #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int open …

【️什么是分布式系统的一致性 ?】

&#x1f60a;引言 &#x1f396;️本篇博文约8000字&#xff0c;阅读大约30分钟&#xff0c;亲爱的读者&#xff0c;如果本博文对您有帮助&#xff0c;欢迎点赞关注&#xff01;&#x1f60a;&#x1f60a;&#x1f60a; &#x1f5a5;️什么是分布式系统的一致性 &#xff1f…

基于QTreeWidget实现带Checkbox的多级组织结构选择树

基于QTreeWidget实现带Checkbox的多级组织结构选择树 采用基于QWidgetMingw实现的原生的组织结构树 通过QTreeWidget控件实现的带Checkbox多级组织结构树。 Qt相关系列文章&#xff1a; 一、Qt实现的聊天画面消息气泡 二、基于QTreeWidget实现多级组织结构 三、基于QTreeWidget…

Git忽略已经提交的文件

原理类似于 Android修改submodule的lib包名

FastAdmin后台安装出现2054错误的解决办法

用Navicat修改密码验证方式。MySQL Workbench的Server菜单中的Users and Privileges菜单中似乎不支持此项修改。 修改完毕以后也许会报错&#xff1a; Access denied for user ‘root‘‘localhost‘ (using password: YES) 用以下命令无密进入mysql。 C:\Program Files\MySQ…

基于SSM的校友录设计与实现

末尾获取源码 开发语言&#xff1a;Java Java开发工具&#xff1a;JDK1.8 后端框架&#xff1a;SSM 前端&#xff1a;采用JSP技术开发 数据库&#xff1a;MySQL5.7和Navicat管理工具结合 服务器&#xff1a;Tomcat8.5 开发软件&#xff1a;IDEA / Eclipse 是否Maven项目&#x…

Qt实现的聊天画面消息气泡

Qt实现的聊天画面消息气泡 采用基于QWidgetMingw实现的原生的消息气泡 通过覆写QWidget::paintEvent(QPaintEvent *event)方法&#xff0c;每当窗口尺寸变化时都会触发paintEvent事件&#xff0c;在覆写QWidget::paintEvent(QPaintEvent *event)方法中重新绘制聊天气泡在QListW…

Unity2023.3(Unity6)版本开始将可以发布WebGPU

翻译一段官网上的话&#xff1a; 利用Unity 2023.3(正式发布时应该称为Unity6)中最新的WebGPU图形API集成&#xff0c;尝试最大限度的提升您的网络游戏的真实感。 通过与谷歌的战略合作&#xff0c;Unity实时3D平台的强大的图形功能现在为图形丰富的网络游戏进行微调&#xff0…

好用的硬盘分区工具,傲梅分区助手 V10.2

傲梅分区助手软件可以帮助用户在硬盘上创建、调整、合并、删除分区&#xff0c;以及管理磁盘空间等操作。它可以帮助你进行硬盘无损分区操作。 支持系统 目前这款软件支持 Windows 7、Windows 8、Windows 10、Windows 11 等个人系统&#xff0c;还支持 Windows 2012/2016/2019…

城市货车通行码二维码解析

目录 说明 界面 下载 城市货车通行码二维码解析 说明 二维码扫描信息为&#xff1a; tmri://12123?ywlx1041&ewmeyJ0eHpiaCI6IjUxMDcwMDAwMDE0MyIsInR4em1jIjoiQeivgSIsImhwemwiOiIwMiIsImhwaG0iOiLlt51CMkwzMjYiLCJrc3JxIjoiMjAyMS0xMS0yOCIsImpzcnEiOiIyMDIyLTEyL…

蓝桥杯专题-真题版含答案-【祖冲之割圆法】【错误票据】【显示为树形】【汉字相乘】

Unity3D特效百例案例项目实战源码Android-Unity实战问题汇总游戏脚本-辅助自动化Android控件全解手册再战Android系列Scratch编程案例软考全系列Unity3D学习专栏蓝桥系列ChatGPT和AIGC &#x1f449;关于作者 专注于Android/Unity和各种游戏开发技巧&#xff0c;以及各种资源分…

yolov8实战第一天——yolov8部署并训练自己的数据集(保姆式教程)

​​​​​​yolov8实战第二天——yolov8训练结果分析&#xff08;保姆式解读&#xff09;-CSDN博客 YOLOv8是一种基于深度神经网络的目标检测算法&#xff0c;它是YOLO&#xff08;You Only Look Once&#xff09;系列目标检测算法的最新版本。YOLOv8的主要改进包括&#xf…

5G工业网关视频传输应用

随着科技的不断进步&#xff0c;5G网络技术已经成为了当前最热门的话题之一。而其中一个引人注目的领域就是5G视频传输和5G工业网关应用。在传统网络通信中&#xff0c;由于带宽和延迟的限制&#xff0c;视频传输常常受到限制&#xff0c;而工业网关应用也存在着链路不稳定、数…