Push Existing Files #192005
Replies: 5 comments
-
|
1.Clone the repository to a new folder on your computer. |
Beta Was this translation helpful? Give feedback.
-
|
You can push your existing local files to a GitHub repository and replace its contents, but the exact steps depend on whether you want to overwrite history or just update files. Case 1: Push local files and overwrite remote (most common)If you already have files on your computer: # Go to your project folder
cd your-project
# Initialize git (if not already)
git init
# Add remote repository
git remote add origin https://github.com/your-username/your-repo.git
# Add all files
git add .
# Commit
git commit -m "Initial commit"
# Force push (overwrites remote content)
git push -f origin mainNOTE: This will replace everything on the remote repository. Case 2: Replace old repo with new content (clean reset)If the repo already has content and you want to completely replace it: git init
git add .
git commit -m "Replace old content"
git branch -M main
git remote add origin https://github.com/your-username/your-repo.git
git push --force origin mainImportant Notes
|
Beta Was this translation helpful? Give feedback.
-
|
You just need to add, commit, and push. In your project folder: |
Beta Was this translation helpful? Give feedback.
-
|
If you're already connected to a remote repo, it's just: git add .
git commit -m "update files"
git push origin mainTo completely replace everything on the remote (overwrites history): git push --force origin mainStarting from scratch with no git setup yet: git init
git add .
git commit -m "initial commit"
git remote add origin https://github.com/yourname/yourrepo.git
git push -u origin mainIf push gets rejected with "non-fast-forward," run |
Beta Was this translation helpful? Give feedback.
-
|
Hi! If you want to push your local files to an existing GitHub repository and "replace" what is currently there with your local version, you can follow these steps.
Bash Bash
Bash |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Question
💬 Feature/Topic Area
ARC (Actions Runner Controller)
Discussion Details
How do i push my existing files to my repositories??
and replace it with the old one?
Beta Was this translation helpful? Give feedback.
All reactions