How to upload a project to Github

前端 未结 23 1373
误落风尘
误落风尘 2020-11-29 14:04

After checking Upload my project to github I still have no idea how to get a project uploaded to my Git Hub repository.

I\'m new to GitHub and I have no idea what to

相关标签:
23条回答
  • 2020-11-29 14:57
    git push --force origin master
    

    if you have problems uploading!

    0 讨论(0)
  • 2020-11-29 15:01

    Follow these steps to upload your project to Github

    1) git init

    2) git add .

    3) git commit -m "Add all my files"

    4) git remote add origin https://github.com/yourusername/your-repo-name.git

    Upload of project from scratch require git pull origin master.

    5) git pull origin master

    6) git push origin master

    If any problem occurs in pushing use git push --force origin master

    0 讨论(0)
  • 2020-11-29 15:02

    Here I explain how I did it on Window, maybe it also helps others :)

    Make sure to install Git and GitHub.

    After installation is complete, open “git bash”;

    so a window like below is gonna pop up:

    Go ahead and type cd ~ to make sure you are on home directory;

    You can check the address that you are in it by typing pwd;

    Now you need to create a GitHub account;

    After creating a GitHub account, go ahead and sign in;

    After you signed in, on the top right click on the + and choose “New Repository”

    Then in the opened window, type the name that you wish to have for the repository in the “Repository name” box. Add “Description (optional)” if you like, and mark “Initialize this repository with a README”. Then click on “Create repository”.

    Now go to your C driver; create a new folder and name it “git” Now go to the “git bash” window; change the directory to c drive by typing cd ~; cd /c If you type ls there it would show you the folders there; Make sure it shows the git folder there:

    Now go back to the browser; go to your GitHub page, click on the repository that you made; and click on “Clone or download”; and copy the address that shows there (by choosing copy to clipboard)

    Now going back to “git bash”; Use the command cd git to go to the git folder; now write the following commands to connect to your GitHub (enter the username and password of your GitHub when it asks you)

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

    And then: git config --global user.email youremail@domain.com . Next type: git clone (url), instead of the (url), type the address of the GitHub repository that you copied from your GitHub page; (e.g. git clone https://github.com/isalirezag/Test.git).

    Now if you do ls command you will see your repository there; If you also open the git folder that you have in your window you will see that your repository is added as a folder.

    Now use the cd command to go to the repository: cd Test

    Go ahead and copy and paste any files that you want to put in this repository in that folder.

    In order to transfer the files to your repository you need to do following now:

    Type git

    add filename (filename is the file name that you want to upload) or you can type the command below if you want to add all the files in the folder:

    git add .

    Then type: git commit -m "adding files" . And then: git push -u origin master .

    And then you should be all set, if you refresh your GitHub account the files should be there :)

    0 讨论(0)
  • 2020-11-29 15:03

    Since I wrote this answer, github released a native windows client which makes all the below steps redundant.

    You can also use sourcetree to get both git and mercurial setup on Windows.


    Here is how you would do it in Windows:

    1. If you don't have git installed, see this article on how to set it up.
    2. Open up a Windows command prompt.
    3. Change into the directory where your source code is located in the command prompt.
    4. First, create a new repository in this directory git init. This will say "Initialized empty git repository in ....git" (... is the path).
    5. Now you need to tell git about your files by adding them to your repository. Do this with git add filename. If you want to add all your files, you can do git add .
    6. Now that you have added your files and made your changes, you need to commit your changes so git can track them. Type git commit -m "adding files". -m lets you add the commit message in line.

    So far, the above steps is what you would do even if you were not using github. They are the normal steps to start a git repository. Remember that git is distributed (decentralized), means you don't need to have a "central server" (or even a network connection), to use git.

    Now you want to push the changes to your git repository hosted with github. To you this by telling git to add a remote location, and you do that with this command:

    git remote add origin https://github.com/yourusername/your-repo-name.git

    *Note: your-repo-name should be created in GitHub before you do a git remote add origin ... Once you have done that, git now knows about your remote repository. You can then tell it to push (which is "upload") your commited files:

    git push -u origin master

    0 讨论(0)
  • 2020-11-29 15:04

    How to upload a project to Github from scratch

    Follow these steps to project to Github

    1) git init

    2) git add .

    3) git commit -m "Add all my files"

    4) git remote add origin https://github.com/yourusername/your-repo-name.git

    Upload of project from scratch require git pull origin master.

    5) git pull origin master

    6) git push origin master

    0 讨论(0)
  • 2020-11-29 15:04

    What you need it an SSH connection and GitHub init into your project. I will explain under Linux machine.

    Let's start with some easy stuff: navigate into your project in the terminal, and use:

    git init
    git add .
    git commit 
    

    now let's add SSH into your machine: use ssh-keygen -t rsa -C "your_email@example.com" and copy the public key, then add it to your GitHub repo Deploy keys -> add one back to your machine project now launch: git push origin master if there is an error config your .github/config by nano .github/config and change the URL to ssh one by url = git@github.com:username/repo.... and that's it

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