git 配置
git config --global user.name "xiaowang"
git config --global user.email "xiaowang@emial.com"
ssh-keygen -t rsa -C "xiaowang@emial.com"
cat ~/.ssh/id_rsa.pub
删除本地某个分支
git branch -d <branch name>
git branch -D <branch name>(强制删除)
删除远端某个分支
git push origin --delete <branch_name>
断开本地仓库和远端仓库的联系
git remote rm origin
建立远端仓库和本地仓库的联系git branch -d <branch name>
git branch -D <branch name>(强制删除)
git remote add origin <your_new_repository_url>
列出远端详细信息
git remote -v
基于远端的某个分支新创建一个分支
git checkout -b wyg_add_idc remotes/origin/openEuler-22.03-LTS-SP1-mt
推送本地新分支到远端
git push origin {local_branch}:{remote_new_name}
拿到某次提交的改动并且修改提交人的信息
git cherry-pick d2c6855e12d
git commit --amend --author="xiaowang <xiaowang@email.com>"
提交的时候指定作者
git commit --author="wangyigen <xiaowang@email.com>"
查看最新一次的修改内容
git show
远端回退到 c7b0f649ecb(某次commitid)版本
git reset --hard c7b0f649ecb
git push origin <branch-name> --force
查看暂存区的更改
git diff --cached
如果你想从暂存区中删除某个特定的文件,可以使用 git reset HEAD <file> 命令:
git reset HEAD <file>
对某次commit打tag
git tag {tagName} 10040e3239db
某次tag push到远端
git push origin {tagName}:refs/tags/{tagName}
删除本地tag
git tag --delete {tagName}
删除远端tag
git push --delete origin {tagName}
撤销某次提交
git revert commitId
添加远端仓库
git remote add {remote_name} {remote_URL}
拿到某次提交
git cherry-pick {commitID}
修改最后一次提交
git add 修改文件
git commit --amend
git push <origin> <your-branch-name> --force
生成patch
git format-patch -1 {commit_ID}