In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the basic configuration and use of Git under the Linux system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "the basic configuration and use of Git under the Linux system".
Git config profile
Git is already in your system, and you will do something to customize your Git environment. You only need to make these settings once; even if you upgrade, they will be bound to your environment. You can also change these settings at any time by running the command.
Git has a tool called git config, which allows you to get and set configuration variables that control all aspects of the appearance and operation of Git. These variables can be stored in three different locations:
1./etc/gitconfig file: contains values that apply to all users and all libraries of the system. If you pass the parameter option'--system' to git config, it will explicitly read and write the file.
2.~/.gitconfig file: specific to your users. You can make Git read or write to this particular file by passing the-- global option.
3. The config file located in the git directory (i.e. .git / config): no matter what library you are currently using, specifically point to that single library. Each level overrides the value of the previous level. Therefore, the value in .git / config overrides the same value in / etc/gitconfig.
On Windows systems, Git looks for the .gitconfig file in the $HOME directory (for most people, under C:\ Documents and Settings\ $USER). It also looks for / etc/gitconfig, although it is relative to the Msys root directory. This could be anywhere you decide to install Git when you run the installer in Windows.
two。 Your logo (Your Identity)
2.1When you install Git, the first thing to do is to set up your user name and e-mail address. This is important because this information is used every time an Git submission is made. It is forever embedded in your submission:
The code is as follows:
$git config-global user.name "John Doe"
$git config-global user.email johndoe@example.com
Again, you only need to make this setting once. If you pass the-- global option, because Git will always use this information to handle everything you do in the system. If you want to use a different name or e-mail address in a particular project, you can run the command in that project instead of the-- global option.
2.2 your editor (Your Editor)
Now that your logo is set, you can configure your default text editor, which Git will use when you need to enter some messages. By default, Git uses your system's default editor, which is usually vi or vim. If you want to use a different text editor, such as Emacs, you can do the following:
The code is as follows:
$git config-global core.editor emacs
2.3 your comparison tool (Your Diff Tool)
Another useful option you may need to configure is the default comparison tool, which is used to resolve conflicts during a merge. For example, you want to use vimdiff:
The code is as follows:
$git config-global merge.tool vimdiff
Git can accept kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff as valid merge tools. You can also set up a custom tool; see Chapter 7 for more information on this.
2.4 check your settings (Checking Your Settings)
If you want to check your settings, you can use the git config-- list command to list all the settings that Git can find there:
The code is as follows:
$git config-list
User.name=Scott Chacon
User.email=schacon@gmail.com
Color.status=auto
Color.branch=auto
Color.interactive=auto
Color.diff=auto
...
You may see a keyword appear multiple times because Git reads the same keyword from different files (for example: / etc/gitconfig and ~ / .gitconfig). In this case, Git uses the last value for each unique keyword.
You can also look at the current value of a particular keyword that Git believes, using the command git config {key}:
The code is as follows:
$git config user.name
Scott Chacon
2.5 get help (Getting help)
If you need help using Git, there are three ways to get help on the man page (manpage) of any git command:
The code is as follows:
$git help
$git-help
$man git-
For example, you can run the following command to get man page help for the config command:
The code is as follows:
$git help config
These commands are very friendly because you can access them anywhere, even if they are not online. If the man pages and this book are still insufficient and you need personal help, you can try using # git or # github channel (irc.freenode.net) on Freenode IRCServer. These channels are regularly maintained by hundreds of professionals who are very familiar with Git, who will be more than happy to help you.
2.6Summary (Summary)
You should have a basic understanding of what Git is and the difference between Git and other CVCS you might use. You should also have a working version of Git with your personal logo in your system. It's time to learn the basics of Git.
Git actual usage record
1. Analysis of errors in git submission codes.
The code is as follows:
$git push origin master
The code is as follows:
To git@192.168.1.3:k6.git
! [rejected] master-> master (non-fast-forward)
Error: failed to push some refs to 'git@192.168.1.3:k6.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
Fast-forwards' section of 'git push-- help' for details.
Cbk@YCS:~/work/k6_130708/k6 $git fecth
Git: 'fecth' is not a git command. See 'git-- help'.
Git push error, because there is no up-to-date code that pull first, the following actions are required:
The code is as follows:
$git fetch origin
$git merge origin/master
$git push origin master
If you do not set your user name and e-mail address after installing git, you still need to execute:
The code is as follows:
$git config-global user.name "cbk"
$git config-global user.email cbk@ylf.com
This is important because this information is used every time an Git submission is made. It is forever embedded in your submission:
Again, you only need to make this setting once. If you pass the-- global option, because Git will always use this information to handle everything you do in the system. If you want to use a different name or e-mail address in a particular project, you can run the command in that project instead of the-- global option.
When it comes to this problem, if your user name and e-mail address are not set, you will not be able to push the code correctly.
2. Git tracks the submission history of a file
When tracking Android code, sometimes you find that a key file has been changed, and you need to track and view the records of all the commit of this key file in order to understand the reason and process of the modification:
The code is as follows:
Git log-p "file name"
Displays the final submission commit of each line of the file, making it easy to locate the commit:
The code is as follows:
Git blame "file name"
Displays the log detailed modification record:
Git show [log_id_num], for example:
The code is as follows:
Git show 75704c8543b033619a80439ddb0fd69cc7cb172c
3. Git config initialized by git
1)。 The following command modifies the / home/ [username] / .gitconfig file, which means that the following configuration is only visible to every ssh user, so everyone needs to do it.
The submitter's information will be displayed in the log of the submitted code.
The code is as follows:
Git config-- global user.name [username]
Git config-- global user.email [email]
Turn on color display in the git command
The code is as follows:
Git config-global color.ui true
2)。 The following command will modify the / etc/gitconfig file, which is the global configuration, so admin can do it once.
Configure some common git commands alias
The code is as follows:
Sudo git config-system alias.st status # git st
Sudo git config-system alias.ci commit # git commit
Sudo git config-system alias.co checkout # git co
Sudo git config-system alias.br branch # git branch
3)。 You can also go to the working root directory and run git config-e, which will only modify the .git / config file in the workspace, but not yet.
The override order of git config files is 3) > 1) > 2).
4. Version fallback
The code is as follows:
Git reset-hard commit_id
The code is as follows:
Git checkout commit_id
The code is as follows:
Git clean-df commit_id
At this point, I believe you have a deeper understanding of the "basic configuration and use of Git under the Linux system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.