Tuesday, February 23, 2021

push an existing repository from the local computer to git repo using command line

 Create a github account with username and password .

When you want to make a folder as git repository, associate that repository with the corresponding github account by adding the same username and password.

 

 To push an existing repository

 

Go to var/www/html/project-folder


git init

git config --global user.name "Your Name"

git config --global user.email "Your Email"

--------------------------------------------------------

git config --list to check current username & email

  1. Change username & email as desired. Make it a global change or specific to the local repo:
    git config [--global] user.name "Full Name"
    git config [--global] user.email "email@address.com"
  2. Per repo basis you could also edit .git/config manually instead
  3. -------------------------------------------------------------------------------------------------------------

 

create github repository

Add local machine ssh key to your github settings ssh


git remote add origin git@github.com:dawnStreaks/github_repo_name.git
git add . //to add all files
git commit -am “adding new project” //t
git push origin master

Please make sure you have the correct access rights
----------------------------------------------------
in case of any errors remove the remote origin,  then reset it in the following way:
-----------------------------------------------------------------------------------
        git remote rm origin
        git remote add origin  https://USERNAME:PASSWORD@github.com/username/reponame.git 
or       git remote add origin git@github.com:username/reponame.git  
 References:
https://www.atlassian.com/git/tutorials/syncing/git-pull 

No comments:

Post a Comment