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

How to use git command under Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the relevant knowledge of "how to use git command under Linux". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

Git (pronounced/g <$t/) is an open source distributed version control system that handles version management from small to very large projects efficiently and at high speed. It is also an open source version control software developed by Linus Torvalds to help manage Linux kernel development.

Linux system git common command: 1 installation:

sudo apt-get install git2 Create a repository:

Create a new folder and enter this directory

git init3 creates a version:

git add filename or directory #means to cache changes to the current file without committing git commit -m 'version name' #Commit buffer to build a version 4 View version history

geit log View version information one line per article

git log --pretty=oneline It's clear when you see it graphically with merged versions

git log --pretty=oneline --graph5 Switch versions:

HEAD^indicates the previous

HEAD^^indicates the top two

HEAD~10 indicates the tenth version of the previous version

git reset --hard HEAD^ #Jump back one version git reset --hard version #Jump to the specified version 6 according to version number View action history

git reflog7 View the status of the current working tree (what changes, what uncommitted buffers)

git status8 Undo modifications

Empty the current workspace modification, if the buffer has data, restore to the buffer, if not restore to the previous commit version

git checkout --file name empties buffer contents back into workspace

git reset HEAD file name 9 compare different

git diff HEAD --filename #Compare differences between workspace and HEAD versions (last submitted version) git diff HEAD (version 1) HEAD^^(version 2)--filename #Compare differences between versions of files 10 Delete files

git rm git commit -m 'version name'11 branch

View all current branches

git branch creates a branch and uses it to work

git checkout -b Quickly merge branch names into another branch with a new version

git merge branch name delete branch

git branch -d name switch branch

git branch name conflict resolution

Different modifications were made to the same file in branch 1 and branch 2, respectively, resulting in conflicts when trying to merge branches

Conflict files can be edited in one of the branches, and then the version submitted,

This is equivalent to merging conflicting files in the current branch and leaving the other branch unchanged

Create a new version merge, not applicable to Quick Merge:

Instead of merging into two versions, it creates a new version

git merge --no-ff -m 'version name'BUG branch:

Create a new branch on the branch where the bug occurred and modify it

And then modify it and then branch and merge it.

Finally, delete the temporarily established bug branch

12 Save the current workspace (if you don't want to submit, you can continue the workspace next time)

git stash, then switch to another branch, then switch back

Restore workspace

git stash pop"How to use git command under Linux" is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

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

Development

Wechat

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

12
Report