Linux下git的简单使用

git是什么?

git的两大作用

1.进行版本管理(版本控制)

2.多人协作

安装git

yum install git

client客户端和server服务端

git如何使用

git --vecsion 查看是否安装了git

将你的远端仓库拷贝过来

git clone 地址

[ycc@iZbp1czm5p4go6poel4l8tZ ~]$ git clone https://gitee.com/Sorrow-is-meaningless/room-c-in-the-north-and-south.git

将文件拷贝到你的仓库目录下

再将该文件添加到本地仓库里

这里补充一点,创建仓库时

记得添加.gitignore文件,里面有一些后缀文件,凡是带这些后缀名的文件提交时都会过滤掉。

三板斧

git add . 当前目录下所有没有添加过的文件

git commit -m "提交日志"

[ycc@iZbp1czm5p4go6poel4l8tZ linux_c]$ git commit -m "提交测试"
[master 61a5b0b] 提交测试
 1 file changed, 32 insertions(+)
 create mode 100644 mycode.c

git push

git log查看提交记录

git stauct 查看没有上传的文件

[ycc@iZbp1czm5p4go6poel4l8tZ linux_c]$ git stauct
git: 'stauct' is not a git command. See 'git --help'.
[ycc@iZbp1czm5p4go6poel4l8tZ linux_c]$ git status
# On branch master
nothing to commit, working directory clean
[ycc@iZbp1czm5p4go6poel4l8tZ linux_c]$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#   (use "git push" to publish your local commits)
#
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	new file:   test4.c
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#	test3.c

vim .gitignore(查看过滤的后缀文件)

1: .gitignore  ⮀                                                                                  ⮂⮂ buffers 
  1 # Prerequisites
  2 *.d
  3 
  4 # Object files
  5 *.o
  6 *.ko
  7 *.obj
  8 *.elf
  9 
 10 # Linker output
 11 *.ilk
 12 *.map
 13 *.exp
 14 
 15 # Precompiled Headers
 16 *.gch
 17 *.pch
 18 
 19 # Libraries
 20 *.lib
 21 *.a
 22 *.la
 23 *.lo
 24                                                                                                             
 25 # Shared objects (inc. Windows DLLs)
 26 *.dll
 27 *.so
 28 *.so.*
 29 *.dylib

修改后缀文件记住添加 *

git首次使用需要配置邮箱和用户名(需要执行两条命令)

git config --global user.name "Your name"

git config --global user.email "[email protected]"

注意:要分开执行,其中第一句输入你的名字,第二句输入你的email

作用

为了方便找到代码负责人,对代码进行溯源

猜你喜欢

转载自blog.csdn.net/2202_75625589/article/details/131869546
今日推荐