I need to change directory from this directory to my git hub account, like : (my name) (my repository), I set global email and global username but it didn't work, please help me
You should make a new folder and locate it, on the local machine. Then you should make a pull from the remote repository you are mentioning with the help of the following command,
git pull <remote url>
and you can set it.
To check out your username and email you can use the following command
git config user.name
git config user.email
In order to change or set the global username and global email you can use
git config --global user.name "Name"
git config --global user.email "mail#xyz.com"
Related
I was using github account A on gitbash and I wanted to switch to B.
I deleted the credentials for github from control panel for account A and signed with B
When I run git config --list, user.email and user.name matched with account A
than I did:
git config --global user.name "AccountB'sname"
git config --global user.email AccountBemail
When I run git config --list , Now user.email and user.name matches with account B. And when I make a commit, It is seem to be with account B. So it's good.
My first question is: Is it all to do when changing github account on gitbash ?
2- why on my first git config --list run, name and email did not match even tho I updated credentials from control panel
Your GitHub credentials and your Git config are two unrelated things.
When you set user.name and user.email, what you are changing is the metadata that will be used in any commits your create. Creating commits is a local operation on your machine, and does not involved talking to GitHub or any other Git server.
When you want to connect to GitHub using a different account, you did the right thing: change your credentials for GitHub in the Windows Credentials Manager. That will not affect how commits are created on your machine, only how you will authenticate yourself when connecting to GitHub.
I am trying to configure a git client to checkout using git fetch followed by git checkout from a bash script.
I have a github PAT (personal access token).
My purpose is to use my github user-id and the PAT to pass to the git fetch command one time such that next git command onwards, it won't require.
I know in git clone, I can pass the password like this:
git clone https://<token>#github.com/<username>/repository.git
I also setup the credential.helper to the cache for credential caching.
git config --global user.name "git-user-id"
git config --global user.email "email"
git config --global credential.helper cache
Now I want to pass the user name and PAT to the git fetch:
git fetch --no-tags --progress --depth=1 -- https://github.com/RepoName/demo-internal.git +refs/heads/<branch>:refs/remotes/origin/<branch>
git checkout <branch>
How can I do it in the git command line?
Note: I am not looking for an interactive way like using Expect or something like that.
You shouldn't place credentials in the URL. The Git FAQ mentions why:
While it is possible to place the password (which must be percent-encoded) in the URL, this is not particularly secure and can lead to accidental exposure of credentials, so it is not recommended.
If your goal is to set up access for your own use (say, a personal or work desktop or laptop), then that FAQ entry tells you how to set up a credential helper that will save your credentials securely long term, using an appropriate encrypted credential store for your system.
If your goal is to set up credentials for some sort of automated system, you can set up a custom credential helper to read from the environment. You could also generate an Ed25519 SSH deploy key and use that.
Note that user.name is not a username; it is a personal name and has no effect on authentication. For example, the maintainer of Git has this value set to “Junio C Hamano.”
I want to clone a repository and I ran into permission issues,
I tried to set up my username and email but keep getting errors
I used
git config --global user.name "yusuf-uthman"
git config --global user.email "yusufuthman57#gmail.com"
but didnt get any notification wether its accepted or not.
Uthman#DESKTOP-30QGK3L MINGW64 ~/Desktop/Scripts/hng_internship5.0
$ git config --global user.name "Uthman Yusuf"
Uthman#DESKTOP-30QGK3L MINGW64 ~/Desktop/Scripts/hng_internship5.0
$ git config --global user.email "yusufuthman57#gmail.com"
Uthman#DESKTOP-30QGK3L MINGW64 ~/Desktop/Scripts/hng_internship5.0
$ git clone git#github.com:yusuf-uthman/hng-internship.git
Cloning into 'hng-internship'...
Warning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts.
git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How do I clone the repository without getting the error?
The failure comes from cloning your GitHub repo via SSH URLs. To use that process, one needs to add your public SSH key in your repository.
Instead use HTTP URL method to clone which will most likely circumvent that error.
Use:
HTTP URLs: https://github.com/yusuf-uthman/hng-internship.git
instead of:
SSH URLs: git clone git#github.com:yusuf-uthman/hng-internship.git
but didnt get any notification wether its accepted or not.
Username and Email are just settings in you git config file, no one will accept or decline it. If you commit, the value of the settings will be used to determine the commits author and committer.
Access rights to a repository are usually managed via ssh keys. See Connecting to GitHub with SSH.
Last week a friend of mine cloned her Github repository and did some work on it on my machine. She changed the user config on my machine using the following bash commands:
git config --global user.name "myFriendsUsername"
git config --global user.email "myFriendsEmail"
When she was done, she used the same commands to change the user config back to my credentials and I verified this using
git config --global user.name
git config --global user.email
which returned my credentials. However, today I cloned a repository of my own, committed some changes and tried to push to origin but it gave me the following error:
remote: Permission to myUsername/myRepo.git denied to myFriendsUsername.
fatal: unable to access
'https://github.com/myUserName/myRepo.git/': The requested URL returned error: 403
Are there any settings that I'm possibly neglecting?
The git config settings you changed are used when committing changes to a repository, not for authorization:
$ git config --global user.name "Full Name"
$ git config --global user.email "user#example.com"
When your friend cloned a git repository, its likely that your computer's credentials manager (Keychain on Mac OS) saved the authorization certificate.
To remove this authorization certificate, open up Keychain, click on All Items and search for git. You will get some items like this:
After deleting these certificates, Git should prompt you to reauthorize on your next action.
When i commit git uses not company mail but my personal, which i use in chrome, i do commits using ssh URL and ssh key contains correct mail address, in git lab commits are also under my name but when i open commit author there is my personal URL with nick name. Usually i commit using intellij idea but same result with console commands
I have already reinstalled git and replaced ssh key with new one but it still use my personal nick as author.
So how can i change author of new commits, so it'll be by default correct?
i don't want to write console commands with author argument every time i commit.
OS windows 7
You can update your config file from Git Bash:
git config --global user.name "[Your name]"
git config --global user.email [email address]
This will set a global username and email.
To check your current settings:
git config --list
Update your Git config file with required Name and Email Id.