Home > front end >  How to access files after committing them in Visual Studio Code
How to access files after committing them in Visual Studio Code

Time:08-12

So I have changes to my code as I am working locally on a newer version of my project and had to commit my changes so I can pull and merge changes from my master branch (there were minor changes on the master version of the project that I needed to add to my code and they were done by a different developer so they were pushed to the branch directly.

But now I need to access the files (or stage the commits) so I can copy the changes I made (I didn't push them to the branch) as files. Normally I undo last commit which would return my files to staged changes but I have 3 commits and one of them is a merge commit (merge code from master to my code locally).

How can I access my files without deleting the changes?

CodePudding user response:

So basically few commands you can check:

you can do soft(after reset will keep changes locally) reset

git reset --soft HEAD~{number of commits}

you can do hard(after reset will NOT keep changes locally) reset

git reset --hard HEAD~{number of commits}

PS: If you want to stash your changes locally and take a pull and if all fine apply your stash changes.

git stash save name

if you want to show all stash list

git stash list

if you want to apply the stash changes:

git stash apply stash{tag}

But what you have done if I understood correctly:

Try these and please read a bit about it.

CodePudding user response:

If you want to inspect the content of a file in a given commit without checking out that file, you can use git show :

git show <commit>:path/to/file
git show <commit>:path/to/file > tempfile.txt
  •  Tags:  
  • git
  • Related