Someone with the user name gikf commented that the file can be removed with an additional commit. You can look at the file added on the files tab but it looks like a bunch of command-line commands.
I did do one thing wrong: I used git fetch upstream on one of my branches instead of on main. Could that be the cause?
Regardless, how do I use a commit to remove a file that was in my last commit?
Probably! Something you have installed maybe adds it to git directories automatically… Googling “tream” doesn’t come up with anything for me though. Hmmm. See below
That’s it. I know right before that I tried git log but I did got instead of git. I also spelled another command wrong as well. I’ll slow down and be more careful and start looking for that file in my root folder.
Just make a habit to review your changes before committing them! On the git tab in VS Code it lists all the changed files so you can review them easily.
I am being asked to remove 8 of 9 of my changes for a different branch. I can make a new post, but would I do that similar to the above? 1. Make the changes, 2. Add, Commit, and Push and my original PR will be updated?
In general, you can use the git revert command to revert changes from previous commits:
git revert <commit_hash>
However, this will revert all the changes from that commit hash. So, if you only want to revert based on the file, it is also common to use git checkout:
git checkout <commit_hash> -- path/to/file
In this case, the commit hash is any hash when the file was in the state you want it to revert to.
Finally, if you are removing more than you are keeping, it could be worth resetting your branch to the point it was before the changes:
git reset <commit_hash>
Then, you can make the changes again, and force push to the same branch:
So if I use git reset <commit_hash>, make the one change that I am being told to keep, then do the normal add, commit, push origin my_branch_name., that will work? Should I do the last part on the same branch or should I delete that branch after the revert command and create a new branch?
Maintainers appreciate these two things in this priority:
Related conversation is kept in a central location
PRs are kept neat - easy to follow
At a quick glance, it looks like you should be able to do:
# You might need the --hard argument
git reset HEAD
# Make your wanted changes
git add .
git commit -m "fix(curriculum): what this does"
git push --force
# The above assumes you have set your branch to follow the remote branch on your origin
Assuming that, there should be no need for you to create a new branch, and there should be no need for you to create a new PR.