Home > Common Problem > body text

What is the command to submit code in git

百草
Release: 2023-06-15 13:25:47
Original
5495 people have browsed it

The command for git submission code: 1. Initialization, the code is "git init"; 2. Add files, the code is "git add filename"; 3. Add all files to the buffer, the code is "git add ." and "git add --all"; 4. Submit, the code is "git commit -m "commission description""; 5. Push to the remote branch, the code is "git push origin master".

What is the command to submit code in git

The operating system of this tutorial: windows10 system, git version 2.37.3, DELL G3 computer.

1. Initialization: Create a git warehouse. After creation, a .git file will be generated in the current directory

git init
Copy after login

2. Add files: Add the file to the buffer

git add filename
Copy after login

3. Add all files to the buffer (from the current level of understanding, the difference between adding "." and adding "all" is that adding "all" can add manually deleted files, but adding "." cannot):

git add .
git add --all
Copy after login

4. Submit: Submit all modifications in the buffer to the warehouse (note: if the file is modified but not added to the buffer, it will not be submitted)

git commit -m "提交的说明"
Copy after login

5. Push to the remote branch

git push origin master
Copy after login

If vscode needs to enter the account and password every time, execute the command on the console:

git config --global credential.helper store
Copy after login

Enter the account and password again to restart the command

PS1: Push to the specified warehouse

git remote add origin git@github.com:michaelliao/learngit.git #添加远程仓库
git push -u origin master #初始化推送
git push origin master #提交主分支
Copy after login

PS2: Use vscode to pull code Tip: Please clean the repository working tree before checking out

Solution:

1、git stash (把当前未提交的修改暂存起来,让仓库还原到最后一次提交的状态。)
2、git pull (拉取远程仓库的代码,让你现在的代码和远程仓库一致)
3、git stash pop (恢复第一步储存起来的代码,也就是恢复当前未提交的修改)
Copy after login

PS3: Merge code

1、git branch(查看所有分支及当前分支)
2、git checkout  test(切换到想要合并的分支)
3、git merge feature/sysyem(分支合并到test)
4、git push (推送)
Copy after login

ps4: git modify user name and email

1、git config user.email # 获取用户邮箱
2、git config user.name # 获取用户名
3、git config --list # 获取用户全部信息
4、git config --global user.name "你的目标用户名" # 修改全局用户名
5、git config --global user.email "你的目标邮箱" # 修改全局邮箱
6、git config user.name "你的目标用户名" # 修改当前的 project 的用户名
7、git config user.email "你的目标邮箱" # 修改当前的 project 的邮箱
Copy after login

ps5: If the ssh certificate authentication fails, directly execute the command line

git config --global http.sslVerify "false"
Copy after login

ps6: git commit specification

What is the command to submit code in git

The above is the detailed content of What is the command to submit code in git. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!