git常用命令

发布时间 2023-10-09 09:30:34作者: fenglongyun

要配置Git的用户名和密码,您可以使用以下命令:

  1. 设置用户名:
git config --global user.name "Your Name"
  1. 设置用户邮箱:
git config --global user.email "youremail@example.com"
  1. 设置用户密码缓存:
git config --global credential.helper cache

这将在10分钟内缓存您的密码,以便在这段时间内无需多次输入密码。

如果您需要更长时间的缓存时间,可以使用以下命令:

git config --global credential.helper 'cache --timeout=3600'

这将在1小时内缓存您的密码。您可以根据需要更改超时值。
4. 可以通过以下命令查看当前git用户的配置:

git config --list

远程仓库增加、删除、查看可以使用以下命令:

1.增加一个远程仓库

git remote add <remote_name> <remote_url>

其中,<remote_name> 是远程仓库的名称,可以自定义,<remote_url> 是远程仓库的地址。

例如,要将本地仓库关联到名为 origin 的远程仓库,可以使用以下命令:

git remote add origin https://github.com/username/repository.git
  1. 删除远程仓库:
git remote rm <remote_name>

这将把远程仓库地址设置为 https://github.com/username/repository.git,并将其命名为 origin

3.查看已经关联的远程仓库:

git remote -v