git config global and local configuration

Note: This article from blogger Chloneda : personal blog | blog park | Github | Gitee | know almost

This article source link : https://www.cnblogs.com/chloneda/p/git-config.html

Foreword

Application developers in the daily development process, using git may encounter such a situation:

  • The company submitted the project using git company account information.
  • Personal hobby project using git submit personal account information.

In other words, we need to git submit relevant records using a different account and mailbox, depending on the project, this article is dedicated to solve this problem.

Local Settings

There are two ways to set up locally, command mode and profile mode , select either of two ways, you can configure the current git git-mail account and submit project information.

Command mode

For local git repo configuration, first enter the local git repo directory, use the command:

git config user.name "your-username"
git config user.email "your-email-address"

Profiles way

For local git repo configuration, first enter the local git project directory, edit the .git / config file, add the following information:

[user]
    name = your-username
    email = your-email-address

Save and exit. The above command mode and profile mode in two ways, are available in local git repo directory, view the account and mailbox whether to change the local project success by following commands.

git config user.name

For a number of local git repo , each local git repo should be set up custom of git local account and mailbox, and sometimes we do not want each set, we can use the global git configuration, all local git repo are using the global Configuring!

Global Settings

There are two ways to set global, command mode and profile mode , select either of two ways, you can configure a global git git-mail account and submit project information.

Command mode

In git server, any non- local git repo , configure the global configuration, use the following command:

git config --global user.name "your-username"
git config --global user.email "your-email-address"

Profiles way

Edit ~ / .gitconfig , whose content .git / config content file is the same, i.e. [user] is added to part of the information ~ / .gitconfig document, as follows:

[user]
    name = your-username
    email = your-email-address

Save and exit. Any non- local git repo , the following command to check whether success

git config user.name

Well, the git config global and local configuration on here!

Guess you like

Origin www.cnblogs.com/chloneda/p/git-config.html