我有一个超然的头在git。我对提交或保存任何更改不感兴趣,我只想转到我的分支的头部位置。我试过他的命令,但不起作用:
git checkout MyBranch
有什么帮助吗?
-更新
当我尝试结账时,我收到了这样的消息:
$ git checkout -f master
Switched to branch 'master'
Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.
-更新2它说这些是一些变化,我如何删除它们?
$ git merge o
我正在寻找一种方法来确保运行npm version的用户正在master分支上工作。
我的想法是使用npm preversion脚本,我只是不知道该放在哪里。
"scripts": {
"preversion": "exit with status code 0 only if `git rev-parse --abbrev-ref HEAD` is `master`"
}
理想的解决方案是跨平台的。用户都在Windows上,但是如果解决方案需要从git运行npm version才能变得更"linuxy",那是可以接受的。
这是我在GitHub操作文件中运行命令GitHub时所面临的问题。
Run npm ci
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/------
npm ERR!
npm ERR! Warning: Permanently added the RSA host key for IP address '140.82.113.4' to the list of known hosts.
npm ERR! git@github.com: Per
我一直在做我的项目,但在某个时候我发现有一件事停止了。当我的代码正常工作时,我需要查看它的状态,所以我决定使用git checkout (因为我想检查一些东西)。我就是这么做的
git checkout SHA
几次返回到我不能转到HEAD的点时,输出如下:
git checkout SHA-HEAD
error: Your local changes to the following files would be overwritten by checkout:
[list of files]
Please, commit your changes or stash them be
我千方百计地放弃了当地的变化。我不需要任何改变。我想抛弃一切。我试过:
git checkout .
git reset
git reset HARD
git clean -f
但无论我如何尝试,当我运行git状态时,我都会看到:
On branch release/3.12
Your branch is up-to-date with 'origin/release/3.12'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
pu
我有3台机器:
笔记本电脑、台式机、服务器
我使用的是两个分支: next和regroup。重组是原始的,我希望它成为新的下一个。
事件的时间线:
1. I finish the last changes to regroup on Desktop and push them to Server
2. I pull from server to laptop
3. On, laptop I checkout next (next happens to be 2 commits ahead of server/next)
// I want to take all the regroup
我希望能够运行一个命令来丢弃对一个特定文件的更改,不管它是未跟踪的还是修改的。
现在我运行git status,它给了我这样的东西:
$ git st
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
mo
我有一个git存储库。它有A,B,C,D,E。提交。现在,我想将D作为一个名为Dbranch的新分支签出。所以我执行:git checkout D -b Dbranch。现在我想删除这个分支。首先我需要切换到主分支,然后使用git branch -d Dbranch删除它。但是当我执行git checkout master时,它会给我错误。
error: The following untracked working tree files would be overwritten by checkout:
source/a/foo.c
...... (too many
一些脚本错误地从我用GIT跟踪的目录中删除了一些文件。我还没有提交这些更改。当我运行git status时,我看到几乎所有的100+文件都被删除了,并且显示为Changes not staged for commit,所以我甚至还没有运行git add。
什么是最好的方法来恢复所有这些文件,并回到我所在的地方。注意:我没有对此存储库进行任何其他更改。我通过运行git status看到的所有更改都是错误删除的文件。