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,一经查实,立即删除!

相关文章

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

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

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

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

字符设备驱动开发基础

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

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

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

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

从公众号转载&#xff0c;关注微信公众号掌握更多技术动态 --------------------------------------------------------------- 一、高性能数据库简介 1.高性能数据库方式 读写分离&#xff1a;将访问压力分散到集群中的多个节点&#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;做好产前筛查是阻断…

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

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

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

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

【腾讯云 HAI域探秘】借助高性能服务HAI快速学会Stable Diffusion生成AIGC图片——必会技能【微调】

目录 Stable Diffusion基本使用方法 学术加速测试 配置中文插件 Prompt与Negative prompt 采样器说明 人像生成 水光效果 微调的使用 图像生成种子/seed使用 附加/Extra 微调实例测试 图生图微调 ​编辑 使用蒙版微调 Stable Diffusion基本使用方法 环境配置&am…

【机器学习】亚马逊云科技基础知识:以推荐系统为例。你知道机器学习的关键所在么?| 机器学习管道的各个阶段及工作:以Amazon呼叫中心转接问题为例讲解

有的时候,暂时的失利比暂时胜利要好得多。 ————经典网剧《mao pian》,邵半仙儿 🎯作者主页: 追光者♂🔥 🌸个人简介: 💖[1] 计算机专业硕士研究生💖 🌿[2] 2023年城市之星领跑者TOP1(哈尔滨)🌿 🌟[3] 2022年度博客之星人工智能领域TOP

大象慧云:从设立分部到迁移总部 与贵阳贵安共筑税务数字化未来

近年来&#xff0c;贵阳贵安着力提升政务服务水平&#xff0c;通过擦亮“贵人服务”品牌&#xff0c;持续优化营商环境。在这样的环境下&#xff0c;再加上“大数据基因”&#xff0c;对于希望在大数据领域大展拳脚的企业来说&#xff0c;贵阳贵安无疑成为了一个极具吸引力的选…

【ZYNQ】AXI4总线接口协议学习

建议翻看着底部的参考文档资料和本文一起辅助阅读 本文带你详细的了解AXI总线协议&#xff0c;并且基于官方手册&#xff0c;能够提高你的手册阅读能力。 什么是AXI AXI 的英文全称是 Advanced eXtensible Interface&#xff0c;即高级可扩展接口&#xff0c;它是 ARM 公司所提…

自激活T细胞为肿瘤免疫治疗提供新思路—高分文献分享

CD28是在所有小鼠和人类T细胞上表达的共刺激受体&#xff0c;用来调节T细胞受体(TCR) 的响应。异常的CD28 信号传导是癌症、自身免疫和病毒感染中T细胞功能障碍的决定性特征之一。早期的一些研究表明CD28对CD4 T细胞更重要&#xff0c;但也有越来越多的研究者发现其对CD8 T细胞…

HAT(CVPR 2023):Hybrid Attention Transformer for Image Restoration

HAT ​ 论文地址&#xff1a;HAT: Hybrid Attention Transformer for Image Restoration ​ 代码地址&#xff1a;XPixelGroup/HAT: CVPR2023 - Activating More Pixels in Image Super-Resolution Transformer 摘要 ​ 通过归因分析attribution analysis method - Local …

智能科技企业网站搭建的作用是什么

随着科学技术快速提升&#xff0c;各种智能产品随之而来&#xff0c;每个赛道里都涌入了大量企业商家&#xff0c;有些热门产品更是广受关注&#xff0c;对企业来说&#xff0c;形象、品牌、信息等方面需要完美呈现到用户眼前&#xff0c;而网站无疑是很好的工具。 企业通过【…

lwIP 细节之四:recv 回调函数是何时调用的

使用 lwIP 协议栈进行 TCP 裸机编程&#xff0c;其本质就是编写协议栈指定的各种回调函数。将你的应用逻辑封装成函数&#xff0c;注册到协议栈&#xff0c;在适当的时候&#xff0c;由协议栈自动调用&#xff0c;所以称为回调。 注&#xff1a;除非特别说明&#xff0c;以下内…

常用whl文件地址整理

文章目录 一、Deep Graph Library&#xff08;DGL&#xff09;二、torch torchvision torchaudio三、numpy四、pandas可留言其他whl文件地址&#xff0c;不定期更新 一、Deep Graph Library&#xff08;DGL&#xff09; DGL是一个专门用于深度学习图形的Python包, 一款面向图神…

代码随想录算法训练营第50天| 123.买卖股票的最佳时机III 188.买卖股票的最佳时机IV

JAVA代码编写 123.买卖股票的最佳时机III 给定一个数组&#xff0c;它的第 i 个元素是一支给定的股票在第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你最多可以完成 两笔 交易。 **注意&#xff1a;**你不能同时参与多笔交易&#xff08;你必须在再次购买前出…