How to upload a project to Github

前端 未结 23 1349
误落风尘
误落风尘 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:44

    Follow the instruction from RishiKesh Pathak above, you can even short the push command by inserting this command line one time only:

    git config --global push.default simple
    

    So next time instead of using git push origin master you just need:

    git push
    

    See details here.

    0 讨论(0)
  • 2020-11-29 14:45

    Follow these two steps:

    1. Create the repository online using the link: https://github.com/new
    2. Then link your local repo to the remote repo using the command: git add remote origin https://github.com/userName/repo.git Here the repo.git will be your newly created remote repo.

    This will work like a charm. No need to worry about the SSH or HTTPS ways. I first faced the same issue and spent hours for solution. But this worked for me.

    0 讨论(0)
  • 2020-11-29 14:45

    Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub. Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).

    Change the current working directory to your local project.

    Initialize the local directory as a Git repository.

    git init
    #Add the files in your new local repository. This stages them for the first commit.

    git add
    # Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'. Commit the files that you've staged in your local repository.

    git commit -m 'First commit'
    #Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.

    1. At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL. At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.
    2. In the Command prompt, add the URL for the remote repository where your local repository will be pushed.

    $ git remote add origin remote repository URL # Sets the new remote git remote -v # Verifies the new remote URL Note: GitHub for Windows users should use the command git remote set-url origin instead of git remote add origin here. Push the changes in your local repository to GitHub.

    $ git push origin master
    # Pushes the changes in your local repository up to the remote repository you specified as the origin.

    Source Attribution: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

    0 讨论(0)
  • 2020-11-29 14:45

    for uploading a new project into GIT (first you need to have local code base of project and the GIT repo where you will be uploading project ,in GIT you need to have your credentials)

    1. List item

      1.open Git Bash

      2 . go to the directory where you have the code base (project location ) cd to project location cd /*/***/*****/***** Then here you need to execute git commands

      1. git init press enter then you will see something like this below Initialized empty Git repository in *:/***/****/*****/.git/ so git init will initialize the empty GIT repository at local
      2. git add . press enter the above command will add all the directory,sub directory , files etc you will see something like this warning: LF will be replaced by CRLF in ****. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in **************. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ************. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *************** The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in j*******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ***********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in **************. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ***********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *********. The file will have its original line endings in your working directory.

      3. git commit -m "first commit" press enter -m provided option for adding comment it will commit the code to stage env you will see some thing like this

    [master (root-commit) 34a28f6] adding ******** warning: LF will be replaced by CRLF in c*******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *******. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in ********. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in *********. The file will have its original line endings in your working directory.

    warning: LF will be replaced by CRLF in ***********.


    27 files changed, 3724 insertions(+) create mode 100644 ***** create mode 100644 ***** create mode 100644 ***** create mode 100644 ****** create mode 100644 ****** create mode 100644 ***** create mode 100644 ******

    6.git remote add origin http://username@git:repopath.git press enter this will add to repo

    7.git push -u origin master press enter this will upload all from local to repo in this step you need to enter password for the repo where you will be uploading the code. you will see some thing like this below Counting objects: 33, done. Delta compression using up to 12 threads. Compressing objects: 100% (32/32), done. Writing objects: 100% (33/33), 20.10 KiB | 0 bytes/s, done. Total 33 (delta 14), reused 0 (delta 0) To http://username@git:repolocation.git * [new branch] master -> master Branch master set up to track remote branch master from origin.

    0 讨论(0)
  • 2020-11-29 14:46

    Probably the most useful thing you could do is to peruse the online book [http://git-scm.com/book/en/]. It's really a pretty decent read and gives you the conceptual context with which to execute things properly.

    0 讨论(0)
  • 2020-11-29 14:50

    This worked for me;

    1- git init
    2- git add .
    3- git commit -m "Add all my files"
    4- git remote add origin https://github.com/USER_NAME/FOLDER_NAME
    5- git pull origin master --allow-unrelated-histories
    6- git push origin master
    
    0 讨论(0)
提交回复
热议问题