Git things with VSCode

Visual Studio Code has native support of Git. Also you can use other Source Control Management (like VSTS, SVN) simply by installing additional extension.

Install Git

What this does is invoking git commands from it’s interface. So to keep this working you have to install Git in your system (git-scm.com) and make it available on command line.

Next set a user by typing those commands:
$ git config --global user.name "Jan Nowak"
$ git config --global user.email jannowak@example.com

GitHub uses the email address set in your Git configuration to associate commits pushed from the command line with your GitHub account!

Keep in mind that there are 3 levels of git config:
1. project: only available for the current project (.git/config in the project’s directory)
2. global: available for all projects for the current user
3. system: available for all the users/projects

Now you have access commands through command palette (Ctrl+Shift+P) and control panel.

 

Initialize repository

There are two ways for doing this:

1. Clone existing Git repo from a remote source like GitHub or VSTS.

2. Initialize a repo locally and push it to a remote.
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/pythonsway/something.git
git push -u origin master

 

Making changes

Cloning automatically sets up your local master branch to track the remote master branch.

git fetch
only downloads the data to your local repository, it doesn’t automatically merge it with any of your work or modify what you’re currently working on.

git pull
fetches data from the server you originally cloned from and automatically tries to merge it into the code you’re currently working on.

Changes are merged automatically. When they are referring to the same source the conflicts occur.

 

Pushing changes

.gitignore file

This file lists things that shouldn’t be tracked, basically you should consider to include such things as:
1. Programming language specific stuff (GitHub has good templates)
2. Secret informations
3. .vscode folder

Adding remote

When you git clone, git fetch, git pull, or git push to a remote repository using HTTPS URLs on the command line, you’ll be asked for your GitHub username and password. To get rid of it you can use:
1. a credential helper so Git will remember your GitHub username and password every time it talks to GitHub.
2. GitHub Desktop
3. ssh connection link

 

But after all still you can do this in terminal…

 

Get Free Email Updates!

Signup now and receive an email once I publish new content.

I agree to have my personal information transfered to MailChimp ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Leave a Reply