git-merge

Git pull - Please move or remove them before you can merge

家住魔仙堡 提交于 2019-12-02 17:52:53
I am trying to do a git pull origin master from my server but keep getting the error: Please move or remove them before you can merge. There are no untracked files, but it seems like it has issues with the ignored files for some reason. I tried running a git clean -nd to see what would be deleted and it lists a whole bunch of files that are ignored in .gitignore . How can I fix this so I can do a pull? Apparently the files were added in remote repository, no matter what was the content of .gitignore file in the origin. As the files exist in the remote repository, git has to pull them to your

Git merge commits [duplicate]

扶醉桌前 提交于 2019-12-02 17:16:10
This question already has an answer here: Squash my last X commits together using Git 31 answers How to check if a string “StartsWith” another string? 18 answers I'm new to git (and enjoying it a lot!). While developing in a new branch, I kept committing the various development 'states' of my application. Now I have to check it in for review but didn't want everything to go in different commits (different comments and ids). How can I do a push of all changes as if it was the first time? git rebase -i HEAD~5 allows you to interactively select which of the 5 last commits to join into one; off

block push of trivial merge to git server

佐手、 提交于 2019-12-02 17:09:56
A while back I asked our developers to use rebase instead of merge before pushing . Eliminating trivial merges makes for a much easier to follow commit graph (ie: gitk, git log). Sometimes folks still accidentally do trivial merges, then push. Does anyone have handy or have tips for writing a server-side hook that blocks trivial merges? By "trivial merge", I mean a merge without conflicts. Here's an example , and here's a better explanation of a trivial merge in git . Update Wed Nov 10 01:26:41 UTC 2010 : great comments, all! Thank you. Consider the following: all I'm really asking folks to do

Git undo pushed merge and delete its history

怎甘沉沦 提交于 2019-12-02 17:04:19
问题 I made an accidental merge to master and pushed it, now master has all the commits from dev. I want to revert the commits from master and delete its history without changing dev. How can I do that? 回答1: The last commit can be removed with: git reset --hard HEAD^ . Sometimes there might be situations, when you need to remove a commit from the "middle" of branch. Here comes to the rescue interactive rebase: git rebase -i <commit>^ . You just need to drop an unwanted commit (it should appear at

Abort a Git Merge

余生颓废 提交于 2019-12-02 16:55:16
I am working on a project using Git as the VCS. I got a branch xyz cut from the mainline branch of master. After working for a while, I committed my code and took a pull of the branch mainline. The pull was fine. I then merged the code with master. After the merge, there were problems in certain files. I have not committed the code after merging. Can someone please guide as to how I can abort this merge and bring my branch where I am working currently to the state where it was before I merged it? as long as you did not commit you can type git merge --abort just as the command line suggested.

what does git merge origin/master do?

和自甴很熟 提交于 2019-12-02 16:42:38
After fetching from remote using git fetch , we need to use something like git merge origin/master I would like to know if this command also does git commit at the same time? Is the order origin/master important? Can I write master/original ? git merge origin/master can do one of two things (or error). In the first case, it creates a new commit that has two parents: the current HEAD , and the commit pointed to by the ref origin/master (unless you're doing something funny, this is likely to be (the local pointer to) the branch named master on a remote named origin , though this is completely

Resolve merge conflicts: Force overwrite all files

丶灬走出姿态 提交于 2019-12-02 15:29:54
I am working on a git repository by myself (so yes, I know the implications and the warnings of doing this) and somehow one of the trees got a commit after being pushed when it shouldn't have. Now I'm trying to pull back and it's complaining about hundreds of merge conflicts. Is there a way to tell git to forcefully overwrite any and all files locally that are coming from the remote server? Is there a faster way than doing git reset --hard HEAD~1 and then doing the pull? On that same note, is there a way to do the same with with a simple merge? Everything I've seen suggests to check out each

How to make git merge handle uncommitted changes to my working tree?

谁说我不能喝 提交于 2019-12-02 15:24:37
A co-worker and I are both working on the master branch at the moment. I have some code in my working tree that I don't want to commit (debugging statements and the like). Now if he commits changes to some of those same files, I can't merge them: $ git merge origin/master Updating 1b8c5c6..eb44c23 error: Entry 'blah.java' not uptodate. Cannot merge. Coming from a subversion background, I'm used to having my working tree automatically merged when I pull changes from the repository and if there are conflicts, I resolve them manually. The quickest way I have found to do this in git is: $ git

How to merge all files manually in Git?

♀尐吖头ヾ 提交于 2019-12-02 14:48:55
I want to merge all files manually with meld or any other diff tool, how can I do this with Git? When I run git mergetool it says no files need merging . So I suppose I can do it only if I have conflicts. There is much simpler way: git merge --no-commit merge_branch As man says: With --no-commit perform the merge but pretend the merge failed and do not autocommit, to give the user a chance to inspect and further tweak the merge result before committing. I had a scenario where: git merge --no-commit merge_branch just caused a Fast Forward. If this happens you can use: git merge --no-commit --no

How does git merge after cherry-pick work?

你说的曾经没有我的故事 提交于 2019-12-02 14:13:01
Let's imagine that we have a master branch. Then we create a newbranch git checkout -b newbranch and make two new commits to newbranch : commit1 and commit2 Then we switch to master and make cherry-pick git checkout master git cherry-pick hash_of_commit1 Looking into gitk we see that commit1 and its cherry-picked version have different hashes, so technically they are two different commits. Finally we merge newbranch into master : git merge newbranch and see that these two commits with different hashes were merged without problems although they imply that the same changes should be applied