Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the knowledge of Git?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What are the knowledge of Git, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Related commands:

1. Configuration

Git config-global user.name leo

Git config-global user.email fulei.zhang@ecarx.com.cn

Git config-global color.ui true

Or

Cat ~ / .gitconfig view

2. Create repository

Git init

Git clone Code Warehouse address

3. Add and submit documents

Git add.

Git commit-m 'init commit'

Git status

4. Git status

Git status

Files ignored by echo'~'> .gitignore

Git add .gitignore

Git status-s

5. View file differences

Git diff

Git diff-staged

Git diff HEAD

Git diff-stat HEAD

6. Undo misoperation

Git status-s

Git reset code.py

Git checkout code.py

Git checkout HEAD code.py

Git commit-am 'add new code'

The figure shows:

7. Remove and rename files

Git rm old.py

Git status-s

Git commit-m 'delete old.py'

Git rm-cached code.py

Git mv README.txt READ.md

Git commit-m 'rename README'

Git rm-cached README.md

Mv README.md README.txt

Git add README.txt

8. Temporary cache area

Git stash

Modify the code

Git stash list

Git stash pop

Git commit-am 'update 2 files'

9. Schematic commit object

Tree

Git log

Git cat-file-t HEAD

Git cat-file-p HEAD

Git cat-file-t efdae

Git cat-file-t efdae

Git cat-file-p efdae

10. Understand tree-ish expressions

Git log-oneline

Git rev-parse HEAD

Git rev-parse HEAD~

Git rev-parse HEAD~4

Git rev-parse HEAD~ 4 ^ {tree}

Git rev-parse HEAD~4:code.py

Git cat-file-p HEAD~4:code.py

Git show HEAD~4:code.py

11. Create and delete branches

Git branch

Git branch tryidea

Git checkout tryidea

Git branch-d tryidea

12. Merge branches

Git checkout-b tryidea

Git merge tryidea

Git log

Git branch-d tryidea

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report