git常用命令
要配置Git的用户名和密码,您可以使用以下命令:
- 设置用户名:
git config --global user.name "Your Name"
- 设置用户邮箱:
git config --global user.email "youremail@example.com"
- 设置用户密码缓存:
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
- 删除远程仓库:
git remote rm <remote_name>
这将把远程仓库地址设置为 https://github.com/username/repository.git
,并将其命名为 origin
。
3.查看已经关联的远程仓库:
git remote -v
需要在本地新建一个和远程分支同名的分支,可以使用git checkout -b <branch_name> origin/<branch_name>
要拉取远程分支的代码,你可以使用以下命令:
git fetch origin branch-name
git checkout branch-name
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律