I made a repo on my laptop. It has a project page on github.com.
I'm now working on my desktop computer. I manually copied over some files because I didn't think I would need every file from the repo (so I didn't clone the repo onto my desktop). How can I connect my desktop local folder with the existing repo so that I can push the files on my desktop to the repo (the desktop files are now the most recent versions of those files, since I stopped working from my laptop)
Adding an existing project to GitHub using the command line:
# Initialize the local directory as a Git repository.
git init
# Add files
git add .
# Commit your changes
git commit -m "First commit"
# Add remote origin
git remote add origin <Remote repository URL>
# <Remote repository URL> looks like: https://github.com/user/repo.git
# Verifies the new remote URL
git remote -v
# Push your changes
git push origin master
And 2nd way as @evolutionxbox suggest you:
If in any case git reject your push you can use git push origin master --force
UPDATE (10-23-2020): Bear in mind that since October 1st, 2020, Github renamed the default repository from master to main https://github.com/github/renaming
Create a local repository in the temp-dir directory using: git clone temp-dir
Go into the temp-dir directory.
do a git branch -a
Checkout all the branches that you want to copy from origin using git checkout branch-name
You are done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.