Re: [git-users] Merging hotfix without merging all files.
On Wed, 26 Jun 2013 11:18:58 +0530 Shouvik cance...@gmail.com wrote: Yes, pass the --no-commit option to `git merge` and it won't automatically record a merge commit but will rather leave the changes staged in the index. Then you'll be able to unstage the changes made to index.php by running $ git reset index.php After that, commit as usually. [...] Ok so please confirm if the following steps are okay (assuming that currently I am in *bugfix* branch) No, one crucial step is missing -- see below. git commit -m major bug fixing register.php login.php index.php git checkout master git merge --no-commit bugfix Notice that here we explicitly told Git to *not* record a merge commit, just leave in the index (and the work tree) whatever changes the merge operation did to them. git reset index.php At this point run `git status`, `git diff --cached` and confirm for yourself you're okay with the changes about to be committed. This is a good habit you're really advised to develop -- do not ever commit blindly (unless you're absolutely sure). git push origin master Too early: you have not committed the changes introduced by the merge operation yet! Hence there's supposedly nothing to push. Now please scroll back to the quote from my original message above, which reads After that, commit as usually... Note that this case is really not rocket science. For some reason, you appear to perceive it as some sort of black magic which it really isn't: 1) Any merge operation which does not resolve in fast-forwarding the receiving branch, -- and this only ever happens if the branch being merged (the other side) completely contains the receiving branch in its history, so there's no point in attempting a true merge -- results in a new commit which a) records all the changes introduced by the merge, and b) refers to all the branches which participated in merging. 2) Since you want to tweak the result of the merge operation (drop the changes which it does to one file) you explicitly tell Git to not auto-commit the result. Consequently, you have to commit the (tweaked) state by hand. Please, don't try to *memorize* what to do, try hard to understand *what* each of the steps does, and why -- you have all the information. If you feel lost with what `git merge`, `git reset` and `git commit` do, it's time to read the book and study other pointers (like that article on `git reset` I linked to in my first reply to this thread). -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Merging hotfix without merging all files.
On Thu, Jun 20, 2013 at 7:52 PM, Dale R. Worley wor...@alum.mit.edu wrote: From: Konstantin Khomoutov flatw...@users.sourceforge.net Then after fixing the bug in 3 files (for eg index.php, register.php and login.php), i merge it in the master branch *git checkout master **git merge bugfix* The above code will merge all the 3 files i made changes, but is there anyway that i can force GIT to merge only 2 files, say login.php and register.php only? Yes, pass the --no-commit option to `git merge` and it won't automatically record a merge commit but will rather leave the changes staged in the index. Then you'll be able to unstage the changes made to index.php by running $ git reset index.php After that, commit as usually. My understanding is that one could also use this sequence: git checkout master git merge --no-commit bugfix and then selectively commit the changes one wanted to commit: git commit login.php register.php Am I correct? This would be somewhat easier to use if one wanted to then commit the remaining changes, as they would remain in the index for git commit Dale -- You received this message because you are subscribed to a topic in the Google Groups Git for human beings group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/git-users/kaQcM4I9ik0/unsubscribe. To unsubscribe from this group and all its topics, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. Ok so please confirm if the following steps are okay (assuming that currently I am in *bugfix* branch) git commit -m major bug fixing register.php login.php index.php git checkout master git merge --no-commit bugfix git reset index.php git push origin master Thanks -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Merging hotfix without merging all files.
On Wed, 19 Jun 2013 22:24:24 -0700 (PDT) Saurav cance...@gmail.com wrote: Suppose I have a project on MASTER branch with 100s of php files. To do a bug fixing in the project, i create a separate branch *git checkout -b bugfix* Then after fixing the bug in 3 files (for eg index.php, register.php and login.php), i merge it in the master branch *git checkout master **git merge bugfix* The above code will merge all the 3 files i made changes, but is there anyway that i can force GIT to merge only 2 files, say login.php and register.php only? Yes, pass the --no-commit option to `git merge` and it won't automatically record a merge commit but will rather leave the changes staged in the index. Then you'll be able to unstage the changes made to index.php by running $ git reset index.php After that, commit as usually. -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Merging hotfix without merging all files.
But u cannot switch branch without commiting first right? and in order or merge a branch u need to checkout to the master branch. no? Or am I missing something? Can u specify the steps pls? Thanks On Thu, Jun 20, 2013 at 5:29 PM, Konstantin Khomoutov flatw...@users.sourceforge.net wrote: On Wed, 19 Jun 2013 22:24:24 -0700 (PDT) Saurav cance...@gmail.com wrote: Suppose I have a project on MASTER branch with 100s of php files. To do a bug fixing in the project, i create a separate branch *git checkout -b bugfix* Then after fixing the bug in 3 files (for eg index.php, register.php and login.php), i merge it in the master branch *git checkout master **git merge bugfix* The above code will merge all the 3 files i made changes, but is there anyway that i can force GIT to merge only 2 files, say login.php and register.php only? Yes, pass the --no-commit option to `git merge` and it won't automatically record a merge commit but will rather leave the changes staged in the index. Then you'll be able to unstage the changes made to index.php by running $ git reset index.php After that, commit as usually. -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Merging hotfix without merging all files.
On Thu, 20 Jun 2013 17:35:54 +0530 Shouvik cance...@gmail.com wrote: Suppose I have a project on MASTER branch with 100s of php files. To do a bug fixing in the project, i create a separate branch *git checkout -b bugfix* Then after fixing the bug in 3 files (for eg index.php, register.php and login.php), i merge it in the master branch *git checkout master **git merge bugfix* The above code will merge all the 3 files i made changes, but is there anyway that i can force GIT to merge only 2 files, say login.php and register.php only? Yes, pass the --no-commit option to `git merge` and it won't automatically record a merge commit but will rather leave the changes staged in the index. Then you'll be able to unstage the changes made to index.php by running $ git reset index.php After that, commit as usually. But u cannot switch branch without commiting first right? and in order or merge a branch u need to checkout to the master branch. no? Of course, when you're merging, you first check out the branch which receives the merge (which will be the first parent of a prospective merge commit), and yes, you can only merge commits (not files or whatnot) since these are basic blocks of which repository history managed by Git consists. But what's the problem, really? If you recorded a bugfix commit (or a series of commits) on your bugfix branch, you just merge that branch into the (checked out) master branch. This is just a normal merge, you just prevent auto-creation of a merge commit and then rip out unwanted changes before actually making a commit. Or am I missing something? Can u specify the steps pls? No, you have to develop understanding of what you need to do and why, not just be able to copy paste a canned solution. P.S. Please don't top-post -- this breaks discussion flow. -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Merging hotfix without merging all files.
From: Konstantin Khomoutov flatw...@users.sourceforge.net Then after fixing the bug in 3 files (for eg index.php, register.php and login.php), i merge it in the master branch *git checkout master **git merge bugfix* The above code will merge all the 3 files i made changes, but is there anyway that i can force GIT to merge only 2 files, say login.php and register.php only? Yes, pass the --no-commit option to `git merge` and it won't automatically record a merge commit but will rather leave the changes staged in the index. Then you'll be able to unstage the changes made to index.php by running $ git reset index.php After that, commit as usually. My understanding is that one could also use this sequence: git checkout master git merge --no-commit bugfix and then selectively commit the changes one wanted to commit: git commit login.php register.php Am I correct? This would be somewhat easier to use if one wanted to then commit the remaining changes, as they would remain in the index for git commit Dale -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [git-users] Merging hotfix without merging all files.
On Thu, 20 Jun 2013 10:22:25 -0400 wor...@alum.mit.edu (Dale R. Worley) wrote: [...] Yes, pass the --no-commit option to `git merge` and it won't automatically record a merge commit but will rather leave the changes staged in the index. Then you'll be able to unstage the changes made to index.php by running $ git reset index.php After that, commit as usually. My understanding is that one could also use this sequence: git checkout master git merge --no-commit bugfix and then selectively commit the changes one wanted to commit: git commit login.php register.php Am I correct? Yes, I beleive you're correct on this point. This would be somewhat easier to use if one wanted to then commit the remaining changes, as they would remain in the index for git commit Well, this is about different mindsets ;-) Mine is that if we do not need a set of files, we drop changes in them from the index, and then commit. -- You received this message because you are subscribed to the Google Groups Git for human beings group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.