10/14/2024

Git replace old files with new files

 

·        If the previous saved password is old and you get fail message when clone the repo, you can try below:

o   $ git config --global credential.helper cache

·        Then you should be able to update your username (PA****) and password


·        Clone the Repository: If you haven’t already, clone the repository to your local machine.

o   git clone https://github.com/your-username/your-repo.git

o   cd your-repo

 
·        Remove Existing Files: Delete all the existing files and folders in the repository. Be careful not to delete the .git directory.

o   rm -rf *

 
·        Copy New Files: Copy all the files from your new folder into the repository.

o   cp -r /path/to/new-folder/* .

 
·        Stage the Changes: Stage all the new files for commit.

o   git add .

 
·        Commit the Changes: Commit the changes with a meaningful message.

o   git commit -m "Replace old files with new files"

 
·        Push the Changes: Push the changes to the remote repository.

o   git push origin main

没有评论: