我们的远程主分支不知怎的搞砸了.当前开发代码与最新提交一起在主分支上.显然,开发代码还没有为主分支做好准备.
所以在我的本地存储库中,我重置了最新的标记,git reset --hard (Tag).现在主分支在我的本地存储库上是正确的.现在,当我尝试将更改推送到远程存储库时git push origin master,我收到一个错误:
To (REMOTE GIT REPOSITORY LOCATION)
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '(REMOTE GIT REPOSITORY LOCATION)'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
所以环顾四周之后,我发现了这个--force选项.所以我强行推进了远程存储库,git push --force origin master我仍然遇到错误:
Total 0 (delta 0), reused …Run Code Online (Sandbox Code Playgroud) 我做了什么:
我认为github gui中有一些奇怪的配置导致了这个问题并阻止我从命令行甚至git-bash轻松使用git.
我最后只是卸载github和git然后重新安装git for windows.我现在让一切都在命令行上运行(除了我从git-bash运行的ssh).github gui更容易,更可靠.
感谢mu无论花时间试图弄明白这一点.我最终没有使用他的答案,但如果我不需要重新安装git,那将是我需要做的.
我在我的本地机器上使用github gui.我只是注意到我要做的提交是要更新我最近更新的所有节点模块.我设置我的.gitignore忽略整个node_modules/目录.
我不知道该怎么做.我在.gitignore中包含的所有文件类型都被忽略了.它只是它似乎忽略的目录.
这是我的.gitignore文件:
#################
## Sublime Text
#################
*.sublime-project
*.sublime-workspace
#################
## Images
#################
*.jpg
*.jpeg
*.png
*.gif
*.psd
*.ai
#################
## Windows detritus
#################
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mac crap
.DS_Store
#################
## Directories
#################
dev/
cms/core/config/
node_modules/
Run Code Online (Sandbox Code Playgroud) 今天我部署了firebase托管.部署之后,我注意到firebase创建了文件.firebase/hosting.ALPHANUM.cache,其中ALPHANUM实际上是一些随机baseNN ish值.
.gitignore吗?
我有一个分支(让我们称之为B)忽略某个文件,在某些其他分支(例如分支A)中不会忽略该文件.当我从分支B切换到分支A,然后再次返回到B时,该文件已被删除.
这是正常的吗?我可以看到它会如何发生,在分支B认为它不存在的意义上,分支A认为它是,所以当我回到B时它"整理它".但它有点烦人.
有什么建议?
我尝试从git存储库中删除不必要的文件.最初添加了这些文件,现在它们位于多个分支中.我想要的只是停止跟踪该文件中的更改,我不关心应该保留哪些更改,但我需要将这些文件留在文件系统上.
我试过跟随
git filter-branch --index-filter "git rm --cached --ignore-unmatch file_to_remove" HEAD
Run Code Online (Sandbox Code Playgroud)
但是从文件系统中删除了不需要的文件.
我们的项目已经使用git一个星期左右了,而且我们都非常享受它(在紧密的协作组中,它变成了一个完全不同的git体验).为了使事情尽可能简单,我们不会进行任何变基或历史修改.但我们确实在第一周犯了一些错误.做了一些不应该做的提交,我们设法将一个功能分支合并到错误的集成分支(1.1而不是1.0).在他们长期进入我们的历史之前,我们没有发现这些事情.
现在我看到很多关于重写历史的警告,但我不确定我是否理解所涉及的危险.我们使用共享的裸存储库,并将所有分支推送到那里进行备份.
我希望如果你重写历史记录(比如删除一个提交),后续提交的完整列表将"丢失"该提交(并且可能不会编译/工作).我也希望如果发生这种情况,我实际上可以选择在历史的顶部解决这个问题(并将这部分历史留作非编译).
任何关于这个主题的文章/教程的参考也会非常好.
我是一些新的应用程序与离子和非常新的存储库的主题,当我做提交无限的文件上传,我发现很难确定项目的变化,这就是为什么我想要求帮助在这里,如果我可以指导你忽略文件,如果一个文件默认存在占用和在哪里,因为大多数工作是在www文件夹中完成的.对不起,如果问题非常基本,但我会很快解决这个问题.
我试图在文件中忽略 3 个路径.gitignore:
aws_scripts/python/aws_tools/__pycache__/
.vscode/
aws_scripts/output_files/
aws_scripts/source_files/
Run Code Online (Sandbox Code Playgroud)
除了aws_scripts/python/aws_tools/__pycache__/
git status
On branch develop
Your branch is up to date with 'origin/develop'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: aws_scripts/python/aws_tools/__pycache__/ec2_mongo.cpython-39.pyc
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
如果我注释掉 中的行.gitignore …
我有一个大项目(让我们说A repo),它有一个来自的子文件夹B repo.当我承诺时,我会像下面那样遇到警告A repo
warning: adding embedded git repository: extractor/annotator-server
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> extractor/annotator-server
hint:
hint: If you added this path by mistake, you can remove it from the …Run Code Online (Sandbox Code Playgroud)