messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Best practices for using git with CVS\nWhat are your best practices and tips for using git to interface with a CVS repository?"
},
{
"role": "assistant",
"content": "I wrote up an answer to a similar question here.\nThis works suprisingly well when you're forced to continue to push changes into a central CVS repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Difference between different GitLab CI Merge Request rules\n\nAs several other users, I'm facing issues with duplicate pipelines in GitLab CI/CD. While there is some documentation on how to prevent this scattered around in the GitLab docs,\nmy impression is that the indivdual docs pages and sections are rather inconsistent.\nMy question is, what are the differences between the following rules? Or, more specifically, are there cases in which these rules are evaluated differently?\n\nSwitch between branch pipelines and merge request pipelines suggest this to identify merge request pipelines:\nif: '$CI_PIPELINE_SOURCE == \"merge_request_event\"'\n\n\nAdditionally, Switch between branch pipelines and merge request pipelines also uses this rule in combination with $CI_COMMIT_BRANCH &&:\nif: '$CI_OPEN_MERGE_REQUESTS'\n\n\nMoreover, the MergeRequest-Pipelines.gitlab-ci.yml uses a third rule:\nif: $CI_MERGE_REQUEST_IID\n\n\n\nAny explanation or hints to docs pages I might have overlooked is highly appreciated."
},
{
"role": "assistant",
"content": "In order to avoid duplicate pipeline creation and the requirement that you want to switch between Branch-Pipelines and Merge-Request-Pipelines I recommend using these workflow rules\nworkflow:\n rules:\n - if: '$CI_PIPELINE_SOURCE == \"merge_request_event\"'\n - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'\n when: never\n - if: '$CI_COMMIT_BRANCH' || '$CI_COMMIT_TAG'\n\nThere is another SO-question that asks how to prevent duplicate pipelines here\nThe Explanation(s):\nIn the following section I will try to explain your different rules and how GitLab CI will evaluate them during pipeline creation.\nThe merge_request_event-rule\nUsing this rule:\nif: '$CI_PIPELINE_SOURCE == \"merge_request_event\"'\n\nwill create a pipeline each time a Merge-Request is created/updated, but there will also be a pipeline created for the branch if you do not have another prevention mechanism (rule).\nAs the variable naming also points out, this is about the source of the pipeline trigger, other sources could be schedule, push, trigger etc.\nThe CI_OPEN_MERGE_REQUESTS variable:\nUsing a rule like:\nif: '$CI_OPEN_MERGE_REQUESTS'\n\nGitLab will create new pipelines if there is an open Merge-Request for this branch. Pipelines because there will be a Merge-Request pipeline (denoted with the detached flag) and a branch pipeline for the branch you pushed changes.\nif: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'\n\nThis rule above will create a pipeline for your branch when, and only when there is an open MR on that branch.\nif: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'\nwhen: never\n\nWhen using the above combination no pipeline will be created if there are open Merge-Requests on that branch, which might also be undesirable since the CI should run tests for branches and/or Merge-Requests.\nBut how to be able to have pipelines for MRs and Branches, but prevent duplications in pipeline creation?\n- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'\n when: never\n- if: '$CI_COMMIT_BRANCH' || '$CI_COMMIT_TAG'\n\nWith this rule set above GitLab will create pipelines for branches and Merge-Requests (the detached ones), as well as pipelines for git-tags, but it will prevent GitLab from duplicating pipelines.\nThe last rule evaluates to true either when there is a commit to a branch or there is a git-tag.\nFurther links\n\nOfficial docs on switching between MR- and Branch-Pipelines\nDocs on how to avoid duplicate pipelines with rules examples"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I recover from an erronous git push -f origin master?\nI just committed the wrong source to my project using --force option.\nIs it possible to revert? I understand that all previous branches have been overwritten using -f option, so I may have screwed up my previous revisions."
},
{
"role": "assistant",
"content": "Git generally doesn't throw anything away, but recovering from this may still be tricky.\nIf you have the correct source then you could just push it into the remote with the --force option. Git won't have deleted any branches unless you told it to. If you have actually lost commits then take a look at this useful guide to recovering commits. If you know the SHA-1 of the commits you want then you're probably OK.\nBest thing to do: Back everything up and see what is still in your local repository. Do the same on the remote if possible. Use git fsck to see if you can recover things, and above all DO NOT run git gc.\nAbove above all, never use the --force option unless you really, really mean it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Add only non-whitespace changes\nI have my text editor to automatically trim trailing whitespace upon saving a file, and I am contributing to an open source project that has severe problems with trailing whitespace.\nEvery time I try to submit a patch I must first ignore all whitespace-only changes by hand, to choose only the relevant information. Not only that, but when I run git rebase I usually run into several problems because of them.\nAs such I would like to be able to add to index only non-whitespace changes, in a way similar that git add -p does, but without having to pick all the changes myself.\nDoes anyone know how to do this?\nEDIT: I cannot change the way the project works, and they have decided, after discussing it on the mailing list, to ignore this."
},
{
"role": "assistant",
"content": "@Frew solution wasn't quite what I needed, so this is the alias I made for the exact same problem:\nalias.addnw=!sh -c 'git diff -U0 -w --no-color --src-prefix=a/ --dst-prefix=b/ \"$@\" | git apply --cached --ignore-whitespace --unidiff-zero -'\n\nOr you can simply run:\ngit diff -U0 -w --no-color --src-prefix=a/ --dst-prefix=b/ | git apply --cached --ignore-whitespace --unidiff-zero -\n\nUpdate\nAdded options -U0, and --unidiff-zero respectively to workaround context matching issues, according to this comment.\nBasically it applies the patch which would be applied with add without whitespace changes. You will notice that after a git addnw your/file there will still be unstaged changes, it's the whitespaces left.\nThe --no-color isn't required but as I have colors set to always, I have to use it. Anyway, better safe than sorry.\nWarning\nWhile this trick works as-is, if you try to use it to drop blank line changes with --ignore-blank-lines then things get complicated. With this option, git diff will just drop some chunks, making the resulting patch bogus since the line numbers in the destination file are going to be off."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %an"
},
{
"role": "assistant",
"content": "author name"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options http.minSessions"
},
{
"role": "assistant",
"content": "The number of curl sessions (counted across slots) to be kept across\nrequests. They will not be ended with curl_easy_cleanup() until\nhttp_cleanup() is invoked. If USE_CURL_MULTI is not defined, this\nvalue will be capped at 1. Defaults to 1."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Download single files from GitHub\n\nWhat are some tips on downloading a single file from a GitHub repo?\nI don't want the URL for displaying the raw file; in the case of binaries, there's nothing.\nhttp://support.github.com/discussions/feature-requests/41-download-single-file\nIs it even possible to use GitHub as a \"download server\"?\nIf we decide to switch to Google Code, is the mentioned functionality presented there?\nOr is there any free-of-charge hosting and VCS for open-source projects?"
},
{
"role": "assistant",
"content": "Go to the file you want to download.\nClick it to view the contents within the GitHub UI.\nIn the top right, right click the Raw button.\nSave as..."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker --html-path"
},
{
"role": "assistant",
"content": "Print the path, without trailing slash, where Git’s HTML\ndocumentation is installed and exit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options pull.ff"
},
{
"role": "assistant",
"content": "By default, Git does not create an extra merge commit when merging\na commit that is a descendant of the current commit. Instead, the\ntip of the current branch is fast-forwarded. When set to false ,\nthis variable tells Git to create an extra merge commit in such\na case (equivalent to giving the --no-ff option from the command\nline). When set to only , only such fast-forward merges are\nallowed (equivalent to giving the --ff-only option from the\ncommand line). This setting overrides merge.ff when pulling."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs porcelain"
},
{
"role": "assistant",
"content": "Use a special line-based format intended for script\nconsumption. Added/removed/unchanged runs are printed in the\nusual unified diff format, starting with a + / - /` `\ncharacter at the beginning of the line and extending to the\nend of the line. Newlines in the input are represented by a\ntilde ~ on a line of its own."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git error: \"fatal: corrupt patch at line 36\"\nI have a Java file that ends like this:\n }\n}\n\nAnd I mistakenly erased the newline at the end some time ago, but it was fine just until today when I got an error message from Git-GUI when commiting\nfatal: corrupt patch at line 36\n\nI tried adding the missing newline, but Git seems not to be able to handle it right:\nBefore adding newline:\n }\n }\n\\ No newline at end of file\n\nAfter adding newline:\n }\n-}\n\\ No newline at end of file\n+}\n\nAnd it still gives me that error.\nI tried reverting changes and adding only the newline without other changes to the file, but it didn't help either.\nEDIT: Adding two or even three newlines doesn't help too.\nEDIT2: This error occurs only when commiting lines within the last hunk."
},
{
"role": "assistant",
"content": "This is happens when you edit '-' lines.\nWhen you remove '-' and forget to add ' ' (space) instead of it\nOpen your patch and check that all lines you want to leave untouched are started with ' ' (space)\nUPDATE\nIt is also possible that your editor has the option: \"Delete spaces at the end of line\". So, when you save the patch in your editor:\n-Line with space at end <--- NOTICE: Here there is one space at the end\n+Line with no space at end<--- Here there's no space\n\nYour editor will remove trailing space and patch become like this:\n-Line with space at end<--- Here no space. Patch will FAIL!!!\n+Line with no space at end<--- Here no space also\n\nThis patch will FAIL because the origin file has no line:\n-Line with space at end<---\n\ninstead it has:\n-Line with space at end <--- \n\nUPD\nSometimes you want to remove - lines. You change it by whitespace which is trimmed. So this does not work (here is just wihitespace as first character):\n \n\nTo workaround this just add + line after it:\n-\n+\n\nThis patch will remove empty line and add it again"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: How to reset a remote Git repository to remove all commits?\nHow can I reset a remote and local Git repository to remove all commits?\nI would like to start fresh with the current Head as the initial commit."
},
{
"role": "assistant",
"content": "Completely reset?\n\nDelete the .git directory locally.\nRecreate the git repostory:\n$ cd (project-directory)\n$ git init\n$ (add some files)\n$ git add .\n$ git commit -m 'Initial commit'\n\nPush to remote server, overwriting. Remember you're going to mess everyone else up doing this … you better be the only client.\n$ git remote add origin <url>\n$ git push --force --set-upstream origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git export from github remote repository\n\nI'd like to export from github remote repository, not cloning it. Similar to svn export, I do not want to get .git folder with it. I can work around it by cloning and removing .git folder. I wonder if there is a cleaner way?\nI read it somewhere you can use git archive to achieve this.\nHowever I got the following errors..\n$ git archive --format=tar [email protected]:xxx/yyy.git master | tar -xf -\n\nInvalid command: 'git-upload-archive 'xxx/yyy.git''\nYou appear to be using ssh to clone a git:// URL.\nMake sure your core.gitProxy config option and the\nGIT_PROXY_COMMAND environment variable are NOT set.\nfatal: The remote end hung up unexpectedly\n\nAny help would be great. Thanks."
},
{
"role": "assistant",
"content": "Thanks to the Subversion support by GitHub, you can use svn export to get the project without any version control files:\nsvn export https://github.com/user/project/trunk\n\nNotice the URL format:\n\nThe base URL is https://github.com/\nUSERNAME/PROJECTNAME without .git\n/trunk appended at the end\n\nThis way you can get branches and subdirectories too.\nThis creates a directory with the exported files. It's not possible to create a tar/zip directly, you have to do in two steps (export + zip). This is a limitation of svn export itself.\nAs @Jon pointed out, this will create the export in a directory named trunk by default. You can specify a different name if you prefer:\nsvn export https://github.com/username/projectname/trunk projectname\n\nYou can use this technique to export any sub-directory of the project.\nFor example if you want only some/path, you can do:\nsvn export https://github.com/username/projectname/trunk/some/path local-dir-name\n\nYou can get paths from branches and tags too. The endpoint https://github.com/username/projectname behaves fully as a Subversion repository with a regular layout, so you will find branches in https://github.com/username/projectname/branches and tags in https://github.com/username/projectname/tags.\nBefore you export something large by mistake, it's good to check first the content of the path. You can do that using svn ls, for example:\nsvn ls https://github.com/username/projectname/\n\nNormally this should give you:\nbranches/\ntags/\ntrunk/\n\nYou could iteratively explore the repository this way."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Rubymine: How to make Git ignore .idea files created by Rubymine\nI use Rubymine for Rails projects. Very often, Rubymine makes changes in .idea/* files that I don't care about. But it keeps preventing me from checking out new branches, and makes my version of .idea/ different from my coworkers.\nWe already added .idea/ to .gitignore, but it keeps tracking changes in .idea. How should I do this the right way?\nBelow is one of typical error messages I got:\nerror: Your local changes to the following files would be overwritten by checkout:\n .idea/workspace.xml"
},
{
"role": "assistant",
"content": "Try git rm -r --cached .idea in your terminal. It disables the change tracking."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does the brown asterisk icon on a file mean in Eclipse?\nI am using the git plugin for Eclipse. Some of my files are marked with a brown asterisk. What does it mean? Where can I find documentation for what the rest of the git icons mean in Eclipse?"
},
{
"role": "assistant",
"content": "This page should give you a good rundown of what the icons mean for GIT in eclipse\nA quoted summary:\n\n\ndirty (folder) - At least one file below the folder is dirty; that means that it has changes in the working tree that are neither in the index nor in the repository.\ntracked - The resource is known to the Git repository.\nuntracked - The resource is not known to the Git repository.\nignored - The resource is ignored by the Git team provider. Here only the preference settings under Team -> Ignored Resources and the \"derived\" flag are relevant. The .gitignore file is not taken into account.\ndirty - The resource has changes in the working tree that are neither in the index nor in the repository.\nstaged - The resource has changes which are added to the index. Not that adding to the index is possible at the moment only on the commit dialog on the context menu of a resource.\npartially-staged - The resource has changes which are added to the index and additionally changes in the working tree that are neither in the index nor in the repository.\nadded - The resource is not yet tracked by but added to the Git repository.\nremoved - The resource is staged for removal from the Git repository.\nconflict - A merge conflict exists for the file.\nassume-valid - The resource has the \"assume unchanged\" flag. This means that Git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell Git when you change the working tree file. This setting can be switched on with the menu action Team->Assume unchanged (or on the command line with git update-index --assume-unchanged)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-rebase"
},
{
"role": "assistant",
"content": "Reapply commits on top of another base tip"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --date=<format>"
},
{
"role": "assistant",
"content": "Only takes effect for dates shown in human-readable format, such\nas when using --pretty . log.date config variable sets a default\nvalue for the log command’s --date option. By default, dates\nare shown in the original time zone (either committer’s or\nauthor’s). If -local is appended to the format (e.g., iso-local ), the user’s local time zone is used instead. --date=relative shows dates relative to the current time,\ne.g. “2 hours ago”. The -local option has no effect for --date=relative . --date=local is an alias for --date=default-local . --date=iso (or --date=iso8601 ) shows timestamps in a ISO 8601-like format.\nThe differences to the strict ISO 8601 format are: a space instead of the T date/time delimiter a space between time and time zone no colon between hours and minutes of the time zone --date=iso-strict (or --date=iso8601-strict ) shows timestamps in strict\nISO 8601 format. --date=rfc (or --date=rfc2822 ) shows timestamps in RFC 2822\nformat, often found in email messages. --date=short shows only the date, but not the time, in YYYY-MM-DD format. --date=raw shows the date as seconds since the epoch (1970-01-01\n00:00:00 UTC), followed by a space, and then the timezone as an offset\nfrom UTC (a + or - with four digits; the first two are hours, and\nthe second two are minutes). I.e., as if the timestamp were formatted\nwith strftime(\"%s %z\") ).\nNote that the -local option does not affect the seconds-since-epoch\nvalue (which is always measured in UTC), but does switch the accompanying\ntimezone value. --date=human shows the timezone if the timezone does not match the\ncurrent time-zone, and doesn’t print the whole date if that matches\n(ie skip printing year for dates that are \"this year\", but also skip\nthe whole date itself if it’s in the last few days and we can just say\nwhat weekday it was). For older dates the hour and minute is also\nomitted. --date=unix shows the date as a Unix epoch timestamp (seconds since\n1970). As with --raw , this is always in UTC and therefore -local has no effect. --date=format:... feeds the format ... to your system strftime ,\nexcept for %s, %z, and %Z, which are handled internally.\nUse --date=format:%c to show the date in your system locale’s\npreferred format. See the strftime manual for a complete list of\nformat placeholders. When using -local , the correct syntax is --date=format-local:... . --date=default is the default format, and is based on ctime(3)\noutput. It shows a single line with three-letter day of the week,\nthree-letter month, day-of-month, hour-minute-seconds in \"HH:MM:SS\"\nformat, followed by 4-digit year, plus timezone information, unless\nthe local time zone is used, e.g. Thu Jan 1 00:00:00 1970 +0000 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I discard remote changes and mark a file as \"resolved\"?\nI have some local files, I pull from remote branch and there are conflicts. I know that I would like to keep my local changes and ignore the remote changes causing conflicts. Is there a command I can use to in effect say \"mark all conflicts as resolved, use local\"?"
},
{
"role": "assistant",
"content": "git checkout has the --ours option to check out the version of the file that you had locally (as opposed to --theirs, which is the version that you pulled in). You can pass . to git checkout to tell it to check out everything in the tree. Then you need to mark the conflicts as resolved, which you can do with git add, and commit your work once done:\ngit checkout --ours . # checkout our local version of all files\ngit add -u # mark all conflicted files as merged\ngit commit # commit the merge\n\nNote the . in the git checkout command. That's very important, and easy to miss. git checkout has two modes; one in which it switches branches, and one in which it checks files out of the index into the working copy (sometimes pulling them into the index from another revision first). The way it distinguishes is by whether you've passed a filename in; if you haven't passed in a filename, it tries switching branches (though if you don't pass in a branch either, it will just try checking out the current branch again), but it refuses to do so if there are modified files that that would effect. So, if you want a behavior that will overwrite existing files, you need to pass in . or a filename in order to get the second behavior from git checkout.\nIt's also a good habit to have, when passing in a filename, to offset it with --, such as git checkout --ours -- <filename>. If you don't do this, and the filename happens to match the name of a branch or tag, Git will think that you want to check that revision out, instead of checking that filename out, and so use the first form of the checkout command.\nI'll expand a bit on how conflicts and merging work in Git. When you merge in someone else's code (which also happens during a pull; a pull is essentially a fetch followed by a merge), there are few possible situations. \nThe simplest is that you're on the same revision. In this case, you're \"already up to date\", and nothing happens.\nAnother possibility is that their revision is simply a descendent of yours, in which case you will by default have a \"fast-forward merge\", in which your HEAD is just updated to their commit, with no merging happening (this can be disabled if you really want to record a merge, using --no-ff). \nThen you get into the situations in which you actually need to merge two revisions. In this case, there are two possible outcomes. One is that the merge happens cleanly; all of the changes are in different files, or are in the same files but far enough apart that both sets of changes can be applied without problems. By default, when a clean merge happens, it is automatically committed, though you can disable this with --no-commit if you need to edit it beforehand (for instance, if you rename function foo to bar, and someone else adds new code that calls foo, it will merge cleanly, but produce a broken tree, so you may want to clean that up as part of the merge commit in order to avoid having any broken commits).\nThe final possibility is that there's a real merge, and there are conflicts. In this case, Git will do as much of the merge as it can, and produce files with conflict markers (<<<<<<<, =======, and >>>>>>>) in your working copy. In the index (also known as the \"staging area\"; the place where files are stored by git add before committing them), you will have 3 versions of each file with conflicts; there is the original version of the file from the ancestor of the two branches you are merging, the version from HEAD (your side of the merge), and the version from the remote branch.\nIn order to resolve the conflict, you can either edit the file that is in your working copy, removing the conflict markers and fixing the code up so that it works. Or, you can check out the version from one or the other sides of the merge, using git checkout --ours or git checkout --theirs. Once you have put the file into the state you want it, you indicate that you are done merging the file and it is ready to commit using git add, and then you can commit the merge with git commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "github server-side git hooks (i.e. pre-commit and post-commit)\n\nI've looked around the answers on SO, and the web, and I can't see anything on how to set up a server-side git hook on github (as opposed to webhooks). Is there a way to do this?\nOr alternatively, is there a way to set it up so that .git/hooks is a symlink to a part of the working tree at the time of cloning?\nI should add that this is an internally-hosted github server."
},
{
"role": "assistant",
"content": "For obvious reasons, GitHub won’t allow you to execute arbitrary code on their servers as part of Git hooks. The only hooking they allow is through their webhooks or the integrated third-party services.\nIf you need to run some custom code, you will have to host that somewhere and set up a webhook to run it on your own server."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules -j <n> --jobs <n>"
},
{
"role": "assistant",
"content": "This option is only valid for the update command.\nClone new submodules in parallel with as many jobs.\nDefaults to the submodule.fetchJobs option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cherry-pick - Apply the changes introduced by some existing commits"
},
{
"role": "assistant",
"content": "NAME git-cherry-pick - Apply the changes introduced by some existing commits"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository -6 --ipv6"
},
{
"role": "assistant",
"content": "Use IPv6 addresses only, ignoring IPv4 addresses."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-apply"
},
{
"role": "assistant",
"content": "Apply a patch to files and/or to the index"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How git works when two peers push changes to same remote simultaneously\nI am new to git, I usually use P4 which has center repository, while git is distributed VCS. \nI am interested in how git works when two peers push changes to same remote simultaneously. \nAssume each peer resolved all conflicts before push. I guess the later one will be rejected if git reports conflicts!\nHowever, from what I understand, git is internally a key/value store, much like the current popular NOSQL database especially Couch-DB which supports p2p replication.\nActually I want to ask, how does git process conflicts in the case that clients push changes to remote git repository? Is the push rejected?\nFrom Mark's answer, I think the push should be rejected."
},
{
"role": "assistant",
"content": "Short answer\nYes, one of the pushes will be rejected - whichever one is later, even if it's just by a microsecond, as Jefromi mentions in his comment. However, it will be rejected because the remote repository sees that the history of the later push doesn't include the history of the earlier one, rather than because it sees any conflict in the content that's being pushed.\nMore detailed answer\nUsually a push will be rejected if it wouldn't \"fast-forward\" the branch, in Git terminology. This means that if your master is at A and the remote repository's is at B, then the push will only succeed if B is an ancestor of A. (I say \"usually\" because you can add options to \"force\" the push if the remote repository allows that, but that's not the typical case.)\nIn the case you describe, supposing all three repositories initially have the same history:\nP -- Q -- R\n\nAnd you have added a commit S:\nP -- Q -- R -- S\n\n... while someone else has added a commit T:\nP -- Q -- R -- T\n\nIf that other person gets there first when pushing (that is, Git on the server handles their push first), then their push will be accepted because R is an ancestor of T, so the remote repository will then also have the history P -- Q -- R -- T. If you subsequently try to push, you will get an error because T is not an ancestor of S. Typically, on seeing that ! [rejected] error you will either run git pull or git pull --rebase to make sure that you are ahead of master in the remote repository.\ngit pull will create a merge commit M to make your history look like:\nP -- Q -- R -- T -- M\n \\ /\n -- S -\n\n... while git pull --rebase will reapply the changes that you introduced on top of T to create a new commit, S':\nP -- Q -- R -- T -- S'\n\nIn either of those cases, you should be able to push again, because T is an ancestor of both M and S'. (That is assuming no one else has pushed again in the mean time!)\nBy only allowing fast-forwards there never has to be resolution of conflicts on the remote side - if there are any conflicts, you'll be prompted to resolve them locally when you run git pull.\nIt might be worth noting that the update applied to the remote repository in response to a push is atomic, so in the example situation we've described above where S and T are being pushed at the same time, it will always be the case that one of them is completely applied while the other one will fail, having not effect.\nA note about your key/value store point\nWhile Git's object database is implemented as a key/value store, which maps object names (also referred to as hashes or SHA1sums) to the content of objects, in my experience it's easy for people learning Git to make confusing assumptions about how Git behaves when they hear \"it's like a key value store\" - it sounds as if this might be happening in your case, so I'd suggest that thinking about Git at that level isn't the most helpful approach for understanding this issue."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Rename file with Git\nI would like to rename file from README to README.md. What is the best practice to do that?\n\nI have only one repo called \"change-z-index\".\n\nI open and login like that:\nssh -T [email protected]\n\n\n\nAnd I enter my passphrase.\n\nI try to rename the file like that:\ngit mv README README.md\ngit commit -m \"renamed\"\ngit push origin master\n\n\n\nIt gives me an error saying bad source.\nI think I need to select my repo first... its name is \"change-z-index\". I have read manual many times, but still can't understand how to do it."
},
{
"role": "assistant",
"content": "As far as I can tell, GitHub does not provide shell access, so I'm curious about how you managed to log in in the first place.\n$ ssh -T [email protected]\nHi username! You've successfully authenticated, but GitHub does not provide\nshell access.\n\nYou have to clone your repository locally, make the change there, and push the change to GitHub.\n$ git clone [email protected]:username/reponame.git\n$ cd reponame\n$ git mv README README.md\n$ git commit -m \"renamed\"\n$ git push origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs plain"
},
{
"role": "assistant",
"content": "Any line that is added in one location and was removed\nin another location will be colored with color.diff.newMoved .\nSimilarly color.diff.oldMoved will be used for removed lines\nthat are added somewhere else in the diff. This mode picks up any\nmoved line, but it is not very useful in a review to determine\nif a block of code was moved without permutation."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: branches diverged; how to proceed?\nMy local tree has diverged from the master:\n$ git status\n# On branch master\n# Your branch and 'origin/master' have diverged,\n# and have 7 and 3 different commit(s) each, respectively.\n#\nnothing to commit (working directory clean)\n\nI tried git pull --rebase and failed:\n$ git pull --rebase\nFirst, rewinding head to replay your work on top of it...\nApplying: * ...\nUsing index info to reconstruct a base tree...\nFalling back to patching base and 3-way merge...\nAuto-merging ChangeLog\nCONFLICT (content): Merge conflict in ChangeLog\nFailed to merge in the changes.\nPatch failed at 0001 * ...\n\nSo I reverted with git rebase --abort and I am now at square 1.\nWhat I want is:\n\n\"Export\" my 7 patches into human readable diff files (a la hg export).\nMake my tree a carbon copy of the origin/master (a la hg strip).\nre-apply my 7 patches one-by-one by hand (a la hg import).\n\nI do understand that git rebase --continue does this.\nI did it and it did work (after a few manual merges and a git add).\nHowever, I want to be able to do that manually, \nso I am wondering what are the git commands corresponding to the hg commands above.\nThanks.\nPS. Please do not tell me that using a ChangeLog file with git is stupid.\nEven if it is, it is not up to me."
},
{
"role": "assistant",
"content": "There are, of course, several ways you could do this manually. You'll still have the same conflicts because git is basically doing this for you under the hood. But if you want to do this manually, here are a couple of ways.\nFirst, export your commits as a series of patches. The easiest way to do this is using git format-patch:\ngit format-patch -M @{upstream}\n\nwill produce 7 patch files -- one for each of your commits. (Note that \"@{upstream}\" is literal -- it's a not so well known feature of git.) This is better than capturing the output of git diff because all of the commit information (author, date, message, etc.) are preserved.\nThen you could reset your repository to match the upstream:\ngit reset --hard @{upstream}\n\nThen you can re-apply your patches using git am -- either one at a time or all at once.\ngit am 0001-blah-blah.patch\ngit am 0002-blah-blah.patch\n...\n\nA second option would be to create a spare branch with your work on it:\ngit branch scrap\n\nThen reset your branch to the upstream:\ngit reset --hard @{upstream}\n\nThen cherry-pick the commits over:\ngit cherry-pick scrap~6\ngit cherry-pick scrap~5\ngit cherry-pick scrap~4\n...\n\nThen trash the scrap branch:\ngit branch -D scrap"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitrevisions - Specifying revisions and ranges for Git HEAD"
},
{
"role": "assistant",
"content": "names the commit on which you based the changes in the working tree."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "updating local master with remote master\n\nI have a branch that I want to merge to the remote, most up-to-date master. I have a local, outdated master on my computer. \nI ran git pull upstream master, and it retrieved the remote master, and that was great, exactly what I wanted. Then, without thinking, i accidentally discarded the changes while switching to another branch. \nWhile on my local master, I have run git pull, and git pull upstream master many times now, and it always says \"Already up to date.\" when it clearly isn't. At first git pull upstream master worked just fine, but now it doesn't, and the machine thinks it is up to date when it isn't. How can I make my local master the same as the remote one again?"
},
{
"role": "assistant",
"content": "Well, typically when I have an outdated master locally and want to merge recent changes in a branch (say, my_branch) to master (both locally and remotely), I do the following,\n\nCheckout the master branch locally.\nRun git pull --rebase origin master (This pulls down the most up-to-date changes on master locally)\nCheckout local branch say my_branch\nRun git pull --rebase origin master(This updates your local branch against the most recent master on remote. You may need to resolve the conflicts here (if any that is))\ncheckout the master branch locally, again.\nRun git merge my_branch\nRun git push origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What are you supposed to enter for the Account name when adding a GitLab account to Xcode?\n\nThis might sound like an obvious and dumb question, but I just cannot signin to a GitLab account (not self-hosted) in order to add it within XCode.\nXCode prompts me to enter an account and a personal access token (which I've created from within the gitlab account and granted full read/write access).\nBut what do I enter for the account? Is that my gitlab username, my gitlab email etc.? No matter what I try, I can't logon within XCode.\nThe email associated with my gitlab account is [email protected], and when I logon to the gitlab website I just enter the SomeName portion of it along with my password.\nOnce logged into gitlab if I display my profile it shows \"My Name\" and underneath that @SomeName \nIf I go to the account section, it displays the full account as:\nhttps://gitlab.clt.something.com/SomeName\n\nWithin XCode I have tried entering the following 6 things as the account name:\n1) https://gitlab.clt.something.com/SomeName\n2) https://gitlab.clt.something.com\n3) My Name\n4) @SomeName\n5) SomeName\n6) [email protected]\n\nBut XCode just keeps saying your account or token is incorrect.\nThe token cannot be incorrect as I only created it 20 minutes ago, so if none of the 6 things above is the correct account name to enter, then what is and where within gitlab do I find it?"
},
{
"role": "assistant",
"content": ""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git diff in summary?\nWith git pull, it shows a diff summary like this:\nUpdating 6a78751..811f788\nFast-forward\n app/Http/Controllers/SaleController.php | 7 +-\n .../views/pages/sale/create.blade.php | 137 +++++++++++++---\n resources/views/pages/sale/index.blade.php | 4 +-\n resources/views/pages/sale/show.blade.php | 5 +-\n 4 files changed, 123 insertions(+), 30 deletions(-)\n\nIs there a way to use commands like git diff to get similar output?"
},
{
"role": "assistant",
"content": "git log --stat will show the amount each file was changed.\ngit whatchanged gives some detail into the files that were modified.\ngit diff --stat <sha1> <sha2> gives the files and the amount of changes between two commits.\ngit diff --stat <branch> to compare to another branch (e.g. master)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I extract test coverage from the istanbul text-summary reporter with a regex?\n\nGitlab CI requires you to specify a regex to extract the statements code coverage (so that they can display it). Given the build output below (with jest and istanbul), I've managed to come as far as: /Statements.*(\\d+\\%)/\n... (other build output)\n=============================== Coverage summary ===============================\nStatements : 53.07% ( 95/179 )\nBranches : 66.67% ( 28/42 )\nFunctions : 30.99% ( 22/71 )\nLines : 50.96% ( 80/157 )\n================================================================================\n... (other build output)\n\nThis highlights the part Statements : 53.07% (see here: http://regexr.com/3e9sl). However, I need to match only the 53.07 part, how do I do that?"
},
{
"role": "assistant",
"content": "I need to match only the 53.07 part,\n\nUse lazy .*?, add (?:\\.\\d+)? to also match floats, and access the capture group:\n\n\nvar re = /Statements.*?(\\d+(?:\\.\\d+)?)%/; \r\nvar str = '... (other build output)\\n=============================== Coverage summary ===============================\\nStatements : 53.07% ( 95/179 )\\nBranches : 66.67% ( 28/42 )\\nFunctions : 30.99% ( 22/71 )\\nLines : 50.96% ( 80/157 )\\n================================================================================\\n... (other build output)';\r\nvar res = (m = re.exec(str)) ? m[1] : \"\";\r\nconsole.log(res);\n\n\n\nNote that Statements.*?(\\d+(?:\\.\\d+)?)% also allows integer values, not only floats.\nPattern description:\n\nStatements - a literal string \n.*? - zero or more chars other than whitespace, but as few as possible\n(\\d+(?:\\.\\d+)?) - Group 1 (the value you need will be captured into this group) capturing 1+ digits and an optional sequence of . and 1+ digits after it\n% - a percentage sign (if you need to print it, move it inside parentheses above)\n\nSee the regex demo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_COMMITTER_EMAIL"
},
{
"role": "assistant",
"content": "The email address used in the author identity when creating commit or\ntag objects, or when writing reflogs. Overrides the user.email and committer.email configuration settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clone - Clone a repository into a new directory --recurse-submodules [ = <pathspec> ]"
},
{
"role": "assistant",
"content": "After the clone is created, initialize and clone submodules\nwithin based on the provided <pathspec> . If no =<pathspec> is\nprovided, all submodules are initialized and cloned.\nThis option can be given multiple times for pathspecs consisting\nof multiple entries. The resulting clone has submodule.active set to\nthe provided pathspec, or \".\" (meaning all submodules) if no\npathspec is provided. Submodules are initialized and cloned using their default settings. This is\nequivalent to running git submodule update --init --recursive <pathspec> immediately after\nthe clone is finished. This option is ignored if the cloned repository does\nnot have a worktree/checkout (i.e. if any of --no-checkout / -n , --bare ,\nor --mirror is given)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_TERMINAL_PROMPT"
},
{
"role": "assistant",
"content": "If this Boolean environment variable is set to false, git will not prompt\non the terminal (e.g., when asking for HTTP authentication)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order -F --fixed-strings"
},
{
"role": "assistant",
"content": "Consider the limiting patterns to be fixed strings (don’t interpret\npattern as a regular expression)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] [--merge-base] <commit> <commit> [--] [<path>…]"
},
{
"role": "assistant",
"content": "This is to view the changes between two arbitrary\n<commit>. If --merge-base is given, use the merge base of the two commits for the\n\"before\" side. git diff --merge-base A B is equivalent to git diff $(git merge-base A B) B ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --boundary"
},
{
"role": "assistant",
"content": "Output excluded boundary commits. Boundary commits are\nprefixed with - ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc"
},
{
"role": "assistant",
"content": "diff format for merges \"git-diff-tree\", \"git-diff-files\" and \"git-diff --raw\"\ncan take -c or --cc option\nto generate diff output also for merge commits. The output differs\nfrom the format described above in the following way: there is a colon for each parent there are more \"src\" modes and \"src\" sha1 status is concatenated status characters for each parent no optional \"score\" number tab-separated pathname(s) of the file For -c and --cc , only the destination or final path is shown even\nif the file was renamed on any side of history. With --combined-all-paths , the name of the path in each parent is shown\nfollowed by the name of the path in the merge commit. Examples for -c and --cc without --combined-all-paths : ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM\tdesc.c\n::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM\tbar.sh\n::100644 100644 100644 e07d6c5 9042e82 ee91881 RR\tphooey.c Examples when --combined-all-paths added to either -c or --cc : ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM\tdesc.c\tdesc.c\tdesc.c\n::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM\tfoo.sh\tbar.sh\tbar.sh\n::100644 100644 100644 e07d6c5 9042e82 ee91881 RR\tfooey.c\tfuey.c\tphooey.c Note that combined diff lists only files which were modified from\nall parents."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options uploadpack.allowFilter"
},
{
"role": "assistant",
"content": "If this option is set, upload-pack will support partial\nclone and partial fetch object filtering."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-worktree - Manage multiple working trees prune"
},
{
"role": "assistant",
"content": "Prune worktree information in $GIT_DIR/worktrees ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to change folder with git bash?\nMy default git folder is C:\\Users\\username\\.git.\nWhat command should I use to go into C:/project?"
},
{
"role": "assistant",
"content": "The command is:\ncd /c/project/\n\nTip:\nUse the pwd command to see which path you are currently in, handy when you did a right-click \"Git Bash here...\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "OpenSSL SSL_connect: Connection was reset in connection to github.com:443 while try to git push\n\nfatal: unable to access 'https://github.com/XXX/XXXXX.git/': OpenSSL SSL_connect: Connection was reset in connection to github.com:443\n\nSuddenly I'm getting above error while I try to git pull, git push, or clone the repo."
},
{
"role": "assistant",
"content": "I also encountered a similar situation; that's when I came across an answer on Code Grepper by Shibbir Ahmed, where he provided this:\ngit config --global --unset-all remote.origin.proxy\nThat solved the issue for me."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-read-tree - Reads tree information into the index <tree-ish#>"
},
{
"role": "assistant",
"content": "The id of the tree object(s) to be read/merged."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git command output is in editor (vim) and not directly to terminal output [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nGit branch command behaves like 'less'\n\n (10 answers)\n \n\nClosed 6 years ago.\n\n\n\nI don't know why but the output from some git command are in editor (vim) and not directly to the terminal output.\nFor example, the command git branch open vim and list the branches but I would like that the output are directly in the terminal.\nI didn't set vim as default editor on the git config.\nMy config is Ubuntu 18.04 and zsh with oh-my-zsh plugin."
},
{
"role": "assistant",
"content": "Reply to myself.\nIt is a default behavior change introduced in git 2.16.\nWith git --no-pager branch or git config --global pager.branch false it's ok"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together --autostash --no-autostash"
},
{
"role": "assistant",
"content": "Automatically create a temporary stash entry before the operation\nbegins, record it in the ref MERGE_AUTOSTASH and apply it after the operation ends. This means\nthat you can run the operation on a dirty worktree. However, use\nwith care: the final stash application after a successful\nmerge might result in non-trivial conflicts."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules --all"
},
{
"role": "assistant",
"content": "This option is only valid for the deinit command. Unregister all\nsubmodules in the working tree."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository"
},
{
"role": "assistant",
"content": "SYNOPSIS git fetch [<options>] [<repository> [<refspec>…]] git fetch [<options>] <group> git fetch --multiple [<options>] [(<repository> | <group>)…] git fetch --all [<options>]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to amend several commits in Git to change author\nI have made a series of commits in Git and I realise now that I forgot to set my user name and user email properties correctly (new machine). I have not yet pushed these commits to my repository, so how can I correct these commits before I do so (only the 3 latest commits on the master branch)?\nI have been looking at git reset and git commit -C <id> --reset-author, but I don't think I'm on the right track."
},
{
"role": "assistant",
"content": "Warning: now deprecated in favor of filter-repo.\nRebase/amend seems inefficient, when you have the power of filter-branch at your fingertips:\ngit filter-branch --env-filter 'if [ \"$GIT_AUTHOR_EMAIL\" = \"incorrect@email\" ]; then\n GIT_AUTHOR_EMAIL=correct@email;\n GIT_AUTHOR_NAME=\"Correct Name\";\n GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL;\n GIT_COMMITTER_NAME=\"$GIT_AUTHOR_NAME\"; fi' -- --all\n\n(split across lines for clarity, but not necessary)\nBe sure to inspect the result when you're done, to make sure that you didn't change anything you didn't mean to!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: How to remove file from index without deleting files from any repository\nWhen you use\ngit rm --cached myfile\n\nit doesn't delete from the local filesystem, which is the goal. But if you've already versioned and committed the file, pushed it to a central repository, and pulled it into yet another repository before using the command, it will delete the file from that system.\nIs there a way to just remove the file from versioning without deleting it from any filesystem?\nEdit: Clarified, I hope."
},
{
"role": "assistant",
"content": "I do not think a Git commit can record an intention like “stop tracking this file, but do not delete it”.\nEnacting such an intention will require intervention outside Git in any repositories that merge (or rebase onto) a commit that deletes the file.\n\nSave a Copy, Apply Deletion, Restore\nProbably the easiest thing to do is to tell your downstream users to save a copy of the file, pull your deletion, then restore the file.\nIf they are pulling via rebase and are ‘carrying’ modifications to the file, they will get conflicts. To resolve such conflicts, use git rm foo.conf && git rebase --continue (if the conflicting commit has changes besides those to the removed file) or git rebase --skip (if the conflicting commit has only changed to the removed file).\nRestore File as Untracked After Pulling a Commit That Deletes It\nIf they have already pulled your deletion commit, they can still recover the previous version of the file with git show:\ngit show @{1}:foo.conf >foo.conf\n\nOr with git checkout (per comment by William Pursell; but remember to re-remove it from the index!):\ngit checkout @{1} -- foo.conf && git rm --cached foo.conf\n\nIf they have taken other actions since pulling your deletion (or they are pulling with rebase into a detached HEAD), they may need something other than @{1}. They could use git log -g to find the commit just before they pulled your deletion.\n\nIn a comment, you mention that the file you want to “untrack, but keep” is some kind of configuration file that is required for running the software (directly out of a repository).\nKeep File as a ‘Default’ and Manually/Automatically Activate It\nIf it is not completely unacceptable to continue to maintain the configuration file's content in the repository, you might be able to rename the tracked file from (e.g.) foo.conf to foo.conf.default and then instruct your users to cp foo.conf.default foo.conf after applying the rename commit.\nOr, if the users already use some existing part of the repository (e.g. a script or some other program configured by content in the repository (e.g. Makefile or similar)) to launch/deploy your software, you could incorporate a defaulting mechanism into the launch/deploy process:\ntest -f foo.conf || test -f foo.conf.default &&\n cp foo.conf.default foo.conf\n\nWith such a defaulting mechanism in place, users should be able to pull a commit that renames foo.conf to foo.conf.default without having to do any extra work.\nAlso, you avoid having to manually copy a configuration file if you make additional installations/repositories in the future.\nRewriting History Requires Manual Intervention Anyway…\nIf it is unacceptable to maintain the content in the repository then you will likely want to completely eradicate it from history with something like git filter-branch --index-filter ….\nThis amounts to rewriting history, which will require manual intervention for each branch/repository (see “Recovering From Upstream Rebase” section in the git rebase manpage).\nThe special treatment required for your configuration file would be just another step that one must perform while recovering from the rewrite:\n\nSave a copy of the configuration file.\nRecover from the rewrite.\nRestore the configuration file.\n\n\nIgnore It to Prevent Recurrence\nWhatever method you use, you will probably want to include the configuration filename in a .gitignore file in the repository so that no one can inadvertently git add foo.conf again (it is possible, but requires -f/--force).\nIf you have more than one configuration file, you might consider ‘moving’ them all into a single directory and ignoring the whole thing (by ‘moving’ I mean changing where the program expects to find its configuration files, and getting the users (or the launch/deploy mechanism) to copy/move the files to to their new location; you obviously would not want to git mv a file into a directory that you will be ignoring)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why would I want stage before committing in Git?\nI'm new to version control and I understand that \"committing\" is essentially creating a backup while updating the new 'current' version of what you're working on.\nWhat I don't understand is what staging for is from a practical perspective. Is staging something that exists in name only or does it serve a purpose? When you commit, its going to commit everything anyway, right?\nEdit: I think I may be confusing the terminology. Is a 'staged' file the same thing as a 'tracked' file?"
},
{
"role": "assistant",
"content": "When you commit it's only going to commit the changes in the index (the \"staged\" files). There are many uses for this, but the most obvious is to break up your working changes into smaller, self-contained pieces. Perhaps you fixed a bug while you were implementing a feature. You can git add just that file (or git add -p to add just part of a file!) and then commit that bugfix before committing everything else. If you are using git commit -a then you are just forcing an add of everything right before the commit. Don't use -a if you want to take advantage of staging files.\nYou can also treat the staged files as an intermediate working copy with the --cached to many commands. For example, git diff --cached will show you how the stage differs from HEAD so you can see what you're about to commit without mixing in your other working changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cherry-pick - Apply the changes introduced by some existing commits git cherry-pick -n master~1 next"
},
{
"role": "assistant",
"content": "Apply to the working tree and the index the changes introduced\nby the second last commit pointed to by master and by the last\ncommit pointed to by next, but do not create any commit with\nthese changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git pull aborted with error filename too long\nI'm using Windows as my OS, and working on a project with a friend who's using a Mac. He checked in code to our Github.\nI was trying to git pull everything he did and it aborted with \"filename too long\" errors of 3rd party code.\nWhat can I do?"
},
{
"role": "assistant",
"content": "The msysgit FAQ on Git cannot create a filedirectory with a long path doesn't seem up to date, as it still links to old msysgit ticket #110. However, according to later ticket #122 the problem has been fixed in msysgit 1.9, thus:\n\nUpdate to msysgit 1.9 (or later)\nLaunch Git Bash\nGo to your Git repository which 'suffers' of long paths issue\nEnable long paths support with git config core.longpaths true\n\nSo far, it's worked for me very well.\nBe aware of important notice in comment on the ticket #122\n\ndon't come back here and complain that it breaks Windows Explorer,\n cmd.exe, bash or whatever tools you're using."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Fastest way to merge branches via gitlab (or git)?\n\nI have a development branch and a production branch. I push changes from my development server to a remote gitlab install. Then I login to gitlab GUI and do a merge request (which is quite time consuming). Then I \"git pull origin production\" from my production server.\nThe merge request step kind of takes a long time to do. Is there a faster way to do this? Could I just make a bash/shell script to merge development into production and pull down the updates with one command? If so what commands is this merge request running? \nI make merge requests a couple times a day. Anything to speed up the process I have would be great."
},
{
"role": "assistant",
"content": "You can merge changes without going through a UI - this is one of the core functionalities of Git. Assuming you have two branches (development and production), here's how you would merge changes:\n# Check out development branch\ngit checkout development\n\n# Make changes, commit...\n...\n\n# Optional: Push development changes to the remote\ngit push origin development\n\n# Check out production branch\ngit checkout production\n\n# Merge the changes from the development branch\ngit merge development\n\n# Push the changes to the remote\ngit push origin production\n\n# Check out the development branch again\ngit checkout development\n\nNow log into the production server and pull the changes there.\nYou could of course put the above checkout/merge/push steps into a script - that's quite common to do.\nThere are ways to automatically pull changes when something changes. Here are a couple of links for you:\n\nGit: auto pull from repository?\nhttps://johnflynn.me/autodeploy-your-gitlab-projects/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to keep a branch synchronized/updated with master?\nAt the moment git is doing my head in, I cannot come up with the best solution for the following.\nThere are two branches, one called master and one called mobiledevicesupport. I want to keep mobiledevicesupport as a continuous branch that will be merged/synced with the master branch whenever mobiledevicesupport is stable. This would merge changes from mobiledevicesupport into master but also bring all the changes from master into mobiledevicesupport so that branch can continue to be worked on and the features improved or amended. This needs to work with a central repository and multiple developers.\nPlease an example of similar workflows other people use or just tell me if this idea is stupid and I should consider other options. At the moment the workflow seems sound, but I just don't know how I can make git work this way.\nThanks, all help much appreciated.\nUpdate 1:\nIf I was to merge master into mobiledevicesupport and mobiledevice support into master, do I get replicated commits across both branches. Or is git smart enough to work out that I have pulled the latest changes from branch A into branch B and add merge commit C to branch B. And I have pulled the latest changes from branch B into branch A and add merge commit D to branch A?\nI was going to post an image but I don't have enough reputation for it, so I guess the following illustration will have to do. Two branches continuously running with merges going both directions often. The key thing I am not sure about is how git will play out the commits and will it fill either branch with the commits from the other branch on merges or will it stay clean. I have used rebase before but it seems to end the branch and put all the commits into the master, or I did it wrong. Thanks for the help so far.\nmaster\nA--B--C-----H--I--J--M--N\n \\ / \\\nmobile \\ / \\\nD--E--F--G--------K--L"
},
{
"role": "assistant",
"content": "Yes, just do:\ngit checkout master\ngit pull\ngit checkout mobiledevicesupport\ngit merge master\n\nto keep mobiledevicesupport in sync with master.\nThen, when you're ready to put mobiledevicesupport into master, first, merge in master like above, then:\ngit checkout master\ngit merge mobiledevicesupport\ngit push origin master\n\nand that's it.\nThe assumption here is that mobilexxx is a topic branch with work that isn't ready to go into your main branch yet. So only merge into master when mobiledevicesupport is in a good place."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do i delete the last 3 commits?\nHow do i delete the last 3 commits? there is probably many examples but I think i ma being very specific here with what I want.\nSo for example I have done a git add . and git commit -m \"message\" and a git push -u origin master for all these.\nI have the following output from all my commits(with 21 being the most recent commit)\n$git log --pretty=oneline\n[[33mab18ba3884244e99d99122e788062b2aaf6ba372[[m commit-21\n[[33m9625c19e03a747457162d7c0274d75b154a0b926[[m commit-20\n[[33m8668df12af9eee540cc29f9deb6d31d873bb8f24[[m commit-19\n[[33m8315cd7962c902d39160fcf2fd018f249e7cf744[[m commit-18\n[[33m3bcecc602a70fb60324777831d51c81b6f9ccaa7[[m commit-17\n[[33m0485a39c37e72eabb4003e07a6b8cbae7a0d4e25[[m commit-16\n[[33m9d3b04a7bcbb82be8b6b7882511f8133745c93b6[[m commit-15\n[[33m22c259497571390fdd1461f0dd6b77244851984b[[m commit-14\n[[33m39fb965fc245be55bb86491b5871dd2def08fdf4[[m commit-13\n[[33m299f6bb77e922d707c9981a48d4d75f57b724719[[m commit-12\n[[33me7285377d7afc08c7a5fb0ca44154d2de7e1d275[[m commit-11\n[[33mb3360786ef13044d13b6e58c2239cce5595a1abf[[m commit-10\n[[33m9af4c134e0d239d1c34fc6bb6087f0473c187fd5[[m commit-9\n[[33md55ac3370f506a4bbf8a4690b9285e5de9c6a671[[m commit-8\n[[33me50ef5f58b18d05c36343114804d8be180d26bcb[[m commit-7\n[[33m962e4a8de7649e06df29f9058a600f8318caf023[[m commit-6\n[[33m37f5363f62a3f973fe6e0d516e47b4324186d998[[m commit-5\n[[33m0033e32339e4dc0cce8bd208d43b18a4e9ab43d9[[m commit-4\n[[33m345239c740a408826f1df0dc5592d5d6b355f019[[m commit-3\n[[33m8c85bf2592f52302ff389a5b6af4127fbe04c73b[[m commit-2\n[[33ma4077b6c2b6a491af72ae3afc3b5c6260090b605[[m commit-1\n\nWhat I want to do is effectively delete the last 3 commits and end up with this:(So it was like git commit 19, 20 and 21 never happened)\n$git log --pretty=oneline\n[[33m8315cd7962c902d39160fcf2fd018f249e7cf744[[m commit-18\n[[33m3bcecc602a70fb60324777831d51c81b6f9ccaa7[[m commit-17\n[[33m0485a39c37e72eabb4003e07a6b8cbae7a0d4e25[[m commit-16\n[[33m9d3b04a7bcbb82be8b6b7882511f8133745c93b6[[m commit-15\n[[33m22c259497571390fdd1461f0dd6b77244851984b[[m commit-14\n[[33m39fb965fc245be55bb86491b5871dd2def08fdf4[[m commit-13\n[[33m299f6bb77e922d707c9981a48d4d75f57b724719[[m commit-12\n[[33me7285377d7afc08c7a5fb0ca44154d2de7e1d275[[m commit-11\n[[33mb3360786ef13044d13b6e58c2239cce5595a1abf[[m commit-10\n[[33m9af4c134e0d239d1c34fc6bb6087f0473c187fd5[[m commit-9\n[[33md55ac3370f506a4bbf8a4690b9285e5de9c6a671[[m commit-8\n[[33me50ef5f58b18d05c36343114804d8be180d26bcb[[m commit-7\n[[33m962e4a8de7649e06df29f9058a600f8318caf023[[m commit-6\n[[33m37f5363f62a3f973fe6e0d516e47b4324186d998[[m commit-5\n[[33m0033e32339e4dc0cce8bd208d43b18a4e9ab43d9[[m commit-4\n[[33m345239c740a408826f1df0dc5592d5d6b355f019[[m commit-3\n[[33m8c85bf2592f52302ff389a5b6af4127fbe04c73b[[m commit-2\n[[33ma4077b6c2b6a491af72ae3afc3b5c6260090b605[[m commit-1\n\nNote:\nI have looked into this and can't quiet get what I want. I have tried git revert(this is advise if I have published which I presume is the same as git push -u origin master) git rebase git reset\nI am not concerned with my remote at this stage I jsut want to get my local repo put back a couple of repos."
},
{
"role": "assistant",
"content": "use can use git reset for that\ngit reset --hard HEAD~3\n\ngit push --force origin master\n\nwhere HEAD~3 means go back 3 commits\nYou can also use the commit number instead of 3 commits, so that you are sure where you are going back in time, like\ngit reset --hard 8315cd7962c902d39160fcf2fd018f249e7cf744\n\nEDIT:\nWhen rewriting history, prefer using \ngit push origin +master\n\nTo be safe if you are ever pushing more than one branch. You can read more at Git Force push syntax, \"-f\" versus \"+branch\"\n(kudor to Josef Kufner comment pointing it out)\nEDIT 2:\nI just noticed that your log is printing colors as codes, So \ngit reset -- hard 33m8315cd7962c902d39160fcf2fd018f249e7cf744 \n\nwill not work, [[33m and [[m are color codes! So your commit number is actually 8315cd7962c902d39160fcf2fd018f249e7cf744 \nIf you do \ngit reset --hard 8315cd7962c902d39160fcf2fd018f249e7cf744\n\nit should work as well.\n(Fixed the commit code on previous examples as well)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options color.decorate.<slot>"
},
{
"role": "assistant",
"content": "Use customized color for git log --decorate output. <slot> is one\nof branch , remoteBranch , tag , stash or HEAD for local\nbranches, remote-tracking branches, tags, stash and HEAD, respectively\nand grafted for grafted commits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-notes - Add or inspect object notes -v --verbose"
},
{
"role": "assistant",
"content": "When merging notes, be more verbose.\nWhen pruning notes, report all object names whose notes are\nremoved."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to cancel previous runs in the PR when you push new commits(update the current) in github-actions\n\nWhen I push my commits to a PR my tests are triggered for this commit. After that, if I push additional commits to this PR, tests in Github Actions runs on both commits.\nI need to cancel the previous run and run only on the most recent pushed commit.\nHow can I configure my yaml file to achieve that?"
},
{
"role": "assistant",
"content": "To cancel a currently running workflow from the same PR, branch or tag when a new workflow is triggered you can use:\nname: Workflow X\n\non: # ...\n\nconcurrency:\n group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}\n cancel-in-progress: true\n\njobs: # ...\n\nExplanation:\n\n${{ github.workflow }}: the workflow name is used to generate the concurrency group (e.g. Workflow 1). That allows you to have more than one different workflow (eg. workflow1.yaml and workflow2.yaml) triggered on the same event (e.g. a PR). Otherwise, workflow1.yaml would cancel workflow2.yaml or viceversa.\n${{ github.event.pull_request.number: when the trigger event is a PR, it will use the PR number to generate the concurrency group (e.g. workflow1-33).\n|| github.ref }}: when the trigger is not a PR but a push, it will use the branch or tag name to generate the concurrency group (e.g. workflow1-branch1).\ncancel-in-progress: true: if cancel-in-progress is omitted or set to false, when a new workflow is triggered, the currently running workflow won't be cancelled, and the new workflow will be queued pending until the previous one is done.\n\nRef: https://docs.github.com/en/actions/using-jobs/using-concurrency"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to list only the names of files that changed between two commits\nI have a bunch of commits in the repository. I want to see a list of files changed between two commits - from SHA1 to SHA2.\nWhat command should I use?"
},
{
"role": "assistant",
"content": "git diff --name-only SHA1 SHA2\n\nwhere you only need to include enough of the SHA hash to identify the commits. The order of the SHAs does not matter. The output (which includes the relative path, not just the file name) follows this format:\n dir 1/dir 2/filename.ext\n dir 3/dir 4/other filename.ext\n\nYou can also do, for example\ngit diff --name-only HEAD~10 HEAD~5\n\nto see the differences between the tenth latest commit and the fifth latest (or so)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_TRACE_REFS"
},
{
"role": "assistant",
"content": "Enables trace messages for operations on the ref database.\nSee GIT_TRACE for available trace output options."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does it mean to fork on GitHub?\n\nAfter few explorations, In my understanding, it is related to contribution.\nFork means to make a copy of the repository (the one being forked) into my own github account.\nIf I want to fork the official jQuery repository, then I would go to https://github.com/jquery/jquery and hit the \"Fork\" button and GitHub will copy the repository (jquery) to my account (http://github.com/sanjaykhadka). Then a copied version of that repository will be available to me at http://github.com/sanjaykhadka/jquery\nNow I can make whatever the changes I wish to make to my repository and then send a pull request to the original repository (jQuery's repository), asking the jQuery team to merge my changes into their original repository.\nDid I understand it properly, or does it mean something more or something else?"
},
{
"role": "assistant",
"content": "Yes, you are absolutely right. When i teach others GitHub, i would like to explain the concept via an example. Lets take a scenario in which the teacher is conducting an MCQ in his class. He usually make copy of the question paper and distribute it (Forking) to his students so that they can work on it and mark the correct answer. The teacher still has the master copy. On the completion of the test he can collect the copies from students so that he can assess it(Pull request).\nSimply just like it. Forking is a concept of making copy of the main repository to your account so that you can make modifications in it. You can Submit pull request to the main repository with the modifications. It will make sure that the main repository is prevented from unwanted changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Merge git repository in subdirectory\nI'd like to merge a remote git repository in my working git repository as a subdirectory of it. I'd like the resulting repository to contain the merged history of the two repositories and also that each file of the merged-in repository retain its history as it was in the remote repository. I tried using the subtree strategy as mentioned in How to use the subtree merge strategy, but after following that procedure, although the resulting repository contains indeed the merged history of the two repositories, individual files coming from the remote one haven't retained their history (`git log' on any of them just shows a message \"Merged branch...\").\nAlso I don't want to use submodules because I do not want the two combined git repositories to be separate anymore.\nIs it possible to merge a remote git repository in another one as a subdirectory with individual files coming from the remote repository retaining their history?\nThanks very much for any help.\nEDIT:\nI'm currently trying out a solution that uses git filter-branch to rewrite the merged-in repository history. It does seem to work, but I need to test it some more. I'll return to report on my findings.\nEDIT 2:\nIn hope I make myself more clear I give the exact commands I used with git's subtree strategy, which result in apparent loss of history of the files of the remote repository.\nLet A be the git repo I'm currently working in and B the git repo I'd like to incorporate into A as a subdirectory of it. It did the following:\ngit remote add -f B <url-of-B>\ngit merge -s ours --no-commit B/master\ngit read-tree --prefix=subdir/Iwant/to/put/B/in/ -u B/master\ngit commit -m \"Merge B as subdirectory in subdir/Iwant/to/put/B/in.\"\n\nAfter these commands and going into directory subdir/Iwant/to/put/B/in, I see all files of B, but git log on any one of them shows just the commit message \"Merge B as subdirectory in subdir/Iwant/to/put/B/in.\" Their file history as it is in B is lost.\nWhat seems to work (since I'm a beginner on git I may be wrong) is the following:\ngit remote add -f B <url-of-B>\ngit checkout -b B_branch B/master # make a local branch following B's master\ngit filter-branch --index-filter \\ \n 'git ls-files -s | sed \"s-\\t\\\"*-&subdir/Iwant/to/put/B/in/-\" |\n GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n git update-index --index-info &&\n mv \"$GIT_INDEX_FILE.new\" \"$GIT_INDEX_FILE\"' HEAD \ngit checkout master\ngit merge B_branch\n\nThe command above for filter-branch is taken from git help filter-branch, in which I only changed the subdir path."
},
{
"role": "assistant",
"content": "git-subtree is a script designed for exactly this use case of merging multiple repositories into one while preserving history (and/or splitting history of subtrees, though that is seems to be irrelevant to this question). It is distributed as part of the git tree since release 1.7.11.\nTo merge a repository <repo> at revision <rev> as subdirectory <prefix>, use git subtree add as follows:\ngit subtree add -P <prefix> <repo> <rev>\n\ngit-subtree implements the subtree merge strategy in a more user friendly manner.\nThe downside is that in the merged history the files are unprefixed (not in a subdirectory). Say you merge repository a into b. As a result git log a/f1 will show you all the changes (if any) except those in the merged history. You can do:\ngit log --follow -- f1\n\nbut that won't show the changes other then in the merged history.\nIn other words, if you don't change a's files in repository b, then you need to specify --follow and an unprefixed path. If you change them in both repositories, then you have 2 commands, none of which shows all the changes.\nMore on it here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker --literal-pathspecs"
},
{
"role": "assistant",
"content": "Treat pathspecs literally (i.e. no globbing, no pathspec magic).\nThis is equivalent to setting the GIT_LITERAL_PATHSPECS environment\nvariable to 1 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-for-each-ref - Output information on each ref signature:grade"
},
{
"role": "assistant",
"content": "Show \"G\" for a good (valid) signature, \"B\" for a bad\nsignature, \"U\" for a good signature with unknown validity, \"X\"\nfor a good signature that has expired, \"Y\" for a good\nsignature made by an expired key, \"R\" for a good signature\nmade by a revoked key, \"E\" if the signature cannot be\nchecked (e.g. missing key) and \"N\" for no signature."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does the exclamation mark mean in git config alias?\nI just see a git config command as below:\ngit config --global alias.out \\!\"git fetch; git cherry origin/HEAD -v\"\n\nwhat does it mean? Is it equal to this:\ngit config --global alias.out '!git fetch; git cherry origin/HEAD -v',\n\nI am confused with the exclamation mark,any help will be appreciated."
},
{
"role": "assistant",
"content": "From the git-config manual:\n\nIf the alias expansion is prefixed with an exclamation point, it will be treated as a shell \n command."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-bugreport"
},
{
"role": "assistant",
"content": "Collect information for user to file a bug report"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options statusUoption"
},
{
"role": "assistant",
"content": "Shown when git-status takes more than 2\nseconds to enumerate untracked files, to tell the user that\nthey can use the -u option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Checkout subdirectories in Git?\nIs it possible to check out subdirectories of a repository in Git?\nImagine I am setting up a new WordPress installation. I will create two new directories for my plugin and theme customization:\n\nwordpress/wp-content/plugins/myplugins/ \nwordpress/wp-content/themes/mytheme/\n\nI want to maintain these directories via Git. In Subversion, I would accomplish this by having trunk/myplugins/ and trunk/mytheme/ directories and checking out subdirectories. Does Git have a way to accomplish the same task using a single repository?\nI could just be missing the boat on some Git paradigm, as a long time SVN user with little exposure to Git.\nEdit: Multiple branches storing different content is an interesting way to handle this."
},
{
"role": "assistant",
"content": "Sparse checkouts are now in Git 1.7.\nAlso see the question “Is it possible to do a sparse checkout without checking out the whole repository first?”.\nNote that sparse checkouts still require you to download the whole repository, even though some of the files Git downloads won't end up in your working tree."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git stash pop- needs merge, unable to refresh index\nI can't pop my stash because I merged a branch which apparently conflicts with my stash and now my stash is seemingly unable to be popped.\napp.coffee: needs merge\nunable to refresh index\n\nAnyone know how to resolve this?"
},
{
"role": "assistant",
"content": "First, check git status.\nAs the OP mentions,\n\nThe actual issue was an unresolved merge conflict from the merge, NOT that the stash would cause a merge conflict.\n\nThat is where git status would mention that file as being \"both modified\"\n\nResolution: Commit the conflicted file.\n\n\nSolution: in this case, simply add and commit your local file.\nActually, just git add -- yourFile, or (if you don't want those changes) git reset -- yourFile (to unstage it) is enough to get past the error message.\nIf you do not want to commit, just git add yourFile is enough.\nYou can then git stash the rest if you want.\n\nYou can find a similar situation 4 days ago at the time of writing this answer (March 13th, 2012) with this post: \"‘Pull is not possible because you have unmerged files’\":\njulita@yulys:~/GNOME/baobab/help/C$ git stash pop\nhelp/C/scan-remote.page: needs merge\nunable to refresh index\n\nWhat you did was to fix the merge conflict (editing the right file, and committing it):\nSee \"How do I fix merge conflicts in Git?\"\nWhat the blog post's author did was:\njulita@yulys:~/GNOME/baobab/help/C$ git reset --hard origin/mallard-documentation\nHEAD is now at ff2e1e2 Add more steps for optional information for scanning.\n\nI.e. aborting the current merge completely, allowing the git stash pop to be applied.\nSee \"Aborting a merge in Git\".\nThose are your two options."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git add and commit in one command\nIs there any way I can do\ngit add -A\ngit commit -m \"commit message\"\n\nin one command? \nI seem to be doing those two commands a lot, and if Git had an option like git commit -Am \"commit message\", it would make life that much more convenient.\ngit commit has the -a modifier, but it doesn't quite do the same as doing git add -A before committing. git add -A adds newly created files, but git commit -am does not. What does?"
},
{
"role": "assistant",
"content": "You can use git aliases, e.g.\ngit config --global alias.add-commit '!git add -A && git commit'\n\nand use it with\ngit add-commit -m 'My commit message'\n\n\nEDIT: Reverted back to ticks ('), as otherwise it will fail for shell expansion on Linux. On Windows, one should use double-quotes (\") instead (pointed out in the comments, did not verify)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Reapply a commit that was undone by conflict?\nI have this commit that was undone by someone who doesn't know how to deal with conflicts. Is there an easy way to try auto merging the commit back in? I tried using \"merge to master\" but it just says up to date. I am using tortoisegit."
},
{
"role": "assistant",
"content": "That's what git cherry-pick is for. It lets you apply changes by using already existing commits.\nThe basic syntax is:\ngit cherry-pick <commit> ..."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": ".gitignore a folder content [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 11 years ago.\nThe community reviewed whether to reopen this question 2 years ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\nPossible Duplicate:\nIgnoring directories in Git repos on Windows \n\nMy web app has the following directory layout:\nmyapp/\n .gitignore\n .git/\n ...\n\n static/\n mytest.txt\n fgs.ico\n ledgerware/\n static/\n mytest.txt\n fgs.ico\n ...\n\nI'd like to edit existing myapp/.gitignore file so that when git push it ignores all files inside myapp/ledgerware/static folder, but NOT myapp/static folder. Can someone help me with this?"
},
{
"role": "assistant",
"content": "Just make the line in .gitignore as specific as you want it to be:\nledgerware/static/*"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-svn - Bidirectional operation between a Subversion repository and Git --localtime"
},
{
"role": "assistant",
"content": "Store Git commit times in the local time zone instead of UTC. This\nmakes git log (even without --date=local) show the same times\nthat svn log would in the local time zone. This doesn’t interfere with interoperating with the Subversion\nrepository you cloned from, but if you wish for your local Git\nrepository to be able to interoperate with someone else’s local Git\nrepository, either don’t use this option or you should both use it in\nthe same local time zone."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-reflog - Manage reflog information"
},
{
"role": "assistant",
"content": "SYNOPSIS git reflog [show] [<log-options>] [<ref>] git reflog list git reflog expire [--expire=<time>] [--expire-unreachable=<time>]\n\t[--rewrite] [--updateref] [--stale-fix]\n\t[--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>…] git reflog delete [--rewrite] [--updateref]\n\t[--dry-run | -n] [--verbose] <ref>@{<specifier>}… git reflog exists <ref>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitattributes - Defining attributes per path Unset"
},
{
"role": "assistant",
"content": "Do not notice anything as error."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-grep - Print lines matching a pattern -P --perl-regexp"
},
{
"role": "assistant",
"content": "Use Perl-compatible regular expressions for patterns. Support for these types of regular expressions is an optional\ncompile-time dependency. If Git wasn’t compiled with support for them\nproviding this option will cause it to die."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --ignore-submodules[=<when>]"
},
{
"role": "assistant",
"content": "Ignore changes to submodules in the diff generation. <when> can be\neither \"none\", \"untracked\", \"dirty\" or \"all\", which is the default.\nUsing \"none\" will consider the submodule modified when it either contains\nuntracked or modified files or its HEAD differs from the commit recorded\nin the superproject and can be used to override any settings of the ignore option in git-config or gitmodules . When\n\"untracked\" is used submodules are not considered dirty when they only\ncontain untracked content (but they are still scanned for modified\ncontent). Using \"dirty\" ignores all changes to the work tree of submodules,\nonly changes to the commits stored in the superproject are shown (this was\nthe behavior until 1.7.0). Using \"all\" hides all changes to submodules."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to run stash in Github Desktop?\nHow do you run stash in GitHub Desktop on Windows?\nThe feature is available in Sourcetree but I'm unable to find it in GitHub Desktop."
},
{
"role": "assistant",
"content": "GitHub Desktop for Windows doesn't support stash. The only stash-like feature it has is that it will allow you to switch branches if you have uncommited changes. Source\nUpdate: GitHub Desktop V2.0.0 now supports stash (Issue 6107). Now when switching branches, you'll be prompted to either leave your changes on the current branch (stash) or bring your changes over to the other branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Shell script to check if specified Git branch exists? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nIs there a better way to find out if a local git branch exists?\n\n (18 answers)\n \n\nClosed 10 years ago.\n\n\n\nI need to create a Git branch using shell script, but since the branch may exist, I need to be aware of that. Currently I'm using:\nif [ `git branch | grep $branch_name` ]\nthen\n echo \"Branch named $branch_name already exists\"\nelse\n echo \"Branch named $branch_name does not exist\"\nfi\n\nBut the problem is the grep command finds branch name without matching the exact name, that is, if I grep name then branch with a name branch-name would be matched.\nSo is there a better way to do this?\nThanks!"
},
{
"role": "assistant",
"content": "NOTE: This always returns true. This is not the right answer to the question, even though it has been accepted....\nYou could always use word boundaries around the name like \\< and \\>, but instead let Git do the work for you:\nif [ `git branch --list $branch_name` ]\nthen\n echo \"Branch name $branch_name already exists.\"\nfi"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options notes.<name>.mergeStrategy"
},
{
"role": "assistant",
"content": "Which merge strategy to choose when doing a notes merge into\nrefs/notes/<name>. This overrides the more general\n\"notes.mergeStrategy\". See the \"NOTES MERGE STRATEGIES\" section in git-notes for more information on the available strategies."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --anchored=<text>"
},
{
"role": "assistant",
"content": "Generate a diff using the \"anchored diff\" algorithm. This option may be specified more than once. If a line exists in both the source and destination, exists only once,\nand starts with this text, this algorithm attempts to prevent it from\nappearing as a deletion or addition in the output. It uses the \"patience\ndiff\" algorithm internally."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --first-parent"
},
{
"role": "assistant",
"content": "When finding commits to include, follow only the first\nparent commit upon seeing a merge commit. This option\ncan give a better overview when viewing the evolution of\na particular topic branch, because merges into a topic\nbranch tend to be only about adjusting to updated upstream\nfrom time to time, and this option allows you to ignore\nthe individual commits brought in to your history by such\na merge. This option also changes default diff format for merge commits\nto first-parent , see --diff-merges=first-parent for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Whole team gets 'too many unreachable loose objects' messages\nNot long ago, we have made the switch from SVN to Git.\nA few days ago, I realized that all of our team gets those messages when they push :\n$ git push\nCounting objects: 32, done.\nDelta compression using up to 8 threads.\nCompressing objects: 100% (19/19), done.\nWriting objects: 100% (32/32), 2.94 KiB | 0 bytes/s, done.\nTotal 32 (delta 14), reused 0 (delta 0)\nerror: The last gc run reported the following. Please correct the root cause\nand remove gc.log.\nAutomatic cleanup will not be performed until the file is removed.\n\nwarning: There are too many unreachable loose objects; run 'git prune' to remove them.\n\nTo [email protected]:root/xxx.git\n 15c3bbb..69e6d8b xxxx -> xxx\n\nI thought it was coming from my computer for a while, until I realize that everybody has the same issues.\nNeedless to say, there is no gc.log in my .git folder, and using 'git gc' or 'git prune' has no effect.\nSo my question is : Could it be that the repository hosted on the server is somehow not clean? If so, how to I actually clean it?\nAll of the solutions I have found so far relate to local copies of repositories.\nAlso, we use Gitlab to host our repos.\nEDIT : It is worth saying that I have since I posted this question also tried \"Housecleaning\" the repository using Gitlab but with no result so far."
},
{
"role": "assistant",
"content": "This is followed by issue 14357 (GitLab 8.6- or less)\nThe manual fix was:\n\nSSH into worker1\ncd into the gitlab-org/gitlab-ce directory\nran rm gc.log, this just contained the line \" warning: There are too many unreachable loose objects; run 'git prune' to remove them.\"\nran git prune and prayed it didn't break things (which it thankfully didn't)\n\nBut it looks like, starting GitLab 8.7, auto gc is disabled.\nThis is also done in the context of (still opened) issue 13524:\n\nTypically after a rebase, amend or other action that requires a force push we can have dangled commits.\nSuch \"dereferenced\" commits are getting lost due to git gc that may be executed internally or by using GitLab Housekeeping features.\nIf it happens that there was a discussion attached to a specific commit - it is not available after dereferenced commit has been garbage-collected.\nCommits are being recorded in push events and are available through system notes added to merge request, and currently this produces error 500 in GitLab.\n\nUpdate: that issue was closed a month later (July 2016) with:\n\nMR 5062: Don't garbage collect commits that have related DB records like comments\n\n\nMakes sure a commit is kept around when Git garbage collection runs.\nGit GC will delete commits from the repository that are no longer in any branches or tags, but we want to keep some of these commits around, for example if they have comments or CI builds.\n\n\nMR 4101: Refactor: Convert existing array-based diff refs to the DiffRefs model"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index none"
},
{
"role": "assistant",
"content": "Disable word diff again."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary ref"
},
{
"role": "assistant",
"content": "A name that begins with refs/ (e.g. refs/heads/master )\nthat points to an object name or another\nref (the latter is called a symbolic ref ).\nFor convenience, a ref can sometimes be abbreviated when used\nas an argument to a Git command; see gitrevisions for details.\nRefs are stored in the repository . The ref namespace is hierarchical.\nDifferent subhierarchies are used for different purposes (e.g. the refs/heads/ hierarchy is used to represent local branches). There are a few special-purpose refs that do not begin with refs/ .\nThe most notable example is HEAD ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Command to get/clone a fetch/pull/read -only copy of a git repository?\n\nHere's a git repository on github:\n\ngit://github.com/Fudge/gltail.git\n\nWhat's the simplest way to check out a read-only copy using the git command line tool?\nupdate: Here's a suggestion to the githubbers: Do something similar to google code, which automatically displays a message such as:\nUse this command to anonymously check out the latest project source code:\n # Non-members may check out a read-only working copy anonymously over HTTP.\n svn checkout http://orapig.googlecode.com/svn/trunk/ orapig-read-only\n\nupdate: The githubbers have done this."
},
{
"role": "assistant",
"content": "git clone git://github.com/Fudge/gltail.git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --no-abbrev-commit"
},
{
"role": "assistant",
"content": "Show the full 40-byte hexadecimal commit object name. This negates --abbrev-commit , either explicit or implied by other options such\nas \"--oneline\". It also overrides the log.abbrevCommit variable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --branches[=<pattern>]"
},
{
"role": "assistant",
"content": "Pretend as if all the refs in refs/heads are listed\non the command line as <commit> . If <pattern> is given, limit\nbranches to ones matching given shell glob. If pattern lacks ? , * , or [ , /* at the end is implied."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-daemon"
},
{
"role": "assistant",
"content": "A really simple server for Git repositories"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "fatal: Failed to resolve HEAD as a valid ref\nI am getting fatal: Failed to resolve HEAD as a valid ref. whenever I try to commit.\nI have tried\necho ref: refs/heads/master >.git/HEAD\n\nbut it's not working\nAlso tried\ngit commit\n\nit's not working either from below the sources.\nGit 'fatal: No such ref: HEAD'\ngit tag: fatal: Failed to resolve 'HEAD' as a valid ref\nPlease help. All my commit history is also gone."
},
{
"role": "assistant",
"content": "I have also encountered the same issue, and have resolved it as follows:\n\nClone your same project in some other folder.\nCopy the (hidden) .git folder of the cloned project.\nFinally replace the .git folder of the original project with the one that you've have copied.\n\nEdit\nWhy does this happen?\n\nBroken git repositories are often the result of file system corruption due to abrupt power failure or other abnormalities.\nSince git stores all the information inside .git folder and if they are corrupted git can no longer recognize the repository.\n\nCaveats\nEverything in your previous .git folder will be gone. Configurations like remote reference name(s) must be set up again."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to install latest version of git on CentOS 8.x/7.x/6.x\nI used the usual: \nyum install git\n\nIt did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer versions of CentOS such as CentOS 7."
},
{
"role": "assistant",
"content": "You can use WANDisco's CentOS repository to install Git 2.x: for CentOS 6, for CentOS 7\n\nInstall WANDisco repo package:\nyum install http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm\n- or -\nyum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm\n- or -\nyum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm\n\nInstall the latest version of Git 2.x:\nyum install git\n\nVerify the version of Git that was installed:\ngit --version\n\n\nAs of 02 Mar. 2020, the latest available version from WANDisco is 2.22.0."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to list all tags pointing to a specific commit in git\nI have seen the commands git describe and git-name-rev but I have not managed to get them to list more than one tag.\nExample: I have the sha1 48eb354 and I know the tags A and B point to it. So I want a git command git {something} 48eb354 that produce output similar to \"A, B\". I am not interested in knowing references relative other tags or branches just exact matches for tags."
},
{
"role": "assistant",
"content": "git tag --points-at HEAD\nShows all tags at HEAD, you can also substitute HEAD with any sha1 id."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch <refspec>"
},
{
"role": "assistant",
"content": "Specifies which refs to fetch and which local refs to update.\nWhen no <refspec>s appear on the command line, the refs to fetch\nare read from remote.<repository>.fetch variables instead\n(see the section \"CONFIGURED REMOTE-TRACKING BRANCHES\"\nin git-fetch ). The format of a <refspec> parameter is an optional plus + , followed by the source <src>, followed\nby a colon : , followed by the destination ref <dst>.\nThe colon can be omitted when <dst> is empty. <src> is\ntypically a ref, but it can also be a fully spelled hex object\nname. A <refspec> may contain a * in its <src> to indicate a simple pattern\nmatch. Such a refspec functions like a glob that matches any ref with the\nsame prefix. A pattern <refspec> must have a * in both the <src> and\n<dst>. It will map refs to the destination by replacing the * with the\ncontents matched from the source. If a refspec is prefixed by ^ , it will be interpreted as a negative\nrefspec. Rather than specifying which refs to fetch or which local refs to\nupdate, such a refspec will instead specify refs to exclude. A ref will be\nconsidered to match if it matches at least one positive refspec, and does\nnot match any negative refspec. Negative refspecs can be useful to restrict\nthe scope of a pattern refspec so that it will not include specific refs.\nNegative refspecs can themselves be pattern refspecs. However, they may only\ncontain a <src> and do not specify a <dst>. Fully spelled out hex object\nnames are also not supported. tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag> ;\nit requests fetching everything up to the given tag. The remote ref that matches <src>\nis fetched, and if <dst> is not an empty string, an attempt\nis made to update the local ref that matches it. Whether that update is allowed without --force depends on the ref\nnamespace it’s being fetched to, the type of object being fetched, and\nwhether the update is considered to be a fast-forward. Generally, the\nsame rules apply for fetching as when pushing, see the <refspec>... section of git-push for what those are. Exceptions to those\nrules particular to git fetch are noted below. Until Git version 2.20, and unlike when pushing with git-push , any updates to refs/tags/* would be accepted\nwithout + in the refspec (or --force ). When fetching, we promiscuously\nconsidered all tag updates from a remote to be forced fetches. Since\nGit version 2.20, fetching to update refs/tags/* works the same way\nas when pushing. I.e. any updates will be rejected without + in the\nrefspec (or --force ). Unlike when pushing with git-push , any updates outside of refs/{tags,heads}/* will be accepted without + in the refspec (or --force ), whether that’s swapping e.g. a tree object for a blob, or\na commit for another commit that doesn’t have the previous commit as\nan ancestor etc. Unlike when pushing with git-push , there is no\nconfiguration which’ll amend these rules, and nothing like a pre-fetch hook analogous to the pre-receive hook. As with pushing with git-push , all of the rules described\nabove about what’s not allowed as an update can be overridden by\nadding an optional leading + to a refspec (or using the --force command line option). The only exception to this is that no amount of\nforcing will make the refs/heads/* namespace accept a non-commit\nobject. Note When the remote branch you want to fetch is known to\nbe rewound and rebased regularly, it is expected that\nits new tip will not be a descendant of its previous tip\n(as stored in your remote-tracking branch the last time\nyou fetched). You would want\nto use the + sign to indicate non-fast-forward updates\nwill be needed for such branches. There is no way to\ndetermine or declare that a branch will be made available\nin a repository with this behavior; the pulling user simply\nmust know this is the expected usage pattern for a branch. Note There is a difference between listing multiple <refspec>\ndirectly on git pull command line and having multiple remote.<repository>.fetch entries in your configuration\nfor a <repository> and running a git pull command without any explicit <refspec> parameters.\n<refspec>s listed explicitly on the command line are always\nmerged into the current branch after fetching. In other words,\nif you list more than one remote ref, git pull will create\nan Octopus merge. On the other hand, if you do not list any\nexplicit <refspec> parameter on the command line, git pull will fetch all the <refspec>s it finds in the remote.<repository>.fetch configuration and merge\nonly the first <refspec> found into the current branch.\nThis is because making an\nOctopus from remote refs is rarely done, while keeping track\nof multiple remote heads in one-go by fetching more than one\nis often useful."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to remove git account from local machine and add new account\n\nI have a github account which is configured in my windows pc. Now I have created a new Github account and want to use the new one.\nHow will I remove my old account from my windows pc and add the new github account ?\nNOTE: I have edited the gitconfig file and added the new user email and username there. But the public key still contains the old user email !!"
},
{
"role": "assistant",
"content": "For windows machine\nyou can manage windows credential for doing this\ngo to search button then write\nmanage windows credential\nthen you will find a button double click it\nthen remove your current windows credential\nafter that when you are using git again git authentication will be asked\nthen you will enter your new github id\nNext you need to edit .gitconfig file\nfile path will be like\nC:\\Users\\Imu\n\nhere imu is my user name\nit will be different in yours\nNow edit .gitconfig file using text editor like nodepad++ or sublime text with ur current id information\nhoping it helps"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to configure Git post commit hook\nHow to trigger a build remotely from Jenkins?\nHow to configure Git post commit hook?\nMy requirement is whenever changes are made in the Git repository for a particular project it will automatically start Jenkins build for that project. \nIn Jenkins trigger build section I selected trigger build remotely.\nIn .git directory, hooks directory is there in that we have to configure post commit file.\nI am confusing how to trigger a build from there (I know some part we should use curl command).\n\ncurl cmbuild.aln.com/jenkins/view/project name/job/myproject/buildwithparameters?Branch=feat-con\n\nI have placed this command in my git server hooks directory (post commit hook).\nWhenever the changes happen in repository it is running automate build. \nI want to check in changeset whether in at least one java file is there the build should start.\nSuppose the developers changed only xml files or property files the build should not start.\nAlong with xml, suppose the .java files is there the build should start."
},
{
"role": "assistant",
"content": "As mentioned in \"Polling must die: triggering Jenkins builds from a git hook\", you can notify Jenkins of a new commit:\n\nWith the latest Git plugin 1.1.14 (that I just release now), you can now do this more >easily by simply executing the following command:\ncurl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>\n\nThis will scan all the jobs that’s configured to check out the specified URL, and if they are also configured with polling, it’ll immediately trigger the polling (and if that finds a change worth a build, a build will be triggered in turn.) \nThis allows a script to remain the same when jobs come and go in Jenkins.\n Or if you have multiple repositories under a single repository host application (such as Gitosis), you can share a single post-receive hook script with all the repositories. Finally, this URL doesn’t require authentication even for secured Jenkins, because the server doesn’t directly use anything that the client is sending. It runs polling to verify that there is a change, before it actually starts a build.\n\nAs mentioned here, make sure to use the right address for your Jenkins server:\n\nsince we're running Jenkins as standalone Webserver on port 8080 the URL should have been without the /jenkins, like this: \nhttp://jenkins:8080/git/notifyCommit?url=git@gitserver:tools/common.git\n\n\nTo reinforce that last point, ptha adds in the comments:\n\nIt may be obvious, but I had issues with: \ncurl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>. \n\nThe url parameter should match exactly what you have in Repository URL of your Jenkins job.\n When copying examples I left out the protocol, in our case ssh://, and it didn't work.\n\n\nYou can also use a simple post-receive hook like in \"Push based builds using Jenkins and GIT\"\n#!/bin/bash\n/usr/bin/curl --user USERNAME:PASS -s \\\n\nhttp://jenkinsci/job/PROJECTNAME/build?token=1qaz2wsx\n\n\nConfigure your Jenkins job to be able to “Trigger builds remotely” and use an authentication token (1qaz2wsx in this example).\n\nHowever, this is a project-specific script, and the author mentions a way to generalize it.\nThe first solution is easier as it doesn't depend on authentication or a specific project.\n\n\nI want to check in change set whether at least one java file is there the build should start.\n Suppose the developers changed only XML files or property files, then the build should not start. \n\nBasically, your build script can:\n\nput a 'build' notes (see git notes) on the first call\non the subsequent calls, grab the list of commits between HEAD of your branch candidate for build and the commit referenced by the git notes 'build' (git show refs/notes/build): git diff --name-only SHA_build HEAD.\nyour script can parse that list and decide if it needs to go on with the build. \nin any case, create/move your git notes 'build' to HEAD.\n\n\nMay 2016: cwhsu points out in the comments the following possible url:\n\nyou could just use curl --user USER:PWD http://JENKINS_SERVER/job/JOB_NAME/build?token=YOUR_TOKEN if you set trigger config in your item\n\n\n\nJune 2016, polaretto points out in the comments:\n\nI wanted to add that with just a little of shell scripting you can avoid manual url configuration, especially if you have many repositories under a common directory.\n For example I used these parameter expansions to get the repo name \nrepository=${PWD%/hooks}; \nrepository=${repository##*/} \n\nand then use it like:\ncurl $JENKINS_URL/git/notifyCommit?url=$GIT_URL/$repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is TortoiseGit ready for prime time yet? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 8 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI'm a big fan of the simplicity of TortoiseSVN. I also am interested in digging into git, and think it would make a good fit for an upcoming project. However, a strictly command-line based app can be a little intimidating. I've followed the TortoiseGit project for a little while, and it looks like they are past 1.0.\nIs there anyone using it in the wild right now? How's it working out? Does it let you use all of the features in git well?"
},
{
"role": "assistant",
"content": "YES, it's ready!\nTortoiseGit has come a long way since 2009.\nAnd now Microsoft Windows has the best graphical interface to git ;-)\nIt's especially nice for people that used TortoiseSVN, because it uses familiar dialogs and terminology. Like \"Revert..\" instead of \"Reset / Checkout\" or that it abstracts away the \"index\" in a single (commit) dialog.\nOf course there is still room for improvement, mainly because most commands are forwarded to the commandline version, which doesn't give an optimal visualisation."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-update-index - Register file contents in the working tree to the index --[no-]assume-unchanged"
},
{
"role": "assistant",
"content": "When this flag is specified, the object names recorded\nfor the paths are not updated. Instead, this option\nsets/unsets the \"assume unchanged\" bit for the\npaths. When the \"assume unchanged\" bit is on, the user\npromises not to change the file and allows Git to assume\nthat the working tree file matches what is recorded in\nthe index. If you want to change the working tree file,\nyou need to unset the bit to tell Git. This is\nsometimes helpful when working with a big project on a\nfilesystem that has a very slow lstat(2) system call\n(e.g. cifs). Git will fail (gracefully) in case it needs to modify this file\nin the index e.g. when merging in a commit;\nthus, in case the assumed-untracked file is changed upstream,\nyou will need to handle the situation manually."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --start-number <n>"
},
{
"role": "assistant",
"content": "Start numbering the patches at <n> instead of 1."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How often should you use git-gc?\nHow often should you use git-gc? \nThe manual page simply says:\n\nUsers are encouraged to run this task on a regular basis within each repository to maintain good disk space utilization and good operating performance.\n\nAre there some commands to get some object counts to find out whether it's time to gc?"
},
{
"role": "assistant",
"content": "It depends mostly on how much the repository is used. With one user checking in once a day and a branch/merge/etc operation once a week you probably don't need to run it more than once a year.\nWith several dozen developers working on several dozen projects each checking in 2-3 times a day, you might want to run it nightly.\nIt won't hurt to run it more frequently than needed, though.\nWhat I'd do is run it now, then a week from now take a measurement of disk utilization, run it again, and measure disk utilization again. If it drops 5% in size, then run it once a week. If it drops more, then run it more frequently. If it drops less, then run it less frequently."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.