The "GIT" Demon King of Work Fighting Monsters! ! !

## 工作打怪之"**GIT**"大魔王!!!

Reason:
I have been tortured by git from yesterday to now. From submission to subsequent misoperation and merge, I was on the verge of collapse. Ask the boss for these simple questions. The silence of the boss made me feel helpless, so for myself With only a little bit of self-esteem, I decided to learn GIT from scratch, considering that the teammates wandering in the Novice Village may still be doing tasks like "helping Aunt Li next door find the hen" all day, and have not experienced the "big devil GIT" So he wrote this "GIT Survival Guide".
Body: Do
n't say much, start now!
1. What is GIT?
Baidu Encyclopedia:
Git (pronounced /gɪt/.) is an open source distributed version control system that can effectively and quickly handle the version management of projects from very small to very large. [1] Git is an open source version control software developed by Linus Torvalds to help manage Linux kernel development.
Personal understanding:
Daguai archives, have you ever played the big board "Second Robot War" with 15 yuan each? , Play the last level off. When you don’t save it, can you return to the first level decisively. GIT is this stuff to save your archives, so that even if you are lying on the ground by Hugh, or if you are lying on the ground, you don’t need to restart from the first level and change the archive ( Version) is fine. Of course, this is only part of the advantages of GIT, and there are branches that have to be said. This is a bit similar to doing math test papers in high school. One test paper is issued, and everyone will work together. I will choose and fill in the blanks at the same table. The front table is a big topic, and the final copy is made. In short, everyone contributes and all have to play. GIT also provides this mode. Multiple people develop at the same time, and the final branch will be OK as soon as it is merged!

This is the view of IDEA. This is probably what it means: This is the view of IDEA, which is probably what it means
2. Using GIT
is a beginner, so it is not convenient to study the underlying principles, and it is directly oriented to work and step into use.
Install GIT:
uninstall the installation package from the official website: click to play for a year!
OK! Some students may not find that the above is a hyperlink, so students can quit the group chat by themselves!
Insert picture description here
No, this is the homepage of GIT's official website, start downloading!
Insert picture description here
Firstly!
Insert picture description here
Then so!
Insert picture description here
Then it's ok!
Insert picture description here
--------------100% download is complete!
Find the installation package:
Insert picture description here
double-click to start the installation:
Insert picture description here
select the configuration:
Insert picture description here
------------ding! The installation is complete, check it out:
Insert picture description here
there is it! Then click any one! I personally suggest not to use the third little tortoise. It will make you learn it as soon as you learn it, and you will waste it when you do it. The second is a small blackboard style, and the first is Linux. It is easy to use and decisive first. Kind!
Insert picture description here
Open this interface, although it is huge, but there is no way!
Brief introduction:
Insert picture description here
(1): Host name
(2): Address
(3): Version
(4): Path
Hmm! Concise and concise, I am worthy of it!
GIT first step, public key diapers!
You have to do this with me:
first:

git config --global user.name "你的名字"

git config --global user.email "------------你的邮箱地址[email protected]"

