Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Terminal Git tracking vs VS Code git tracking is not in sync

When I add, modify OR delete files from Terminal (I am using iTerm2 -oh my zsh- git extension) stage them and commit them it doesn't reflect in my VS code git tracking.

My source control section in VS code still says that changes are not staged OR tracked with git.
And I have to stage and commit them again.

When I open terminal in VS code and check git config --list, both iTerm2 terminal and VS code terminal shows same list of configuration.

Also log and history is also same when I check from both individual terminals.

It's just when I stage OR commit from either of my iterm2 terminal OR from VS Code, they both don't consider changes are staged OR committed if other terminal did, and still shows untracked OR not committed of each others.

Did any one face such issue before? Is anything to do with VS Code Git settings or so?

See screenshot exact error i am mentioning

like image 464
Vaibhav Chawale Avatar asked Jul 03 '21 19:07

Vaibhav Chawale


People also ask

How do I sync my Visual Studio Code with Git?

First, log in to your GitHub profile, view the files in it, and copy the repository URL. In the VS Code, click on the Clone Repository. It asks for the GitHub URL, pastes the URL, and clicks on the Clone from URL. Next, it asks for the folder in your local system.

What is sync changes in VS Code?

There is a Synchronize Changes action in the Status Bar, next to the branch indicator, when the current checked out branch has an upstream branch configured. Synchronize Changes will pull remote changes down to your local repository and then push local commits to the upstream branch.

What is publish branch in VS Code?

Branches let you work with multiple versions of the source code in the same local Git repository at the same time. You can use Visual Studio Code to publish, check out and delete branches. Click the Publish changes button next to the branch.

What is Git and how does it work?

What is Git? Git is a distributed approach to version control. Git was created by Linus Torvalds in 2005 to manage the development of the Linux Kernel. Put simply, Git tracks changes made to your files allowing you to revert to previous file versions if necessary. There’s one VS Code extension that will help you so much it seems like a hack.

Can You Drive Git with VS Code?

In this article, we will cover how you can combine some of the most powerful tools available to developers–VS Code and Git–to start making meaningful contributions to both open source and private projects. Before we get into driving Git with VS Code let’s start with some background. What is VS Code?

How do I commit changes in Git using VS Code?

To commit using the VS Code integrated terminal, run git commit -m. The -m flag is used to include a commit message that explains how your changes affect the project. Including a Git commit message is a best practice; this enables you and other project contributors to more easily track changes made to the project.

How do I know if Git is installed in Visual Studio?

To check whether or not you have Git installed, open the integrated terminal in VS Code by using the keyboard shortcut CTRL + and then type git --version. If the terminal returns git version followed by any version number, that indicates that you do in fact have Git installed.


Video Answer


1 Answers

Did any one face such issue before?

No, and if you actually make another commit with VSCode, after making one with iTerm2, there is no way, the git log would show you identical commits (SHA1), since part of a commit metadata is its creation date.

Try and add GitLens, to see more information on your local Git repository.

Check also for any GIT_xxx environment variable (like ones regarding Repository location -- GIT_DIR, GIT_WORK_TREE) which might explain why a Git repository is not seen by default.

like image 141
VonC Avatar answered Oct 21 '22 05:10

VonC