Git

1 minute read

Published:

Git配置

https://www.digitalocean.com/community/tutorials/how-to-contribute-to-open-source-getting-started-with-git

Check If Git is Installed

git --version

However, if Git is not installed, you will receive an error similar to the following:

-bash: git: command not found
'git' is not recognized as an internal or external command, operable program or batch file.

In this case, you should install Git into your machine. Let’s go through installation for several of the major operating systems.

Installing Git on Linux

Installing Git on Ubuntu 18.04 or Debian 10

sudo apt update
sudo apt install git

Installing Git on Windows

https://git-scm.com/download/win

Setting Up Git

git config --global user.name "Your Name"
git config --global user.email "youremail@domain.com"

We can see all of the configuration items that have been set by typing:

git config --list

Using VScode

CTRL + `

mkdir git_test
cd git_test

Then, create a Git repository:

git init
ls -la

Another way to accomplish this with Visual Studio Code is by opening up the Source Control tab (the icon looks like a split in the road) in the left-side panel:

Untitled

Next, select Open Folder:

Untitled 1

This will open up your file explorer to the current directory. Select the preferred project directory and click Open.

Then, select Initialize Repository:

Untitled 2

After doing so, you’ll see in the Source Control panel that your new file shows up with the letter U beside it. U stands for untracked file, meaning a file that is new or changed, but has not yet been added to the repository:

Untitled 3

Once added, the letter next to the file will change to an AA represents a new file that has been added to the repository.

To commit your changes, type a commit message into the input box at the top of the Source Control panel. Then, click the check icon to perform the commit.

Untitled 4

After doing so, you will notice that are no pending changes.

proxy

git config --global http.proxy 'socks5://127.0.0.1:45077'
git config --global https.proxy 'socks5://127.0.0.1:45077'
git config --global http.proxy 'http://127.0.0.1:45077'
git config --global https.proxy 'http://127.0.0.1:45077'