git 常用命令

本地使用git:

创建并进入一个目录,mkdir learn-git, cd learn-git

创建git仓库:git init

添加文件到仓库:git add readme.txt

提交文件到仓库:git commit -m "write a readme file"

查看提交日志:git log

退回上一版本: git reset --hard HEAD^

查看历史commit ID:git reflog

退回指定版本:git reset --hard commit-ID

Git鼓励大量使用分支

查看分支:git branch

创建分支:git branch <name>

切换分支:git checkout <name>

创建+切换分支:git checkout -b <name>

合并某分支到当前分支:git merge <name>

删除分支:git branch -d <name>



查看工作区状态:git status

临时存储工作现场:git stash

查看临时工作现场:git stash list

恢复工作现场(恢复并删除stash内容);git stash pop

恢复工作现场(仅恢复,不删除stash内容): git stash apply

删除stash内容:git stash drop

如存在多个stash内容的时候,使用 git stash apply stash@{0} 


git 查看远程库 git remote 或者 git remote -v


Using: Intel (R) PRO Network Connections SDK v2.30.10 EEUPDATE v5.30.10.00 Copyright (C) 1995 - 2017 Intel Corporation Intel (R) Confidential and not for general distribution. ----------------------------------------------------- Options: /HELP or /? Displays command line help. /EXITCODES Displays exit code help. /ALL Selects all adapters found in the system. /NIC=XX Selects a specific adapter (1-32). /BUS=XX Selects PCI bus of adapter to program. Must be used with the DEV parameter to specify an adapter. /DEV=XX Selects PCI device of the adapter to program. Must be used with the BUS parameter to specify an adapter. /FUN=XX Selects PCI function of the adapter to program. Must be used with both the BUS and DEV parameters to specify an adapter. Press to continue... /DEVICE= 4 hex digit device id of card to program. /SUBDEVICE= 4 hex digit subsystem device id of card to program. /DUMP Dumps EEPROM/Shadow RAM memory contents to file *.eep and flash memory to *.bin (if available) /MAC_DUMP_FILE Dumps the MAC address to a file usable by the /A command. /MAC_DUMP Displays the adapter LAN MAC address. /MAC_DUMP_ALL Displays all the MAC addresses. /MAC_ALL_TO_FILE Dumps all the MAC addresses to a file usable by the /MAC_ALL_FROM_FILE command. /MAC_ALL_FROM_FILE Programs all MAC addresses from text file to a device. File should contain 13 MAC addresses (9 for PEPs and 4 custom MAC addresses), one each line. EUI48 and EUI64 formats accepted. /CB Clears bits in the EEPROM, specified in . /SB Sets bits in the EEPROM, specified in . Press to continue... /RW Reads from the EEPROM. /WW Writes into in EEPROM. /MAC=macaddr [/NUM=PF_num] Programs the EEPROM/NVM with only the MAC address of macaddr without changing the rest of the EEPROM/NVM. /NUM is optional and I40E specific - it defines target PF. /A or /address Programs the EEPROM/NVM with only the MAC address from the without changing the rest of the EEPROM. /D or /DATA Programs the NVM [EEPROM/FLASH] with the contents of without changing the MAC address. /PHYNVM Programs the PHY NVM with the contents of /DEBUG Forces debug update to be used where applicable. Must be used with /D or /DATA switch. /CALCCHKSUM Forces the EEPROM checksum and CRCs to be updated. Press to continue... /EEPROMVER Displays the version of the EEPROM image. /INVMVERSION Displays the version of the iNVM image. /PCIINFO Displays the PCI information of the adapter. /ADAPTERINFO Displays additional information about the adapter, such as EtrackID, PF MAC address, or image and firmware version. /TEST Checks the EEPROM/NVM checksum(s) and size. /IDFLASH Displays the flash ID and its protected status. /VERSION Displays version and the diagnostic library information. /PHYID Programs the PHY ID NVM with the contents of . /PHYID_DUMP Dumps PHY ID NVM contents to a file with the name: _.bin /PHYID_VERIFY Verifies the PHY ID NVM image in eeprom against the file specified in . Press to continue... /FLASH_DUMP Dumps contents of the whole flash memory of selected adapters to *.bin file /EEPROM_DUMP Dumps contents of the EEPROM/Shadow RAM memory of selected adapters to *.eep file /GUI Brings up GUI mode. /GUI /HELP Displays GUI help. /NOPROT When programming an image for devices that support NVM protection, prevents protection from being enabled. This switch must be used with the /DATA command and has no effect on NVM devices that are already protected. /DEBUGLOG Log debug messages into the debugfile. /VERIFY Verifies the eeprom/NVM image in eeprom/NVM to the target file specified in . Press to continue... /CHECKIMAGE Verifies that the NVM in can be loaded over the running NVM. /VERIFYPHYNVM Verifies the PHY NVM image in eeprom to the target file specified in . /ADAPTERRESET Reset the adapter. *CAUTION* This will unload the driver for this device if present. /SANMAC_DUMP [/NUM=PF_num] Displays the dedicated MAC address for the SAN. /NUM is optional and i40e specific - it defines target PF. /SANMAC=macaddr [/NUM=PF_num] Programs the dedicated SAN MAC address withoutchanging the rest of the EEPROM. /NUM is optional and i40e specific - it defines target PF. /SANADDRESS Programs the dedicated SAN MAC address with the MAC address from . /INVMVERIFY /FILE=] Compares autoload configuration stored in OTP memory with the configuration defined in configuration file. /INVMTEST /FILE=] Report number of free space left in INVM if autoload configuration defined in configuration file would be applied. Press to continue... /INVMUPDATE /FILE=] Write new autoload configuration defined in Raw (*.raw) configuration file to empty INVM or updates current autoload configuration stored in INVM based on 'human readable' configuration file. /INVMISLOCKED Checks if autoload configuration stored in OTP memory is protected against write attempts. /INVMLOCK Sets unique record in autoload configuration stored in INVM protecting its content against further updates. /INVMGET Dumps autoload configuration stored in INVM to file with predefined name .otp. /FORCE Omits any warnings and forces command execution. /KEEPCONFIG This option lets you keep config words while upgrading eeprom. /PORT_MAC=macaddr /NUM=Port_num Programs the dedicated Port MAC address without changing the rest of the EEPROM. /PORT_MAC_DUMP /NUM=Port_num Display the adapter port MAC address. Press to continue... /CUSTOM_MAC mac_number mac_addr Programs the given custom mac address number [0-3] without changing the rest of the NVM (EUI48 and EUI64 formats supported). /SERIAL_MAC=macaddr Programs the dedicated PCIe serial MAC address without changing the rest of the EEPROM. /SERIAL_MAC_DUMP Display the adapter PCIe serial MAC address. /PF_MAC=macaddr /NUM=PF_num Programs the dedicated MAC address of a specified Physical Function This allows altering the mac addresses of inactive functions of a visible NIC. /PF_MAC_DUMP /NUM=PF_num Display MAC address of a selected Physical Function of the specified NIC. This allows dumping MAC addresses of inactive functions of a visible device. /MNG_MAC=macaddr /NUM=MNG_num Programs the dedicated MAC address of a specified Manageability Function This allows altering the mac addresses of inactive functions of a visible NIC. /MNG_MAC_DUMP /NUM=MNG_num Display MAC address of a selected Manageability Function of the specified NIC. This allows dumping MAC addresses of inactive functions of a visible device. /RO Programs RO words in EEPROM/SR with values taken from RO Module binary file.
<think>我们被要求生成一个关于Git常用命令的汇总列表。根据用户的要求,我们需要提供结构清晰的回答,并尽量保证真实可靠。同时,我们参考了站内引用中提供的Git命令信息。根据引用内容,我们可以整理出以下常用命令:1.基本操作(初始化、添加、提交等)2.分支管理3.远程仓库操作4.标签管理5.历史查看与撤销6.其他实用命令(如删除大文件、清理仓库等)我们将按照这些类别来组织命令。注意:由于引用中提供了一些特定问题的解决方案(如删除大文件),我们也会将其作为实用命令的一部分。另外,注意用户要求使用中文回答,并且行内数学表达式使用$...$格式(但本问题不涉及数学表达式,所以忽略),独立公式使用$$...$$格式(同样不涉及)。同时,在回答末尾生成相关问题。我们开始整理Git常用命令汇总:</think>### Git常用命令汇总 以下是Git常用命令分类整理,帮助您高效管理代码版本: #### 1. 仓库初始化与基础操作 ```bash # 初始化新仓库 $ git init # 克隆远程仓库 $ git clone <远程仓库URL> # 查看当前状态 $ git status # 添加文件到暂存区 $ git add <文件名> # 添加单个文件 $ git add . # 添加所有修改 # 提交更改 $ git commit -m "提交说明" ``` #### 2. 分支管理 ```bash # 创建分支 $ git branch <新分支名> # 切换分支 $ git checkout <分支名> $ git switch <分支名> # Git 2.23+推荐方式 # 创建并切换分支 $ git checkout -b <新分支名> $ git switch -c <新分支名> # 合并分支 $ git merge <要合并的分支名> # 删除分支 $ git branch -d <分支名> # 安全删除 $ git branch -D <分支名> # 强制删除未合并分支 ``` #### 3. 远程仓库操作 ```bash # 添加远程仓库 $ git remote add origin <远程仓库URL> # 查看远程仓库 $ git remote -v # 推送到远程仓库 $ git push -u origin <分支名> # 首次推送 $ git push # 后续推送 # 拉取远程更新 $ git pull origin <分支名> $ git pull --rebase origin <分支名> # 变基式拉取 # 删除远程连接 $ git remote rm origin ``` #### 4. 版本回退与撤销 ```bash # 查看提交历史 $ git log $ git log --oneline # 简洁版日志 # 撤销工作区修改 $ git checkout -- <文件名> # 撤销暂存区文件 $ git reset HEAD <文件名> # 版本回退 $ git reset --hard <commit_id> # 彻底回退 $ git reset --soft <commit_id> # 保留修改 # 恢复删除的文件 $ git restore <文件名> # Git 2.23+ ``` #### 5. 标签管理 ```bash # 查看标签 $ git tag # 创建标签 $ git tag <标签名> # 轻量标签 $ git tag -a v1.0 -m "版本说明" # 附注标签 # 推送标签 $ git push origin <标签名> # 删除标签 $ git tag -d <标签名> # 本地删除 $ git push origin :refs/tags/<标签名> # 远程删除 ``` #### 6. 高级维护 ```bash # 清理历史大文件 $ git filter-branch --force --index-filter \ 'git rm -rf --cached --ignore-unmatch <文件名>' \ --prune-empty --tag-name-filter cat -- --all # 回收存储空间 $ git reflog expire --expire=now --all $ git gc --prune=now # 查看仓库大小 $ git count-objects -vH ``` #### 7. 配置相关 ```bash # 设置用户名/邮箱 $ git config --global user.name "用户名" $ git config --global user.email "邮箱" # 查看配置 $ git config --list # 设置默认编辑器 $ git config --global core.editor vim ``` > **最佳实践提示**: > 1. 频繁提交小变更,保持提交记录清晰 > 2. 使用`.gitignore`文件排除无需版本控制的文件 > 3. 重要分支(如main/prod)设置保护规则 > 4. 推送前先执行`git pull --rebase`避免合并提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值