任何人都可以帮助避免 git 合并问题。我正在尝试将我的分支合并到另一个分支,比如另一个分支。由于 another_branch 是基础分支。所以要添加在 my_branch 中完成的工作,首先我要合并 my_branch。为此,我正在执行这些步骤。
git checkout another_branch
git pull anothr_branch
一旦我更新了 another_branch 的最新更改,我就会切换到 my_branch
git checkout my_branch
git merge anothr_branch
在做这一切之前,是的,我提交并暂存我的更改以将其保存在本地。所以毫无疑问会丢失我的任何更改。
但我没有看到 another_branch 的所有变化。所以我称之为覆盖。
可能是什么原因?
git push --force-with-lease origin +somebranch在当前的 Git 上, ,git push --force-with-lease origin somebranch和git push origin +somebranch(没有加号)之间有实质性区别吗?三个人似乎都在做同样的事情。
我试图寻找文档。我尝试查看文档中的refspec ,但我不知道是否存在差异,如果有的话,例如,当我想通过 拉到工作分支时git pull --rebase origin master,默认情况下应该更喜欢哪个。
这是我在重新设置当前分支同时保持本地分支不被压扁时通常会做的事情:
git fetch origin
git rebase -r origin/develop
Run Code Online (Sandbox Code Playgroud)
-r是--rebase-merges,我更喜欢--preserve-merges
我的问题是:有没有办法在做的时候通过这个git pull --rebase?
例如 - 我想像这样运行上面的命令的等价物:
git pull --rebase=rebasemerges origin develop
代替:
git pull --rebase=preserve origin develop
**编辑:好的 - 看起来像 2.22,--preserve-merges正在被弃用而支持--rebase-merges. 这是因为git rebase- 手指越过变化被延续到git pull --rebase
I have a local project which is also present as a git repository.
Recently, me and my colleague worked on two different changes on the project. He modified some files and pushed it on the remote repository. I made some changes which are present in my local repository and do not conflict with any of his changes on the remote repository.
我需要首先从远程存储库中获取他的更改,然后将我的更改与我刚刚到达远程存储库的更改一起推送。我该怎么做?
像 - git pull origin master 这样的东西会用远程存储库上的当前项目覆盖我的本地更改吗?
有没有办法合并这些提交?
我git pull --rebase --autostash一直在工作中使用(在 git bash 中,如果这很重要)。
但是由于某种原因,我的一些同事无法使用它,现在我发现它在家里不起作用。
在家里,我在 macbook 上使用 git 2.6.3。
错误信息很简单: error: unknown option `autostash'
有任何想法吗 ?
我有以下内容 .git/config
1 [core]
2 repositoryformatversion = 0
3 filemode = true
4 bare = false
5 logallrefupdates = true
6 [remote "origin"]
7 url = git@github.com:monajalal/instagram-scraper.git
8 fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)
当我尝试将更改推送到主服务器时,出现以下错误:
$ git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
我都尝试过这两个,但仍然会出错:
2150 git remote set-url origin https://github.com/monajalal/instagram-scraper.git
2154 git remote set-url origin git@github.com:monajalal/instagram-scraper.git
mona@pascal:~/computer_vision/instagram/instagram$ git log
commit e69644389a5c7be65ae6eae14d74065e221600cb
Author: …Run Code Online (Sandbox Code Playgroud) 以下问题Can “git pull” automatically stash and pop pending changes有使用两者的解决方案:
git pull --rebase --autostash
git pull --ff-only
我有点困惑我应该使用哪个。他们真的完成了相同的结果吗?提出了非常相似的问题,其中没有--autostash参数以及--rebase