The user name depends on what you like, usually something easy to remember, or some abbreviation, just choose your own mailbox. (It is worth mentioning that when I first generated it, I did not execute the last two commands, but wrote the mailbox and user name directly in the configuration. The generated public key directly displayed my mailbox, and then I couldn't use it; Later, when I wrote it step by step, the public key that was generated was actually not the mailbox, but the name of the computer. At that time, I always thought that the mailbox was correct, and it was only after others pointed me that I learned. Of course, what is the specific reason for me? Do not understand, a rookie, welcome to add!)
Then this:
Insert picture description here
Nice! My path is like this, usually under your users. shh file. Of course, if you appoint the boy yourself, then I don’t know where to find it, Xiaobai +1!
Then let us open the file with the suffix of .pud and open it in Notepad.
Insert picture description here
Then you will see a bunch of characters fuck him! Let C take it away!
Insert picture description here
When you get here, if you are working on the first day, just send this to your boss, and he will send you a git link.
You can directly pull down the project.
Dididi is like this

https://github.com/--------滴滴滴马赛克!

OK then wait for the next drop-down specific pull, first talk about the basic commands of GIT
what! Said a long time actually forgot to say that the public key is a hammer! Make up:

The first is the official description:
a public key (Public Key) and a private key (Private Key) is obtained by means of a key algorithm (i.e. a public key and a private key), the public key is disclosed The private key is the non-public part. The public key is usually used to encrypt session keys, verify digital signatures, or encrypt data that can be decrypted with the corresponding private key. The key pair obtained through this algorithm can be guaranteed to be unique in the world. When using this key pair, if one key is used to encrypt a piece of data, the other key must be used to decrypt it. For example, if you encrypt data with a public key, you must decrypt it with a private key. If you encrypt data with a private key, you must also decrypt it with the public key. Otherwise, the decryption will not succeed.
Then personal understanding:

公钥 公钥 顾名思义就是公共的钥匙啦!
GIT 是一个存放很多宝贝的宝箱  或者说是仓库   既然是一个存放宝贝的仓库 那谁都能来白嫖肯定是不行滴
于是就需要 公钥这个弟弟用来加密 对!没错 这个钥匙是用来加锁的。
既然都说公钥那就不得不说私钥了 
私钥的话就是用来解密的   就像阿里巴巴和四十大盗  山洞(GIT)里存放了宝贝,山洞前有石门(公钥)挡着
想进入山洞里拿宝贝,就只能大喊“芝麻开门”(私钥)才可以!

GIT basic operation,
MMP foreplay, so many foreplays are not exciting, enter the basic operation commands of git!

1.1 Initialization command:

git init  //初始化

Insert picture description here

git config --global --list //查看配置列表

Insert picture description here
There are too many, so I won't try them one by one. CV come over first and make up one by one!
A lot of small commands

touch a // 创建一个a文件
echo 1234 >> a // 把1234这个内容放入a文件
cat a // 打开a文件 读取出a文件中的内容
mkdir test // 创建test文件夹
rm 文件名 // 删除文件
pwd // 打印当前工作路径

Commonly used basic commands are basically enough for daily use!

git init // 初始化 在工作路径上创建主分支
git clone 地址 // 克隆远程仓库
git clone -b 分支名 地址 // 克隆分支的代码到本地
git status // 查看状态
git add 文件名 // 将某个文件存入暂存区
git add b c //把b和c存入暂存区
git add . // 将所有文件提交到暂存区
git add -p 文件名 // 一个文件分多次提交
git stash -u -k // 提交部分文件内容 到仓库 例如本地有3个文件 a b c 只想提交a b到远程仓库 git add a b 然后 git stash -u -k 再然后git commit -m "备注信息" 然后再push push之后 git stash pop 把之前放入堆栈的c拿出来 继续下一波操作
git commit -m "提交的备注信息"  // 提交到仓库
若已经有若干文件放入仓库,再次提交可以不用git add和git commit -m "备注信息"2步, 直接用
git commit -am "备注信息" // 将内容放至仓库 也可用git commit -a -m "备注信息"
* git commit中的备注信息尽量完善 养成良好提交习惯 例如 git commit -m "变更(范围):变更的内容"

The command to view information, Xiaobai will not use the series that the boss does not like!

git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
// 获取git log里的树形详细信息 包括hasg 日期 提交信息 提交人等
git log --oneline //拉出所有提交信息 q是退出
git log -5 // 查看前5次的提交记录
git log --oneline -5 // 打印出的日志里面只有哈希值和修改的内容备注
git log 文件名 // 查看该文件的提交
git log --grep // 想过滤看到的内容   过滤日志
git log -n // 查看近期提交的n条信息内容
git log -p // 查看详细提交记录

The next few more important remote operations!

 git remote add origin https://github.com/whjamz/studys.git //链接远程仓库

git pull origin master  //把远程仓库 master分支下的文件pull到本地

【如报错,远程已存在文件和本地仓库没有关联,导致下载失败

则需要强制pull git pull   origin master --allow unrelated-histories】

git push -u origin master  //将本地代码上传到远程 master分支上

git push origin 本地分支名:远程分支名称[不存在,先创建,后上传] //将本地xx分支的代码上传到远程 xx分支上

Dididi! There are three more!

git pull //从远程仓库获取最新版本合并到本地

git push //把本地仓库的内容提交推送给远程仓库

git push 远程仓库别名 :远程仓库分支名 //删除指定的远程的分支

When I got here, I found that there were too many commands. A little brother like me and Ben Shen couldn't help summing up all of them. So in the spirit of collecting it is my
own, I will do the following operations!
Insert picture description here
Hehehe! This is not lazy, this is learning like the predecessors!
Thanks for the selfless contributions of a few blogs! I only attract communication and study, not for any commercial purposes! !

https://www.jianshu.com/p/93318220cdce
https://segmentfault.com/a/1190000015482463?utm_source=tag-newest
http://www.sohu.com/a/251952125_663371

OK! The blogs of these three big guys are absolutely fine and simple!
Hmm, I still have to do something, just make a common quick reference basic form, benefit others and benefit yourself!
Insert picture description here
There is also a quick check form!

git branch 查看本地所有分支
git status 查看当前状态 
git commit 提交 
git branch -a 查看所有的分支
git branch -r 查看远程所有分支
git commit -am "init" 提交并且加注释 
git remote add origin git@192.168.1.119:ndshow
git push origin master 将文件给推到服务器上 
git remote show origin 显示远程库origin里的资源 
git push origin master:develop
git push origin master:hb-dev 将本地库与服务器上的库进行关联 
git checkout --track origin/dev 切换到远程dev分支
git branch -D master develop 删除本地库develop
git checkout -b dev 建立一个新的本地分支dev
git merge origin/dev 将分支dev与当前分支进行合并
git checkout dev 切换到本地dev分支
git remote show 查看远程库
git add .
git rm 文件名(包括路径) 从git中删除指定文件
git clone git://github.com/schacon/grit.git 从服务器上将代码给拉下来
git config --list 看所有用户
git ls-files 看已经被提交的
git rm [file name] 删除一个文件
git commit -a 提交当前repos的所有的改变
git add [file name] 添加一个文件到git index
git commit -v 当你用-v参数的时候可以看commit的差异
git commit -m "This is the message describing the commit" 添加commit信息
git commit -a -a是代表add,把所有的change加到git index里然后再commit
git commit -a -v 一般提交命令
git log 看你commit的日志
git diff 查看尚未暂存的更新
git rm a.a 移除文件(从暂存区和工作区中删除)
git rm --cached a.a 移除文件(只从暂存区中删除)
git commit -m "remove" 移除文件(从Git中删除)
git rm -f a.a 强行移除修改后文件(从暂存区和工作区中删除)
git diff --cached 或 $ git diff --staged 查看尚未提交的更新
git stash push 将文件给push到一个临时空间中
git stash pop 将文件从临时空间pop下来
---------------------------------------------------------
git remote add origin git@github.com:username/Hello-World.git
git push origin master 将本地项目给提交到服务器中
-----------------------------------------------------------
git pull 本地与服务器端同步
-----------------------------------------------------------------
git push (远程仓库名) (分支名) 将本地分支推送到服务器上去。
git push origin serverfix:awesomebranch
------------------------------------------------------------------
git fetch 相当于是从远程获取最新版本到本地,不会自动merge
git commit -a -m "log_message" (-a是提交所有改动,-m是加入log信息) 本地修改同步至服务器端 :
git branch branch_0.1 master 从主分支master创建branch_0.1分支
git branch -m branch_0.1 branch_1.0 将branch_0.1重命名为branch_1.0
git checkout branch_1.0/master 切换到branch_1.0/master分支
du -hs

git branch 删除远程branch
git push origin :branch_remote_name
git branch -r -d branch_remote_name
-----------------------------------------------------------

初始化版本库,并提交到远程服务器端
mkdir WebApp
cd WebApp
git init 本地初始化
touch README
git add README 添加文件
git commit -m 'first commit'
git remote add origin git@github.com:daixu/WebApp.git

增加一个远程服务器端

Table reference address

https://www.cnblogs.com/kenshinobiy/p/4543976.html
Infringement is deleted! !

3. IDEA AND GIT
In fact, for us novices , git commands only need to use a few simple ones. The most important thing is to be able to complete the work:
IDEA is currently used by most people. There are many people who use it. Not much, I don’t know if I use it anyway!
Insert picture description here
Here! My one is still valid until 2089! Refer to my other blog for the cracking tutorial

https://blog.csdn.net/DoChengAoHan/article/details/102660977

Use IDEA to upload the code by
drop-down : the drop-down code is also simple, so I won't say much! One thing to pay attention to is the branch problem.
Don't start working after pulling the code. You must first get the code to your own local branch!
Insert picture description here
IDEA can also create and switch branches directly!
The labeled branch is the current branch.
Create a new branch Click new branch and
Insert picture description here
enter the branch name!
OK ----------Done!
Let me talk about submission in detail. For Xiaobai, I have stepped on a lot of pits!
The history of blood and tears will probably be published! ! !
-------------------------------------------------- ------Beep beep dividing line--------------------------------------- -The
first step:
upload the code to the local warehouse!
Insert picture description here
The second step
select the code to upload!
Insert picture description here
Insert picture description here
There may be errors when uploading. IDEA will prompt you to check!
Insert picture description here
After checking correct! You can choose to submit directly!
Insert picture description here
Click push to push the code to the remote warehouse!
Insert picture description here
You can see that the upload is complete!

----------------------------- Blindly forced ------------------ ------------------------------------
Basically, I don't want to write too much and make up later!

Guess you like

Origin blog.csdn.net/DoChengAoHan/article/details/102854663