How to login git bash
How to login git bash
How to Set Git Username and Password in GitBash?
Git is an open-source version control system. Git is software that helps to track updates in any folder. It is a DevOps resource used mostly for source code planning. It’s typically used to promote collaboration between coders who are relying on source code together during software development. Speed, the integrity of data, including support for dispersed, non-linear workflows are among the aims.
A terminal Git environment is handled by Git Bash (Bash, an acronym for Bourne Again Shell). Git Bash replicates a bash terminal on Windows. It allows you to use all git tools or most other typical Unix commands from the command line. If you’re used to Linux and want to preserve your routines, this is a great alternative.
Git is usually bundled as one of the elevated GUI applications in Windows settings. Bash is a popular Linux and Mac OS default shell. On a Windows operating system, Git Bash is a package that installs Bash, some standard bash utilities, and Git. The fundamental version control system primitives may be abstracted and hidden by Git’s GUI. Git Bash is a Microsoft Windows software that functions as an abstraction shell for the Git command-line experience. A shell is a console application that allows you to interact with your operating system by command prompt.
Now let us discuss how to set Git Username and Password in Git Bash
Step 1: After the successful installation of Git on your system, you have to right-click wherever you want to open the Git tab. Click on the Git Bash Here icon. Now here we will see the location of where the program is opened when the window opens.
Git Bash opened on Desktop.
Step 2: In the Git Bash window, type the below command and press enter. This will configure your Username in Git Bash.
Step 3: After that, you will have to configure your email. For that, type
Step 4: To set your password, type the below command as depicted:
Step 5: To save the credentials forever, type the below command as depicted:
This is how you set git username and password in git bash.
To check the inputs, type the below command as depicted:
Working on Git Bash
Git Bash is an application that provides Git command line experience on the Operating System. It is a command-line shell for enabling git with the command line in the system. A shell is a terminal application used to interface with an operating system through written commands. Git Bash is a package that installs Bash, some common bash utilities, and Git on a Windows operating system. In Git Bash the user interacts with the repository and git elements through the commands.
What is Git?
Installing Git Bash
Follow the steps given below to install Git Bash on Windows:
Step 2: Select the components that you need to install and click on the Next button.
Step 3: Select how to use the Git from command-line and click on Next to begin the installation process.
Step 4: Let the installation process finish to begin using Git Bash.
To open Git Bash navigate to the folder where you have installed the git otherwise just simply search in your OS for git bash.
Navigate in Git Bash
cd command
cd command refers to change directory and is used to get into the desired directory.
To navigate between the folders the cd command is used
Syntax:
ls command
ls command is used to list all the files and folders in the current directory.
Syntax:
Set your global username/email configuration
Open Git Bash and begin creating a username and email for working on Git Bash.
Set your username:
Set your email address:
Initializing a Local repository
Follow the steps given below to initialize your Local Repository with Git:
Step 1: Make a repository on Github
Step 2: Give a suitable name of your repository and create the repository
Note: You can choose to initialize your git repository with a README file, and further, you can mention your project details in it. It helps people know what this repository is about. However, it’s absolutely not necessary. But if you do initialize your repo with a README file using interface provided by GitHub, then your local repository won’t have this README file. So to avoid running into a snag while trying to push your files (as in step 3 of next section), after step 5 (where you initialize your local folder as your git repository), do following to pull that file to your local folder:
Step 3: The following will appear after creating the repository
Step 4: Open Git Bash and change the current working directory to your local project by use of cd command.
Step 5: Initialize the local directory as a Git repository.
Step 6: Stage the files for the first commit by adding them to the local repository
Step 7: By “git status” you can see the staged files
Step 8: Commit the files that you’ve staged in your local repository.
Now After “git status” command it can be seen that nothing to commit is left, Hence all files have been committed.
Push files to your Git repository
Step 1: Go to Github repository and in code section copy the URL.
Step 2: In the Command prompt, add the URL for your repository where your local repository will be pushed.
Step 3: Push the changes in your local repository to GitHub.
Here the files have been pushed to the master branch of your repository.
Now in the GitHub repository, the pushed files can be seen.
Saving changes to local repository
Suppose the files are being changed and new files are added to local repository.
To save the changes in the git repository:
Step 1: Changes have to be staged for the commit.
Step 2: Now commit the staged files.
Step 3: Push the changes.
New changes can be seen
Branching through Git Bash
Branching in Github
Suppose if a team is working on a project and a branch is created for every member working on the project.
Hence every member will work on their branches hence every time the best branch is merged to the master branch of the project.
The branches make it version controlling system and makes it very easy to maintain a project source code.
Syntax:
Navigating between Branches
To navigate between the branches git checkout is used.
To create create a new branch and switch on it:
To simply switch to a branch
After checkout to branch you can see a * on the current branch
Now the same commit add and commit actions can be performed on this branch also.
Merge any two branches
To merge a branch in any branch:
Cloning Repository to system
Cloning is used to get a copy of the existing git repository.
When you run the git clone command it makes the zip folder saved in your default location
This command saves the directory as the default directory name of the git repository
To save directory name as your custom name an additional argument is to be passed for your custom name of directory
Undoing commits
When there is a situation when you forget to add some files to commit and want to undo any commit, it can be commit again using —ammend
Configuring user and password with Git Bash
I am using Git Bash on Windows 7. We are using GitHub as our repository origin.
Every time I push or pull I have to provide user and password credentials. I know that my SSH keys are set up correctly, otherwise I would not be able to access the repository. (That is, once I enter my credentials the push/pull works correctly.)
But nonetheless I am being asked for credentials each and every time I push/pull.
13 Answers 13
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
You can change the URL with: [1]
[1] This portion incorporates the answer to this question.
From Git Bash I prefer to run the command:
For those who are using access token and a Windows environment, there is a simple way to do it:
Start menu → Credential Manager → Windows Credentials → find the line (Git: https://whatever/your-repository/url) → edit, user name is «github_username» and password is your access token.
If you are a Mac user and have keychain enabled, you to need to remove the authorization information that is stored in the keychain:
Then you should change your username and email from the terminal using git config :
Now if you try to push to the repository you will be asked for a username and password. Enter the login credentials you are trying to switch to. This problem normally pops up if you signed into GitHub on a browser using a different username and password or previously switched accounts on your terminal.
I wrote an answer in this other answer: How to change git account in Git bash?
Still, I am sharing it here as well.
Change username and email global
Change username and email for current repo
With git bash for Windows, the following combination of the other answers worked for me (repository checked out using the GitHub client i.e. https, not ssh):
Try ssh-agent for installing the SSH key for use with Git. It should auto login after use of a passphrase.
If the git bash is not working properly due to recently changed password.
You could open the Git GUI, and clone from there. It will ask for password, once entered, you can close the GIT GUI window.
Now the git bash will work perfectly.
So, From then while you pull / push the code to the repository it will not ask for password.
GnuPG can be used as cross-platform password manager, including GIT HTTPS credetials. Just use your GPG key-pair to encrypt/decrypt passwords(tokens. ). To encrypt token(password) run:
type the token (or copy-paste it) then press Ctrl+D for ending input, or use file name with this token. Then make custom git credential helper: BASH file with name git-credential-[HELPER_LAST_NAME] (without SH extension):
GnuPG can be used as password manager in Maven projects instead of Maven’s password-encryption method. And so on.
How do I sign out in the Git Bash console in Windows?
I’m using Git, on Windows, version 2.9.2.windows.1.
I work on a repository project and when I do a push, it asked me to enter my GitHub username and password. I entered both my GitHub username and password to update the project.
In my next push, it doesn’t ask for my username and password any more. All my modifications for the project are updated.
It looks like my username and password are «saved». How do I «unsave» them?
How do I sign out?
But they do not make me sign out.
I want to clear my sign in so the next time I make a push, it asks me again to enter my username and password.
10 Answers 10
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
For Windows 10, if your PC has a different login (a MSFT account) and GitHub is on another login, if you go to control panel → user accounts and search for credential manager, you will see «Web Credentials» and «Windows credentials».
GitHub seems to be taking the default ID that is registered in the PC (Microsoft account). Under Windows Credentials, remove the GitHub login details and try Push again. You will be prompted for a GitHub ID and password explicitly. Once we login that gets stored as a personal access token for Git push.
First, user authentication has nothing to do with user.name and user.email git config.
Update 2018: » delete » is now deprecated, use reject :
Update 2020: » reject » is now deprecated, use erase :
Actually, whatever ‘ xxx ‘ credential manager you are using (‘ xxx ‘ being the result of git config credential.helper ), you can do:
This is better than fiddling with the Credential Manager of your OS.
I would remove that particular credential helper from the config, as it stores credentials in plain text.
The OP Lord Rixuel actually confirms in the comments it is a native Windows Credential Manager function which provides automatically (Git or not) the credentials:
I see the «Manage your credentials» option, I click on it out of curiosity, then I click on «Windows Credentials», under «Generic Credentials», there is » git:github.com «;, I click on it and there is the «Remove» option. I clicked Remove.
Первоначальная настройка Git
Теперь, когда Git установлен в вашей системе, самое время настроить среду для работы с Git под себя. Это нужно сделать только один раз — при обновлении версии Git настройки сохранятся. Но, при необходимости, вы можете поменять их в любой момент, выполнив те же команды снова.
Чтобы посмотреть все установленные настройки и узнать где именно они заданы, используйте команду:
Имя пользователя
Первое, что вам следует сделать после установки Git — указать ваше имя и адрес электронной почты. Это важно, потому что каждый коммит в Git содержит эту информацию, и она включена в коммиты, передаваемые вами, и не может быть далее изменена:
Многие GUI-инструменты предлагают сделать это при первом запуске.
Выбор редактора
Теперь, когда вы указали своё имя, самое время выбрать текстовый редактор, который будет использоваться, если будет нужно набрать сообщение в Git. По умолчанию Git использует стандартный редактор вашей системы, которым обычно является Vim. Если вы хотите использовать другой текстовый редактор, например, Emacs, можно проделать следующее:
В системе Windows следует указывать полный путь к исполняемому файлу при установке другого текстового редактора по умолчанию. Пути могут отличаться в зависимости от того, как работает инсталлятор.
В случае с Notepad++, популярным редактором, скорее всего вы захотите установить 32-битную версию, так как 64-битная версия ещё не поддерживает все плагины. Если у вас 32-битная Windows или 64-битный редактор с 64-битной системой, то выполните следующее:
Vim, Emacs и Notepad++ — популярные текстовые редакторы, которые часто используются разработчиками как в Unix-подобных системах, таких как Linux и Mac, так и в Windows. Если вы используете другой редактор или его 32-битную версию, то обратитесь к разделу Команды git config core.editor за дополнительными инструкциями как использовать его совместно с Git.
В случае, если вы не установили свой редактор и не знакомы с Vim или Emacs, вы можете попасть в затруднительное положение, когда какой-либо из них будет запущен. Например, в Windows может произойти преждевременное прерывание команды Git при попытке вызова редактора.
Настройка ветки по умолчанию
Например, чтобы установить имя main для вашей ветки по умолчанию, выполните следующую команду:
Проверка настроек
Некоторые ключи (названия) настроек могут отображаться несколько раз, потому что Git читает настройки из разных файлов (например, из /etc/gitconfig и
/.gitconfig ). В таком случае Git использует последнее значение для каждого ключа.
Также вы можете проверить значение конкретного ключа, выполнив git config :
Так как Git читает значение настроек из нескольких файлов, возможна ситуация когда Git использует не то значение что вы ожидали. В таком случае вы можете спросить Git об origin этого значения. Git выведет имя файла, из которого значение для настройки было взято последним:
Источники информации:
- http://www.geeksforgeeks.org/working-on-git-bash/
- http://stackoverflow.com/questions/8840551/configuring-user-and-password-with-git-bash
- http://stackoverflow.com/questions/38549834/how-do-i-sign-out-in-the-git-bash-console-in-windows
- http://git-scm.com/book/ru/v2/%D0%92%D0%B2%D0%B5%D0%B4%D0%B5%D0%BD%D0%B8%D0%B5-%D0%9F%D0%B5%D1%80%D0%B2%D0%BE%D0%BD%D0%B0%D1%87%D0%B0%D0%BB%D1%8C%D0%BD%D0%B0%D1%8F-%D0%BD%D0%B0%D1%81%D1%82%D1%80%D0%BE%D0%B9%D0%BA%D0%B0-Git