Changes in codespaces are not showing up in the clone of repo #163187
-
Select Topic AreaQuestion BodyHello, I'm very new using Git and Github, so forgive me in advance if I am not being the most clear with the terminology. I recently made a codespace from a repo created by someone else to follow a script from a coding tutorial. In the codespace, I changed some files and added some code as part of some exercises as well as some comments which I now want to save to a local clone of the repository. I first forked the repo as it sounded like if I wanted to save those changes in my own account, doing so would be one method. When I create a codespace from the forked repo, I do see the changes I originally made. I read that i needed to commit all changes in order for the repo to be updated, and so I did that within codespaces, and that is where I stopped doing anything else in codespaces (it sounds like I may need to publish as well...? but that runs into issues as well...) The problem comes when I try to clone the forked repo. The committed changes in codespace does not make it into the local copy that appears on my desktop. Can someone advise on how to clone the forked repo with all the changes made in codespace? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
|
What issue does appear? Do you get an error? |
Beta Was this translation helpful? Give feedback.
-
|
Hi, it sounds like your changes were committed inside the Codespace, but not yet pushed to your forked GitHub repo. That’s why you don’t see them when cloning locally. To fix this: Then, on your local machine: If not, clone it using: |
Beta Was this translation helpful? Give feedback.
-
Cloning My Codespace Changes to a Local RepositoryI'm very new to Git and GitHub, so I wanted to document the steps I followed to clone the changes I made in a GitHub Codespace to my local computer. What I DidI started by forking a repository that someone else created, and then I created a Codespace from that fork. I made changes in the Codespace — added some code, comments, and completed some exercises. After finishing my work, I wanted to save those changes to my local machine by cloning the forked repository. However, I noticed that when I cloned the repo to my desktop, none of my changes showed up. What I LearnedThe reason my changes weren’t in the cloned repo is because I hadn’t pushed the commits from the Codespace to GitHub. Committing changes in a Codespace doesn’t automatically upload them to GitHub — I also need to push them. Here’s what I did to fix it: Step-by-Step Instructions1. Make Sure All My Changes Were Committed in CodespaceIn the Codespace terminal, I ran: git add .
git commit -m "My changes from the tutorial"2. Push My Changes to My GitHub ForkTo upload the changes to GitHub, I ran: git push origin mainIf I saw an error about no upstream branch, I used: git push --set-upstream origin mainThis pushed all my local changes from the Codespace into my forked repository on GitHub. 3. Clone the Forked Repo LocallyNow that my fork on GitHub had the changes, I could safely clone it to my computer: git clone https://github.com/MY_USERNAME/MY_FORK_NAME.gitI replaced Optional: Push to a Separate BranchIf I didn’t want to put my changes directly on the git checkout -b my-changes
git push origin my-changesFinal CheckI double-checked my fork on GitHub and confirmed that my files and commits were there. Then, cloning worked as expected. Hopefully this helps me or others if I ever run into the same issue again! |
Beta Was this translation helpful? Give feedback.
-
|
Hi all. I figured out my issue. I de-committed the pkl file listed in the error seen in my replies. It was easiest just to remove the file as it was a file that the code generated. I was able to then commit and push my changes to the fork which made it into my clone. Thanks everyone that clarified the process! |
Beta Was this translation helpful? Give feedback.
Hi all. I figured out my issue. I de-committed the pkl file listed in the error seen in my replies. It was easiest just to remove the file as it was a file that the code generated. I was able to then commit and push my changes to the fork which made it into my clone. Thanks everyone that clarified the process!