Git pushing to a private repo

前端 未结 4 826

I have been working on my local on a web app and I was ask to push it to an empty(only read me file on it) private repo created just for this project. I\'m new to git<

相关标签:
4条回答
  • 2020-12-07 12:09

    I was facing the same problem. I was able to solve this by removing old credentials from windows.

    1. Open Control Panel from the Start menu
    2. Go to User Accounts -> Credential Manager -> Manage Windows Credentials
    3. Delete any credentials related to Git or GitHub

    Once I did this, it started working again.

    0 讨论(0)
  • 2020-12-07 12:11

    Let us say 'yourWebApp' is the folder you have your local web app. Change it to the directory

    cd 'yourWebApp'
    

    Init git in the folder

    git init
    

    Now add your github url as a remote

    git remote add origin git://github.com/somename/Web-App.git
    

    Here origin is the short name for your url

    Now pull the read me file from the github repo

     git pull origin master
    

    Now push your web app to the github repository

    git push origin master
    

    Here it is assumed that you are in your master, the default branch

    Here pulling your readme files is necessary to merge the readme file with your local work. If your github repository is empty, you can skip the pull and directly push to your github repository.

    On the other hand, if you want to use clone, there is no need to init as clone automatically sets up git in the directory. clone also sets your remote git url. In that case, your workflow should be

     clone -> push
    
    0 讨论(0)
  • 2020-12-07 12:21

    To push to a private repository, you probably want to fork it, push your changes to your copy (which will stay private), and then create a pull request. When I tried to push directly to a private repository, I got the puzzling "remote: Repository not found. fatal" message, even though I could pull just fine.

    0 讨论(0)
  • 2020-12-07 12:30

    git clone is a little bit overkill for this purpose.

    The mechanism that git provides to deal with other servers is fittingly called remote. This is typically automatically set up when you clone, explaining why that was your instinct.

    Documentation can be found here:

    http://git-scm.com/book/en/Git-Basics-Working-with-Remotes

    Some summary commands:

    git remote add [remote-name] [branch-name]
    
    git fetch [remote-name]
    
    git push [remote-name] [branch-name]
    

    In addition, you might consider setting up tracking branches, which will eliminate the need to qualify the remote name each time you type a command. Documentation for that use case is here.

    http://git-scm.com/book/en/Git-Branching-Remote-Branches

    Usually, if you clone a repository, git executes git checkout -b master [remotename]/master

    Your tracking branch doesn't have to be master though.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题