I want to push a directory to Github via nodejs app. Here's what I currently do.
I take username, password and new repository name from user. Then, I create new repository via Github API(https://developer.github.com/v3/repos/#create).
Now I want to push some specific code to this repository. I can't use node.js child process (git push origin master), because that requires username and password.
How can I push code to Github via API. (And if via command line, then without entering password manually)
To skip the password on each commit you need to tell the git to store the credential in a separate place. This can be done by using the following command:
git config --global credential.helper cache
This will store the password for 15 minutes. If you wish you can extend this time by specifying the amount of duration in milliseconds:
git config --global credential.helper "cache --timeout=3600"
Related
I have a shell script file which will push the files to empty git repo.
git init
git add .
git commit -m "first commit"
git remote add origin https://<my-personal-access-token>#github.com/<organization-name>/<repo-name>.git
git push -u origin master
This was pushing files to repo without asking for password, but surprisingly now it is asking for password too.
Why is it asking for password even though I used personal access token? What is going wrong here?
Even if I input correct password manually, it says as below :
You can try below line in your code for git remote step by adding username to it:
git remote add origin https://username:<my-personal-access-token>#github.com/<organization-name>/<repo-name>.git
I tried using this commands before getting errors
git remote add name url
git add .
git commit -m 'message'
git push -u name master
The question should be more clear. Error messages should be posted.
If you logged in GitLab with GitHub account, you'll have to set up a password for GitLab in order to log into GitLab account.
The fastest way to do so is to change your password in GitLab. You should see only new password fields.
After that, you'll have no trouble pushing.
I Need to do a git pull using https url as a oneline command . this command I need to integrate in a bash script . But all the time it is asking the usernmae and password .
The repository is in AWS codecommit
Try this:
git clone https://username:password#git-codecommit.us-east-1.amazonaws.com/v1../repos../..
This way worked for me for CodeCommit (AWS) repository
Check this link: Enter user password in command
As is described perfectly in that post, you basically have three options:
Store the password in .netrc file (with 600 permissions). Make sure you clone the repo specifying the username in the url.
Clone the repo with https://user:pass#domain/repo . Take into account that your password will be visible in several places...
Use the credential helper.
As an update, AWS has released their remote git remote codecommit. With proper IAM setup, you can do oneline pulls without even passing username and passwords. This is now the recommended method by AWS. It can be setup on your local or on a container that's running in an AWS Pipeline for example.
i.e. git clone codecommit://HelloWorldRepo myLocalHelloWorldRepo
And then you can git pull as normal.
Full documentation is here:
https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-git-remote-codecommit.html
So, when I use HTTPS method for cloning git repository and do some changes and push or pull to git it will always be prompting me for username and password. what's the solution for that?
Apart from changing to SSH, you can also keep using HTTPS, if you don't mind to put your password in clear text. Put this in your ~/.netrc and it won't ask for your username/password (at least on Linux and Mac)
Make one .netrc file in your home directory.
machine github.com
login <user>
password <password
The solution to your problem is this git command which is kind of remember me of GIT.
git config credential.helper store
Read this for details:
GIT credentials store
I am working on linux and I clone a private repository using my github account credentials. But over the period of time my password has changed for github and whenever I try to use git pull it is giving me an error
remote: Invalid username or password.
How can I change the password which I used while cloning the repository for the first time?
You the issue an git remote -v and check what kind of auth you are using. I always use git protocol (which uses SSH). You can freely edit those remote urls in ./git/config file. I believe you cloned it using HTTP (or using SSH w/o .ssh key file being present).
If you want to use SSH, you can follow this: https://help.github.com/articles/generating-ssh-keys
Then you will never need to worry about passwords again.