How to Git Reset and push to the remote branch

If I have already push my code to a remote branch, how to reset it into the previous version?

Firstly, Git Reset your local branch. I use IDEA’s Git Reset function, Hard mode.
在这里插入图片描述

Then, use git bash tool to putin “git push --force”. Check the local branch name before entering the command statements.

DONE

root@jw:~/Desktop/jwstf66framework# git remote add origin git@gitee.com:A265386614/automated_test.git root@jw:~/Desktop/jwstf66framework# git remote ls error: Unknown subcommand: ls usage: git remote [-v | --verbose] or: git remote add [-t <branch>] [-m <master>] [-f] [--tags | --no-tags] [--mirror=<fetch|push>] <name> <url> or: git remote rename <old> <new> or: git remote remove <name> or: git remote set-head <name> (-a | --auto | -d | --delete | <branch>) or: git remote [-v | --verbose] show [-n] <name> or: git remote prune [-n | --dry-run] <name> or: git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)...] or: git remote set-branches [--add] <name> <branch>... or: git remote get-url [--push] [--all] <name> or: git remote set-url [--push] <name> <newurl> [<oldurl>] or: git remote set-url --add <name> <newurl> or: git remote set-url --delete <name> <url> -v, --verbose be verbose; must be placed before a subcommand root@jw:~/Desktop/jwstf66framework# clear root@jw:~/Desktop/jwstf66framework# git remote -v origin git@gitee.com:A265386614/automated_test.git (fetch) origin git@gitee.com:A265386614/automated_test.git (push) root@jw:~/Desktop/jwstf66framework# git remote add origin git@gitee.com:A265386614/automated_test.git fatal: remote origin already exists. root@jw:~/Desktop/jwstf66framework# git push origin master error: src refspec master does not match any. error: failed to push some refs to 'git@gitee.com:A265386614/automated_test.git' root@jw:~/Desktop/jwstf66framework# git push origin master error: src refspec master does not match any. error: failed to push some refs to 'git@gitee.com:A265386614/automated_test.git' root@jw:~/Desktop/jwstf66framework# git checkout -b master Switched to a new branch 'master' root@jw:~/Desktop/jwstf66framework# root@jw:~/Desktop/jwstf66framework# git push origin master error: src refspec master does not match any. error: failed to push some refs to 'git@gitee.com:A265386614/automated_test.git' root@jw:~/Desktop/jwstf66framework# git checkout -b master Switched to a new branch 'master' root@jw:~/Desktop/jwstf66framework# git add . warning: adding embedded git repository: automated_test hint: You've added another git repository inside your current repository. hint: Clones of the outer repository will not contain the contents of hint: the embedded repository and will not know how to obtain it. hint: If you meant to add a submodule, use: hint: hint: git submodule add <url> automated_test hint: hint: If you added this path by mistake, you can remove it from the hint: index with: hint: hint: git rm --cached automated_test hint: hint: See "git help submodule" for more information. root@jw:~/Desktop/jwstf66framework# root@jw:~/Desktop/jwstf66framework# git commit -m "Initial commit" *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got 'root@jw.(none)') root@jw:~/Desktop/jwstf66framework# root@jw:~/Desktop/jwstf66framework# git push origin master error: src refspec master does not match any. error: failed to push some refs to 'git@gitee.com:A265386614/automated_test.git' root@jw:~/Desktop/jwstf66framework# git checkout -b main Switched to a new branch 'main' root@jw:~/Desktop/jwstf66framework# root@jw:~/Desktop/jwstf66framework# git add . root@jw:~/Desktop/jwstf66framework# root@jw:~/Desktop/jwstf66framework# git commit -m "Initial commit" *** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: unable to auto-detect email address (got 'root@jw.(none)') root@jw:~/Desktop/jwstf66framework# root@jw:~/Desktop/jwstf66framework# git push -u origin main error: src refspec main does not match any. error: failed to push some refs to 'git@gitee.com:A265386614/automated_test.git' root@jw:~/Desktop/jwstf66framework# root@jw:~/Desktop/jwstf66framework# root@jw:~/Desktop/jwstf66framework# root@jw:~/Desktop/jwstf66framework# git remove -v git: 'remove' is not a git command. See 'git --help'. The most similar command is remote root@jw:~/Desktop/jwstf66framework# git remote -v origin git@gitee.com:A265386614/automated_test.git (fetch) origin git@gitee.com:A265386614/automated_test.git (push) root@jw:~/Desktop/jwstf66framework#
11-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值