skip to Main Content

I have noticed that on my laptop, it lets me initialize repositories and use source control in visual studio code. But when I go to source control on my main PC, it tells me to download git for windows.

what it shows

On my laptop I have never downloaded git but now on my pc I have to.

How it is on my laptop

Has anyone had this issue before?

So I downloaded git as it said and it tells me that I can reopen closed repository. So I downloaded git as it said and it tells me that I can reopen closed repository.

before downloading git:

before downloading git

after downloading git:

after downloading git

if i press reopen repository:

if i press reopen repository

That repository doesn’t even open.

2

Answers


  1. Why do I need to download Git, if it is built into VS Code?

    As far as I know, Git is not built into VS Code.

    Indeed, from the official docs at https://code.visualstudio.com/docs/sourcecontrol/overview#_working-in-a-git-repository:

    Make sure Git is installed. VS Code will use your machine’s Git installation (at least version 2.0.0), so you need to install Git first before you get these features.

    If on one of your machines you were able to use the Git support of VS Code, that means Git was already installed before you got it, or that sometime when you had it, it was installed.

    For macOS, see Is git pre-installed on macOS Sierra? and Is git already installed when buying a new Macbook?. TL;DR it comes with a shim that prompts you to actually install Git.

    Login or Signup to reply.
  2. It is likely that your VS Code installation installed it by default. Normally you need to install a Git Client on your computer and enable it for VS Code if you are using it.

    Additional details

    Please continue to read if you are new to the concept of Git to understand the big picture better.

    Git is a distributed version control system that lets developers track source code changes during software development. It is fast and super flexible. You can create as many branches as you need and switch between branches as you wish.

    Distributed Version Control System means Git has a remote repository which is stored on a server and a local repository which is stored on the computer of each developer. This means the code is not just stored on a central server, but the full copy of the code is present on all developers’ computers (assuming they all pulled the latest code to their computers).

    In order to work with a Git repo, you should install a Git Client.

    A Git client is a software application that allows you to interact with a Git repository. You can use a Git client to perform actions such as committing changes, creating branches, merging changes, and more. Some popular Git clients include Git CLI, GitKraken, and SourceTree. A lot of developers prefer to work with applications like Git Bash, Command Prompt or PowerShell on Windows and Homebrew, MacPorts, Xcode on macOS.

    Bonus

    Quite a few people prefer to work with a Git GUI client which is a powerful alternative to command line options like Git Bash. I personally recommend you to get used to working with a command line tool. Below are the most common bash commands.

    Set global settings for user information

    $ git config --global user.name "[name]"
    
    $ git config --global user.email "[email address]"
    

    Check status

    git status
    

    Clone a project and working with branches

    $ git clone [https://repository-link]
    
    $ git checkout [branch-name]
    

    Creating a new branch

    $ git checkout -b feature/[branch-name]
    
    $ git checkout -b bugfix/[branch-name]
    
    $ git checkout -b release/[branch-name]
    

    Renaming an existing branch

    Long version of renaming a branch (from bugfix to feature in this example)

    git branch -m bugfix/[branch-name] feature/[branch-name]
        
    

    Short version of renaming a branch (from bugfix to feature in this example)

    git branch -m {bugfix,feature}/[branch-name]
    

    Adding changes for commit

    This is for adding a single file, following 2 commands are adding all allowed changed files

    $ git add [file]
    
    $ git add -A
    
    $ git add .
    

    Committing and pushing

    $ git commit -m "commit message"
    $ git push
    

    If the branch is newly created.

    $ git push --set-upstream [remote] [branch-name]
    

    Changing the most recent commit message

    $ git commit --amend -m "new commit message"
    

    Pull, fetch and merge

    $ git pull
    
    $ git fetch
    
    $ git merge [branch-name]
    

    Reset changes

    $ git reset [commit]
    
    $ git reset --hard [last-known-good-commit]
    

    Undo the last commit, do not keep the changes.

    $ git reset --hard HEAD~1 
    

    Undo the last commit, keep the changes.

    $ git reset --soft HEAD~1
    

    Show all ignored files

    $ git status --ignored
    

    Check local, remote and all branches

    $ git branch
    
    $ git branch -r
    
    $ git branch -a
    

    Delete a local branch

    $ git branch -d feature/branch-name
    
    $ git branch -d bugfix/branch-name
    
    $ git branch -d hotfix/branch-name
    

    Delete a remote branch

    $ git push origin --delete feature/branch-name
    

    Tag checking and creation

    $ git tag
    
    $ git tag -a [tag-name] -m "tag description"
    
    $ git push origin [tag-name]
    

    Start using SSH in a repository where I am currently using HTTPS

    $ git remote set-url origin [email protected]:v3/rest-of-your-project-ssh-url
    

    Stash changes

    Save the un-committed changes in a "stash". This will remove changes from working tree.

    $ git stash
    

    List the stashes

    $ git stash list
    

    Apply stash to working tree in current branch

    $ git stash apply
    

    Apply the stash 0 – change the number in order to apply other stashes

    $ git stash apply stash@{0}
    

    Remove the stash 0 from stash list – change the number in order to apply other stashes.

    $ git stash drop stash@{0}
    

    Apply the selected stash and remove it from the stash list.

    $ git stash pop stash@{1}
    

    Show all commits of the current branch as well as the parent branch and its commits

    $ git log --first-parent
    

    Exit git log history

    For exit

    $ :q
    

    For help

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