[git-users] Ignoring files
Hello!! I have a (newbie) problem with GIT. I want to have two branches in a project, one for development and one for production and I want to push everything in Dev and then, if everything is ok, merge them to Prod. But there is some files that always will be different in dev and in prod, so I want to push them in each branch and never merge them... how I can do that? I try with gitignore file but it doesn't work if i have the files in the repository Thanks! Silvai -- 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] files case name changes detection.
thanks a lot Konstantin for the detailed answer. great help indeed. I was well aware of the similarity index of git diff and planned to use it. however, your global view of the issue made it much clearer for me. I do think I will need to go through all the commits in between since when applied during a pull, it is done one by one so in between commits with a rename like that can still confuse windows clients. regarding a change+rename you mentioned - if you declare you are looking for 100% in the similarity index + the rename flag from git - so we are covered, as you said. On Wednesday, November 13, 2013 2:31:25 PM UTC+2, Konstantin Khomoutov wrote: On Tue, 12 Nov 2013 08:11:40 -0800 (PST) Gabby Romano omer...@gmail.com javascript: wrote: I would like to be able to prevent case name changes done on windows clients and being pushed to our linux remote repository. when pulled, it confuses the other windows clients and messes things up. I want to use a hook for that along with the rename detection mechanism of git, if I can call it this way. my question is - what would be the best way to approach this in the hook ? detect the rename and check the content is the same (sha1 check ? ) am I wrong regarding the approach in general and there is a much better way to do this ? I think it's a viable approach though it should be used somewhat differently to what you proposed. Git does not explicitly track file renames so renaming a file (without changing the file's contents) physically looks like a (new) commit indirectly referencing *the same* blob of data as does one of its parent commits, but this blob has a different symbolic name attached to it in one of the tree objects referenced by both commits. In Git, each commit references exactly one tree object (representing the root directory of the project), and that tree object might reference zero or more other tree objects -- one for each top-level subdirectory, and so on and so on going deeper down. Tree objects also reference blobs which contain the data of tracked files. In a tree object, both references to blobs and to other tree objects are decorated with filesystem names for these objects. That's how filesystem hierarchies are mapped to Git objects in its database. As you can see, renames can only be detected by analyzing a part of the commit graph using special algorythms. Fortunately, Git has this machinery implemented for you in its `git diff` command: git diff --name-status --diff-filter=R --find-renames A B should present you with a list or files (along with the Rnnn marker in front of them) which were renamed in commit B compared to commit A. R means Git detected the file has been renamed, and nnn shows you the persentage of the file's contents which remained unchanged (the similarity index; 100% means the file's content hasn't changed). Applying this paradigm in a post-receive hook *might* be more involved since any push operation might update any ref (a branch or a tag) with more than one commit at once -- in a general case with a graph of commits. If you're fine with merely making sure the new tip commit does not introduce any rename compared to the old one, ignoring anything which might have happened in between, just use `git diff` as shown above. If, instead, you want to be sure no commit between A and B introduced a rename, you should employ the fact the command for walking commit graphs, `git log`, is able to use `git diff` machinery for analyzing the commits as it walks. Hence, if we have a ref that is currently pointing to a commit A, and it's about to be updated by the push operation to point to a commit B, we could call git log --oneline --name-status --diff-filter=R --find-renames A..B to list all commits sent to update our ref, which contain renames. Notice that `git diff` is passed the two revisions as a separate arguments, and `git log` receives the rule A..B which means all commits reachable from B excluding all commits reachable from A. I should stress again that there are no renames in Git -- in this VCS this concept is purely synthetic, and so there are knobs to control the algorythm which detects renames. At least you can specify which persentage of the file contents must be *not* changed in a commit to count as a rename. The rationale: in a given commit, a file might be both changed and renamed, and since their contents differ, how do you tell if it's still logically the same file or not? You might tell Git your idea about this -- read the `git diff` manual page about the --find-renames (-M) command-line option. -- 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
[git-users] Sync repository remote with local after git reset
Hi, I'm necessity rollback 2 commits, I try: git reset --hard HEAD~2 Now, how can I synchronize with my remote repository? -- 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] Sync repository remote with local after git reset
On Thu, 14 Nov 2013 03:44:56 -0800 (PST) Diogo Machado di...@diogomachado.com wrote: Hi, I'm necessity rollback 2 commits, I try: git reset --hard HEAD~2 Now, how can I synchronize with my remote repository? Depends on how do you specify synchronize. Do you want to send the updated contents of your local branch to update (overwrite) some branch in a remote repository? If yes, do git push -f remote localbranch:remotebranch or git push remote +localbranch:remotebranch or just one of git push -f remote localbranch git push remote +localbranch if the name to update/overwrite in the remote repository is the same as in the local one. The idea is that the -f command-line option (--force is its full name) forces updating. A + sign before the so-called refspec -- the specification of what to update with what means the same thing: to force the update. Forcing is needed because by default Git forbirds updating a branch with the history if the new history does not wholly contain the old one. In case you chopped off a number of commits falls into the same class of scenario: the new history graph is not a strict superset of the old one. -- 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] Sync repository remote with local after git reset
Thank brother! Em quinta-feira, 14 de novembro de 2013 10h22min41s UTC-2, Konstantin Khomoutov escreveu: On Thu, 14 Nov 2013 03:44:56 -0800 (PST) Diogo Machado di...@diogomachado.com javascript: wrote: Hi, I'm necessity rollback 2 commits, I try: git reset --hard HEAD~2 Now, how can I synchronize with my remote repository? Depends on how do you specify synchronize. Do you want to send the updated contents of your local branch to update (overwrite) some branch in a remote repository? If yes, do git push -f remote localbranch:remotebranch or git push remote +localbranch:remotebranch or just one of git push -f remote localbranch git push remote +localbranch if the name to update/overwrite in the remote repository is the same as in the local one. The idea is that the -f command-line option (--force is its full name) forces updating. A + sign before the so-called refspec -- the specification of what to update with what means the same thing: to force the update. Forcing is needed because by default Git forbirds updating a branch with the history if the new history does not wholly contain the old one. In case you chopped off a number of commits falls into the same class of scenario: the new history graph is not a strict superset of the old one. -- 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.
[git-users] Re: .gitignore question
Thanks for the reply. Unfortunately it is not that simple. There are other directories named 'cache' that are not in 'system' that need to be tracked. -- 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] Question on Git Hooks
On Wed, 13 Nov 2013 12:00:00 -0500 lingfei ouyang oylf1...@gmail.com wrote: and one more quick question? What is the correct way for define the variable in pre-commit hooks in Git bash so I can using those three variables to run git commands, i.e. git show $newrev git merge-base $oldreve $newrev since what I tried in my bash scripts first to define: refname=$1 oldrev=$2 newrev=$3 but when I run check if those three variables are valid first and it doesn't return any value. Your question has little sense as is: to define a variable in bash (and in any other POSIX shell) yo do variable=value to assign value to a variable named variable (possibly creating it). Hence a dumb answer is that you're doing assignments right. On the other hand, I'm not so sure about these $1, $2 and $3: in a POSIX shell, $1 expands to the value of the first so-called positional parameter, $2 to the value of the second positional parameter and so on. Positional parameters are arguments passed to the shell process on its command line, for instance, if you call $ ./myscript.sh foo bar baz $1 inside myscript.sh would expand to foo, $2 to bar etc. The problem is that by (stupid) default it's not an error in a POSIX shell to attempt to expand a parameter which does not exist. I mean, if you have a script myscript.sh reading #!/bin/bash foo=$1 echo $foo and run it without any arguments, like just $ ./myscript.sh it will execute successfully and print nothing (a newline, actually). The reason: there was no first positional parameter, so $1 expanded to an empty string instead of erroring out and so the variable foo has been assigned an empty string which echo printed. What I'm leading you to is just supposedly what you're observing is your hook not receiving any arguments and hence it has no positional parameters set. Which leads us to the next question: did you read the githooks(5) manual page to read up on how exactly Git communicates its information to your kind of hook? Or is there any such information at all? I know the answer but I want you to start thinking and doing some active research. -- 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] Question on Git Hooks
Thanks a lot Konstantin for the information, will doing research on this. On Thu, Nov 14, 2013 at 8:03 AM, Konstantin Khomoutov flatw...@users.sourceforge.net wrote: On Wed, 13 Nov 2013 12:00:00 -0500 lingfei ouyang oylf1...@gmail.com wrote: and one more quick question? What is the correct way for define the variable in pre-commit hooks in Git bash so I can using those three variables to run git commands, i.e. git show $newrev git merge-base $oldreve $newrev since what I tried in my bash scripts first to define: refname=$1 oldrev=$2 newrev=$3 but when I run check if those three variables are valid first and it doesn't return any value. Your question has little sense as is: to define a variable in bash (and in any other POSIX shell) yo do variable=value to assign value to a variable named variable (possibly creating it). Hence a dumb answer is that you're doing assignments right. On the other hand, I'm not so sure about these $1, $2 and $3: in a POSIX shell, $1 expands to the value of the first so-called positional parameter, $2 to the value of the second positional parameter and so on. Positional parameters are arguments passed to the shell process on its command line, for instance, if you call $ ./myscript.sh foo bar baz $1 inside myscript.sh would expand to foo, $2 to bar etc. The problem is that by (stupid) default it's not an error in a POSIX shell to attempt to expand a parameter which does not exist. I mean, if you have a script myscript.sh reading #!/bin/bash foo=$1 echo $foo and run it without any arguments, like just $ ./myscript.sh it will execute successfully and print nothing (a newline, actually). The reason: there was no first positional parameter, so $1 expanded to an empty string instead of erroring out and so the variable foo has been assigned an empty string which echo printed. What I'm leading you to is just supposedly what you're observing is your hook not receiving any arguments and hence it has no positional parameters set. Which leads us to the next question: did you read the githooks(5) manual page to read up on how exactly Git communicates its information to your kind of hook? Or is there any such information at all? I know the answer but I want you to start thinking and doing some active research. -- 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] Question on Git Hooks
On Thu, 14 Nov 2013 08:18:56 -0500 lingfei ouyang oylf1...@gmail.com wrote: [...] The problem is that by (stupid) default it's not an error in a POSIX shell to attempt to expand a parameter which does not exist. I mean, if you have a script myscript.sh reading [...] Thanks a lot Konstantin for the information, will doing research on this. Note that you can make the shell die on trying to expand a nonexisting variable by changing its error mode by executing the set -u builtin command. I'd also recommend to insert set -e -u in your scripts to make the shell also die upon executing commands that fail instead of chugging away happily. Shell programming with these settings active requires certain discipline but it's actually a good thing and helps debugging errors like the yours. -- 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] files case name changes detection.
On Thu, 14 Nov 2013 02:37:20 -0800 (PST) Gabby Romano omerik...@gmail.com wrote: [...] regarding a change+rename you mentioned - if you declare you are looking for 100% in the similarity index + the rename flag from git - so we are covered, as you said. Really? Not so fast, please. ;-) Looking for R100 markers or passing -M100 to `git diff`/`git log` means you're looking for files which were just renamed, with their contents unchanged. But what if I change a single letter in a file *and* rename it in the same commit? Its similarity index will be close to 100%, but still lower, and so this rename will pass undetected. I meant to underline (but seems like I failed at it) that what constitutes a rename is a rather philosophical question in Git as merely *using* `git mv` does not *record* a rename using some imaginary metadata (as could be the case in other VCSes). Look at it this way: while comparing two commits Git sees two identical blobs with their filesystem names changed -- okay, that's surely a rename. Now it sees two blobs with similarity index of, say, 50% and different names -- is this a rename? That could be just a file split into two (or three or more) other files or parts of the code contained in the original file moved to other existing files. Since no explicit renames are recorded, Git does not know by itself what it really is. I would recommend to thoroughly read this post [1] to really understand the Git's approach to this and its implications. So *to me,* using -M100 may pass certain renames undetected. I would possibly use something like 80%... I don't know. You decide. 1. http://thread.gmane.org/gmane.comp.version-control.git/27/focus=217 -- 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] .gitignore question
From: wtriker@gmail.com I have some files that I want to ignore but can't seem to come up with the correct format. There are multiple sub-directories with the same path that I want to ignore. Specifically, the are 'someupper path/system/cache' and all start with 'cache.'. The .gitignore entry I am using is: system/cache/cache.* But that does not work. What is the correct syntax to ignore these files? One solution is to put cache in each someupper path/system/.gitignore file. I would start by reading the rules for how gitignore entries are interpreted, which is in the gitignore manual page. In particular, I see: Two consecutive asterisks (**) in patterns matched against full pathname may have special meaning: · A leading ** followed by a slash means match in all directories. For example, **/foo matches file or directory foo anywhere, the same as pattern foo. **/foo/bar matches file or directory bar anywhere that is directly under directory foo. This suggests the answer is to put **/system/cache in the top-level .gitignore file. 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.
[git-users] After git -am commit changed files are not in repo
I have a git repository cloned to an AWS server. But my commits are not showing up in the repository even though there is no error when I commit a file. Is it OK to make commits as root or do I need to login with a git user name ? root@ip-xxx-xx-x-xxx:/var/www/myproject# git config --global user.name 'me' root@ip-xxx-xx-x-xxx:/var/www/myproject# git config --global user.email 'm...@my.com' root@ip-xxx-xx-x-xxx:/var/www/myproject# git commit -am 'test2commit' [master b506b96] test2commit 1 files changed, 0 insertions(+), 215 deletions(-) delete mode 100644 myproject#/protected/runtime/application.log root@ip-xxx-xx-x-xxx:/var/www/myproject# git log commit b506b96c093c9ee9ec8f940ceb7964171b4827f5 Author: me m...@my.com Date: Fri Nov 15 03:09:52 2013 + test2commit root@ip-1xxx-xx-x-xxx:/var/www/myproject# git status -s root@ip-xxx-xx-x-xxx:/var/www/myproject# -- 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] After git -am commit changed files are not in repo
On Nov 14, 2013 7:53 PM, Dave Kennedy davek1...@gmail.com wrote: I have a git repository cloned to an AWS server. But my commits are not showing up in the repository even though there is no error when I commit a file. Is it OK to make commits as root or do I need to login with a git user name ? root@ip-xxx-xx-x-xxx:/var/www/myproject# git config --global user.name'me' root@ip-xxx-xx-x-xxx:/var/www/myproject# git config --global user.email ' m...@my.com' root@ip-xxx-xx-x-xxx:/var/www/myproject# git commit -am 'test2commit' [master b506b96] test2commit 1 files changed, 0 insertions(+), 215 deletions(-) delete mode 100644 myproject#/protected/runtime/application.log root@ip-xxx-xx-x-xxx:/var/www/myproject# git log commit b506b96c093c9ee9ec8f940ceb7964171b4827f5 Author: me m...@my.com Date: Fri Nov 15 03:09:52 2013 + test2commit root@ip-1xxx-xx-x-xxx:/var/www/myproject# git status -s root@ip-xxx-xx-x-xxx:/var/www/myproject# I must be missing something. You made a commit, then you ran git log and it showed you that your commit was made. Everything's fine, right? -- 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] After git -am commit changed files are not in repo
No the 'deleted' file, application.log, is still in the repo and the other commits I made are not showing up in the repo. I can't understand where the committed files went? On Thursday, November 14, 2013 8:28:22 PM UTC-8, Peter J Weisberg wrote: On Nov 14, 2013 7:53 PM, Dave Kennedy dave...@gmail.com javascript: wrote: I have a git repository cloned to an AWS server. But my commits are not showing up in the repository even though there is no error when I commit a file. Is it OK to make commits as root or do I need to login with a git user name ? root@ip-xxx-xx-x-xxx:/var/www/myproject# git config --global user.name'me' root@ip-xxx-xx-x-xxx:/var/www/myproject# git config --global user.email ' m...@my.com javascript:' root@ip-xxx-xx-x-xxx:/var/www/myproject# git commit -am 'test2commit' [master b506b96] test2commit 1 files changed, 0 insertions(+), 215 deletions(-) delete mode 100644 myproject#/protected/runtime/application.log root@ip-xxx-xx-x-xxx:/var/www/myproject# git log commit b506b96c093c9ee9ec8f940ceb7964171b4827f5 Author: me m...@my.com javascript: Date: Fri Nov 15 03:09:52 2013 + test2commit root@ip-1xxx-xx-x-xxx:/var/www/myproject# git status -s root@ip-xxx-xx-x-xxx:/var/www/myproject# I must be missing something. You made a commit, then you ran git log and it showed you that your commit was made. Everything's fine, right? -- 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] After git -am commit changed files are not in repo
Without the -s 'git status' returns 'Your branch is ahead of 'origin/master' by 1 commit. root@ip-xxx-xx-x-xxx:/var/www/myprojecgt# git status # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # nothing to commit (working directory clean) On Thu, Nov 14, 2013 at 9:30 PM, Dave Kennedy davek1...@gmail.com wrote: No the 'deleted' file, application.log, is still in the repo and the other commits I made are not showing up in the repo. I can't understand where the committed files went? On Thursday, November 14, 2013 8:28:22 PM UTC-8, Peter J Weisberg wrote: On Nov 14, 2013 7:53 PM, Dave Kennedy dave...@gmail.com wrote: I have a git repository cloned to an AWS server. But my commits are not showing up in the repository even though there is no error when I commit a file. Is it OK to make commits as root or do I need to login with a git user name ? root@ip-xxx-xx-x-xxx:/var/www/myproject# git config --global user.name'me' root@ip-xxx-xx-x-xxx:/var/www/myproject# git config --global user.email 'm...@my.com' root@ip-xxx-xx-x-xxx:/var/www/myproject# git commit -am 'test2commit' [master b506b96] test2commit 1 files changed, 0 insertions(+), 215 deletions(-) delete mode 100644 myproject#/protected/runtime/application.log root@ip-xxx-xx-x-xxx:/var/www/myproject# git log commit b506b96c093c9ee9ec8f940ceb7964171b4827f5 Author: me m...@my.com Date: Fri Nov 15 03:09:52 2013 + test2commit root@ip-1xxx-xx-x-xxx:/var/www/myproject# git status -s root@ip-xxx-xx-x-xxx:/var/www/myproject# I must be missing something. You made a commit, then you ran git log and it showed you that your commit was made. Everything's fine, right? -- 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/1DG_7n_YOWA/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. -- 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] After git -am commit changed files are not in repo
I ran the following commands but still get the 'Your branch is ahead…' 1. git reset --hard origin/master 2. git pull Already up-to-date. 3. git status # On branch master # Changed but not updated: # (use git add/rm file... to update what will be committed) # (use git checkout -- file... to discard changes in working directory) # # deleted:myproject/protected/runtime/application.log # 4. git commit -am 'message' 5. git status # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # nothing to commit (working directory clean) -- 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.