skip to Main Content

I have visual studio 2019.

  1. I write some code.
  2. Commit.
  3. Push.

Now pending changes are gone.
Is there any way how can I have still all files in pending changes even after push? (all files that differ from main)

2

Answers


  1. After committing all staged changes, you have no more staged changes.

    Once you have created a commit, you can see what is in that commit however:

    • either in your IDE (visual studio) there is probably a git pane where you can view the contents of a commit.
    • on command-line: git show <commit>
    Login or Signup to reply.
  2. tl;dr: You can’t have them listed as pending changes, because they aren’t pending changes anymore. However, you can still easily see what you want. Skip down to the section "Now to finally answer your question" if you’re in a hurry.

    When working with Git, I recommend having the history of your branch open in another window/tab pretty much all the time, and refresh it after any change you make to your branch (if your UI doesn’t auto-refresh it for you). The reason for this is by keeping an eye on your commits you’ll continuously validate that you’re doing exactly what you think you’re doing (especially important if you rebase frequently), and it also enables you to quickly look at any work you’ve already done when you want additional context. As your question points out, it’s common to desire this additional context, especially when you’re working on a feature with multiple commits.

    When using Git in Visual Studio, there are two views that can display your branch history. Under the Git menu, there are two relevant options:

    1. View Branch History: This opens a window showing your branch history right now, and if you are tracking an upstream branch it will show outgoing and incoming commits as well. This view does not auto-refresh so you should use the refresh button in the upper left corner of the window to manually refresh it anytime you modify your branch. (Note you can also get to this view by right clicking on your checked out branch name in the bottom right corner of VS2019. If the fly-up branch list contains so many local branches that you can’t see your bolded branch, you can start typing in the search box to find it, then right click on your branch.)
    2. Manage Branches: This opens a window displaying all of the branches in your repo; local branches are first, and remote branches appear below it. You can simply click on any branch to see it’s history, and by default your branch will be selected first. This view auto-refreshes. (Note you can also get to the view by right clicking on your checked out branch name in the bottom right corner of VS2019, then in the fly-up at the top right click on the 3 dots menu and select "Manage Branches". Or, in your Git Changes Window at the top next to your branch name, there is a 3 dot menu with more options that also includes this.)

    Note that both of these views contains icons at the top of the window to enable you display other local branches, remote branches, and tags, all in the same view if they are pointing to any of the same commits you can see in the current branch’s history.

    Now to finally answer your question:

    In either of the views described above, you can view the changes in any single commit, but you can also select two commits (left click on one commit, hold down the control key and left click on another commit), and then right click and select "Compare Commits…". By comparing the parent commit of your first commit (possibly main would be displayed there in your history if it hasn’t moved yet since you branched off of it), with your tip commit, you will see all the entire set of changes you made across all commits in your comparison. This should be what you wish to see while working on a feature.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search