Push Existing Files #192005
-
🏷️ Discussion TypeQuestion 💬 Feature/Topic AreaARC (Actions Runner Controller) Discussion DetailsHow do i push my existing files to my repositories?? |
Beta Was this translation helpful? Give feedback.
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.
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:
NOTE: This will replace everything on the remote repository.
Case 2: Replace old repo with new co…