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)
To add and commit files to a Git repository Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With