Push existing project into Github

后端 未结 18 758
天涯浪人
天涯浪人 2020-12-04 04:25

I have a folder with my project sources. How I can push this project into Github\'s repository?

I tried using this steps:

  1. I created empty repository o
相关标签:
18条回答
  • 2020-12-04 05:01

    I will follow the previous comment from Rose P. It took me a long time to find the solution so I'm reposting (hopefully in plain English) what worked for me...

    step 1: Create your new repository on Github.com (skip if you already have one)

    step 2: Close XCode...not needed

    step 3: Open a new Terminal window (yes, you have to use terminal...I tried all other ways...nothing worked)

    step 4: Using the command cd to find your folder location to your project (the project you want to add to your existing or new repository)

    step 5: type git init you'll get something like this. Reinitialized existing Git repository in /{current directory}

    step 6: type git add . nothing happens after this step, but type it and go on to the next step.

    step 7: type git commit -m "Initial commit" you'll get the following: # On branch master nothing to commit, working directory clean

    or

    some explanation about configuration and then a list of files that have changed.

    step 8: type git remote add origin {project url} The project url can be found in Github.com. Its the HTTPS clone URL...you should be able to just copy and paste to the terminal window. If the system tell you that origin already exists, create a different name or use your project name (something different)

    step 9: go to your GitHub application on your mac and click the "Sync Branch" button (even if there are no pending changes). It takes awhile I think for it to actually commit, but if you go back to your local repository folder you should see your new project. I had to re-create the parent folder, but it's just a matter of moving your files around. Go to GitHub.com and refresh your browser and your new files should also be there.

    I hope that helps.

    0 讨论(0)
  • 2020-12-04 05:02

    I know, this is an old question but I'm trying to explain every step, so it may help others. This is how I add an existing source to git:

    1. Create the repo on the git, so you'll have the ssh || https where you're gonna remote add you source code.
    2. In your terminal go to the path of your project.
    3. Run git init (here you initiate the project as a git one).
    4. Run git add * (here you add all the files and folders from you project).
    5. Run git commit -m "Initial Commit." (here you commit your files and folders added in step #4; keep in mention that you can't push your changes without committing them).
    6. Run git remote add origin https://your_username@bitbucket.org/your_username/project-name.git (here you add a remote project where your source it's gonna be pushed; replace my link with your ssh || https from the step #1).
    7. Run git push -u origin master (here you push your source into the git repository).

    Note: Those are simple steps for pushing your source into the master branch.

    0 讨论(0)
  • 2020-12-04 05:04

    In summary;

    git init
    git status
    git add "*"
    git commit -m "Comment you want"
    git remote add origin  https://link
    git push  -u origin master
    

    I would like to share a source with you so that you learn about Git more easily.

    https://try.github.io/levels/1/challenges/1

    0 讨论(0)
  • 2020-12-04 05:05
    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. Copy remote repository URL fieldAt the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.

    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
    

    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

    0 讨论(0)
  • 2020-12-04 05:07
    1. From command line, navigate to your local repository directory.
    2. Create new repository in GitHub, it will provide you with a link ends with .git.
    3. in cmd run : git remote add origin [your_GitHub_Repository_link] (remember link should end with .git )
    4. then run : git push -u origin master

    Hope this was useful.

    0 讨论(0)
  • 2020-12-04 05:08
    Follow below gitbash commands to push the folder files on github repository :-
    1.) $ git init
    2.) $ git cd D:\FileFolderName
    3.) $ git status
    4.) If needed to switch the git branch, use this command : 
        $ git checkout -b DesiredBranch
    5.) $ git add .
    6.) $ git commit -m "added a new folder"
    7.) $ git push -f https://github.com/username/MyTestApp.git TestBranch
        (i.e git push origin branch)
    
    0 讨论(0)
提交回复
热议问题