git基础(二)

实验四:邮箱账号设置 目的:为了以后在和github交互的时候 区分提交着是谁??
	user.name  user.email 
	git config 
		/*
			 --global  1      (很少)       use global config file  全局: 给整个计算机设置邮箱和账号  --》任何用户创建的git仓库都使用这个邮箱和账号
			 --system  2      (常用)       use system config file  用户: 给当前用户设置邮箱和账号    --》用户新建的任何git仓库都使用这个邮箱和账号
			 --local   3            use repository config file 当前项目(仓库):            --》当前这个仓库设置邮箱和账号  
		*/
		优先级: 离仓库最近的设置生效 3 》 2 》 1
		
	git config --system user.name ''
	git config --system user.email ''
		
	//如果 local 级别的邮箱和姓名 (.git/config )	
		注意:要执行git 命令必须在.git文件夹的外层
		[user]
			name = yzj
			email = 123@qq.com	
			
	vi 编辑器 删除一整行
		vi 文件
		调整光标到删除行的位置 直接按 dd	
		:wq
	
	git config user.name 
	git config user.email 
    
	// 如果设置 system 级别的邮箱和姓名 (用户家目录 )
		windows 用户家目录(C:\Users\xuanqiyan\.gitconfig)
		mac     用户家目录 (/Users/xuanqiyan/.gitconfig)
	
	cd ~
	vi .gitconfig
实验五:对已经提交(commit)的文件再次编辑
	创建新的test文件夹
	cd test
	touch a.txt
	echo '1111' >> a.txt
	git add .
	git commit -m 'di 1 ge'
	
	echo '2222' >> a.txt // 效果: 将对象区中的a.txt 重新拉回到工作区
	
	git status
		/*
			On branch master
			Changes not staged for commit:
			  (use "git add <file>..." to update what will be committed) // add 将修改的a.txt文件提交到暂存区
			  (use "git checkout -- <file>..." to discard changes in working directory) // 撤销修改
			
				modified:   a.txt
			
			no changes added to commit (use "git add" and/or "git commit -a")
		*/
	方式一: 保存修改
		git add  .
		git commit -m 'di 2 ge'
	方式二: 撤销修改   
		git checkout -- a.txt 

实验六:对已提交的(commit)文件执行删除操作
	创建新的test文件夹
	cd test
	touch a.txt
	echo '1111' >> a.txt
	git add .
	git commit -m 'di 1 ge'		
	
	git rm a.txt  // 把删除的a.txt文件 拉到暂存区
	git status
		/*
			On branch master
			Changes to be committed:
			  (use "git reset HEAD <file>..." to unstage)// stage 暂存 unstage 工作区
			
				deleted:    a.txt
		*/
	方式一:确定删除
		git commit -m '彻底删除 '
		// 提交不是一个文件 而是一个动作 在版本中把a.txt 删除	
		还能不能还原a.txt文件 ??	可以 --》 版本回退  
		
	方式二:撤销删除
		将暂存的删除的a.txt 文件 拉回到工作区
		git reset HEAD a.txt
			
		git checkout -- a.txt 撤销删除命令	
		/*	
			checkuot --  文件 (动作:文件名) 动作:modified修改 delete删除
			checkout 相当于移除工作区文件名前面动作,一般这样的行为叫做检出
		'*/
		
		ll 查看 还原了a.txt

git忽略

新建.gitignore 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值