Git---->Linux common commands + trunk and branch merge, conflicts occur + when urgent tasks come, files are temporarily stored + files are ignored and not submitted

1. Git basic structure

Insert picture description here

2. Create a project in the git working directory: the following directory

个人信息,没有就创建

git config -l # View personal information
git config --global user.name “xxx” # set personal name global settings
git config --global user.email “xxx” # set personal email

pwd :当前目录
ll 目录下所有文件
git status 查看每个文件状态(红色:该文件没有到本地仓库、暂存区,只是在工作区)
git add a.txt 把文件添加到暂存区
git commit -m "提交了一个a.txt文件"  把暂存区所有文件提交到本地仓库 -m:加批注
git add . 提交所有文件到暂存区
vi user.txt  进入文件内部修改文件内容
git基本命令

git配置
 全局设置
git config --global user.name yourname
git config --global user.email youremail
 局部设置  争对某个仓库有效
git config --local user.name yourname
git config --local user.email youremail

git init  
	 echo '内容'>  文件名    覆盖
	 echo '内容'>>  文件名   追加

	 生成隐藏文件夹.git   代表git仓库 

	 vi readme   编辑一个文件	 有则打开编辑,无创建空的文件并打开编辑
	 	按a进入编辑模式,dd:删除一行  ,yy:复制一行 ,p:粘贴 
	 	:wq  保存退出    :q 不保存退出   :q!  强制退出
git add 文件名/文件夹     git add .      暂存区
git  commit  -m '操作的描述'
git reset head  取消add操作  把暂存区的文件撤销

git  status   查看git文件状态
git log  查看过去(历史)版本
		--oneline  简洁显示
		-n行数  查看最新的几行
git reset --hard   commit_id    回退到历史版本
git reflog  查看历史版本的将来版本


分支
git branch 分支名
git branch -av   查看分支
git  checkout  分支名  切换到分支下

切换到master下操作合并  
git merge 分支名    合并分支   有可能遇到冲突  


远程仓库

	push(推送代码)  pull(拉取)
git remote add origin(缺省)  远程仓库地址(ssh  https)
git remote -v   查看是否关联远程仓库
git  push  --all  推送所有
git push origin master

git fetch 远程仓库地址(ssh  https)  拉取代码  不会合并
git  merge  分支名

git  pull  远程仓库地址(ssh  https) 拉取代码

gitk --all  查看git的仓库的树信息(工作树)

Insert picture description here

initialization

git init

Insert picture description here
If the initialization is successful, the file
Insert picture description here
flow chart is:
Insert picture description here

3. Manually modify the file a.txt

Insert picture description here
At this time, the work area file is modified, then the work area file is different from the local library at this time. If you check the status again, it will report red.
Insert picture description here
Then we need to add to the temporary storage area and the local library again, (temporary storage Area does not need to be annotated)

4. Example

Insert picture description here
Insert picture description here
Insert picture description here
The graphical interface is as follows:Insert picture description here

3.1 Problem: The trunk and branches merge and conflict

Insert picture description here
Select the content you need to stay, and delete the content automatically generated by git
Insert picture description here
Delete useless branches
Insert picture description here

Edit commentInsert picture description here

3.2 When an urgent task comes and needs to be temporarily stored, 1. temporarily store 2. then take out

Insert picture description here
Insert picture description here

3.3 Ignore files and do not submit: For example, target bytecode files do not submit

Insert picture description here
Insert picture description here
If you still want that file not to be submitted, add the condition vi .gitignore to .ignore
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_39773004/article/details/108732337