In Part 3 of our “Setup Git for Development” tutorial, are going to begin setting up your identity within Git Bash. We are going to continue right where Part 2 left off. It is important to setup your identity that was others you are collaborating with are able to determine which commits are from you. Many places like GitHub will require them so its system can determine which user made the commit and if they have the appropriate permissions to do so.
Getting Started
If you continued from Step 2, you should already have Git Bash open, however if you don’t, go ahead an open it now. Below is a screenshot of what Git Bash looks like. If you your screen doesn’t look exactly the same that is fine, I open a fresh Git Bash window.
Once you have Git Bash open we are going to enter a few commands that will be used to identify yourself. Please enter the command below, however replace my own first name and last name with your own full name.
1 | $ git config --global user.name "Brandon Enriquez" |
$ git config --global user.name "Brandon Enriquez"
Once you have completed entering your full name, go ahead and press enter. If it was successful you will not see any response back from Git Bash except for a new line that you can enter a command from.
The next command you will enter is going to identify your email address. Again please enter the command below, however replace the fake email address with your own email address. Sometimes this email must match the email address on the project manager you may be using, this may not apply to everyone though.
1 | $ git config --global user.email "brandon@somewhere.com" |
$ git config --global user.email "brandon@somewhere.com"
Once you entered your own email address, go ahead and press enter. Again if it was successful you will not see any response back.
GitHub Setup
This next section is completely optional, however required if you plan on using GitHub as your project management portal. In order to complete this step, you will need your GitHub username and API Token. To get to your API Token, go to the GitHub website and to go Account Settings then Account Admin. From there you will see a long string under the API Token header.
Once you have your GitHub username and API Token, go ahead and begin entering this command below. Replace my username with your own GitHub username.
1 | $ git config --global github.user username |
$ git config --global github.user username
Same as before when your ready press enter and then copy to API Token and replace the word apitoken in the following command with your token from the GitHub website.
1 | $ git config --global github.token apitoken |
$ git config --global github.token apitoken
Once you are done entering your token, press enter and you will be done setting up your GitHub identity. Just know that if you ever change your GitHub password, this token will change and will need to be re-entered through Git Bash.
Result
If you successful setup your identity with your full name and email address, and GitHub username and API Token if you chose to, then your screen should like the one below. Obviously it will not look exactly the same as you placed your own variables in place of the sample data.
If you have any questions or need help, please feel free to ask in the comments.