messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --children"
},
{
"role": "assistant",
"content": "Print also the children of the commit (in the form \"commit child…\").\nAlso enables parent rewriting, see History Simplification above."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Difference between file in local repository and origin\nI want to find the differences between a file I have in my local repository vs. what is in the origin master.\nI know that there is git diff. However, I just want to isolate it down to this one particular file.\nFor simplicity, let’s say the file is named file1.txt and it has a local file path = [local_path] and in the origin it has filepath = [remote-path].\nWhat would be the Git command I need to type?\n\nFor those that are using Eclipse, I just found out that you can just right click → Compare With → Branch, Tag or Reference → select the appropriate version and there you go."
},
{
"role": "assistant",
"content": "If [remote-path] and [local-path] are the same, you can do\n$ git fetch origin master\n$ git diff origin/master -- [local-path]\n\nNote 1: The second command above will compare against the locally stored remote tracking branch. The fetch command is required to update the remote tracking branch to be in sync with the contents of the remote server. Alternatively, you can just do\n$ git diff master:<path-or-file-name>\n\nNote 2: master can be replaced in the above examples with any branch name"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --no-ext-diff"
},
{
"role": "assistant",
"content": "Disallow external diff drivers."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub pages only showing ReadMe file?\nI'm trying to host my webpages into Github pages but for some reason it seems to only show my Readme file.\nGitHub repo: https://github.com/InquisitiveDev2016/InquisitiveDev2016.github.io\nWebsite: \nhttps://inquisitivedev2016.github.io/"
},
{
"role": "assistant",
"content": "GitHub Pages is doing what it is designed to do: hosting the contents of that repository.\nThe root of the question asker's repository only contained a single file (README.md). So there isn't an easy way to navigate to the other pages, e.g. repo/website/webpage.html.\nConsider moving your web content into the root of your repository and renaming your default page to index.md or index.html, depending what type of file it is. (By convention the default page of most websites is called index.html, and this is what GitHub Pages will show by default if it exists.)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to stage only part of a new file with git?\nI love git add --interactive. It is now part of my daily workflow.\nThe problem seems that it does not work with untracked files. What I want to do is track a new file, but only add part of it, i.e. some parts of this new file are not yet ready to be staged. \nFor example, with git add -i, I can chose the patch option and even edit individual hunks in order to stage parts of the new code, leaving debug code comments unstaged. I love working this way because it makes it obvious which places of the mega patch I am currently working on still need work.\nUnfortunately, I don't seem to be able to do the same with an untracked file. Either I stage the whole file, or nothing. The workaround I have been using is staging or even committing a new file when it is empty, and then staging individual changes in the usual way. But this solution feels like a dirty hack and when I forget, or change my mind, it creates more troubles than there should be.\nSo the question is: How to stage only part of a new file, so that this new file gets tracked but leaving the whole or parts of its content unstaged?"
},
{
"role": "assistant",
"content": "Whoa, all that update-index and hash-object business seems overly complicated. How about this instead:\ngit add -N new_file\ngit add -i # or 'git add -p' if you prefer\n\nFrom git help add:\n-N, --intent-to-add\n Record only the fact that the path will be added later. An entry\n for the path is placed in the index with no content. This is useful\n for, among other things, showing the unstaged content of such files\n with git diff and committing them with git commit -a."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --no-color"
},
{
"role": "assistant",
"content": "Turn off colored diff.\nIt is the same as --color=never ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How does git detect similar files for its rename detection?\nWikipedia explains the automatic rename detection:\n\nBriefly, given a file in revision N, a file of the same name in\n revision N−1 is its default ancestor. However, when there is no\n like-named file in revision N−1, Git searches for a file that existed\n only in revision N−1 and is very similar to the new file.\n\nRename detection apparently boils down to similar file detection. Is that algorithm documented anywhere? It would be nice to know what kinds of transformations are detected automatically."
},
{
"role": "assistant",
"content": "Git tracks file contents, not filenames. So renaming a file without changing its content is easy for git to detect. (Git does not track, but performs detection; using git mv or git rm and git add is effectively the same.)\nWhen a file is added to the repository, the filename is in the tree object. The actual file contents are added as a binary large object (blob) in the repository. Git will not add another blob for additional files that contain the same content. In fact, Git cannot as the content is stored in the filesystem with first two characters of the hash being the directory name and the rest being the name of file within it. So to detect renames is a matter of comparing hashes.\nTo detect small changes to a renamed file, Git uses certain algorithms and a threshold limit to see if this is a rename. For example, have a look at the -M flag for git diff. There are also configuration values such as merge.renameLimit (the number of files to consider when performing rename detection during a merge).\nTo understand how git treats similar files (i.e., what file transformations are considered as renames), explore the configuration options and flags available, as mentioned above. You need not be considered with the how. To understand how git actually accomplishes these tasks, look at the algorithms for finding differences in text, and read the git source code.\nAlgorithms are applied only for diff, merge, and log purposes -- they do not affect how git stores them. Any small change in file content means a new object is added for it. There is no delta or diff happening at that level. Of course, later, the objects might be packed where deltas are stored in packfiles, but that is not related to the rename detection."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files <branch>"
},
{
"role": "assistant",
"content": "Branch to checkout; if it refers to a branch (i.e., a name that,\nwhen prepended with \"refs/heads/\", is a valid ref), then that\nbranch is checked out. Otherwise, if it refers to a valid\ncommit, your HEAD becomes \"detached\" and you are no longer on\nany branch (see below for details). You can use the @{-N} syntax to refer to the N-th last\nbranch/commit checked out using \"git checkout\" operation. You may\nalso specify - which is synonymous to @{-1} . As a special case, you may use A...B as a shortcut for the\nmerge base of A and B if there is exactly one merge base. You can\nleave out at most one of A and B , in which case it defaults to HEAD ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab Cloud: Can't unprotect branch in project I own\n\nI was surprised to find that I could not force push to the master branch of a project I own on GitLab.\nAlso, there seems to be no way in the web UI for me to unprotect the branch. \nHow would you address that issue?"
},
{
"role": "assistant",
"content": "You can protect and unprotect branches at Settings -> Repository -> Protected Branches"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options color.diff.<slot>"
},
{
"role": "assistant",
"content": "Use customized color for diff colorization. <slot> specifies\nwhich part of the patch to use the specified color, and is one\nof context (context text - plain is a historical synonym), meta (metainformation), frag (hunk header), func (function in hunk header), old (removed lines), new (added lines), commit (commit headers), whitespace (highlighting whitespace errors), oldMoved (deleted lines), newMoved (added lines), oldMovedDimmed , oldMovedAlternative , oldMovedAlternativeDimmed , newMovedDimmed , newMovedAlternative newMovedAlternativeDimmed (See the <mode> setting of --color-moved in git-diff for details), contextDimmed , oldDimmed , newDimmed , contextBold , oldBold , and newBold (see git-range-diff for details)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitcredentials"
},
{
"role": "assistant",
"content": "Providing usernames and passwords to Git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc no"
},
{
"role": "assistant",
"content": "Do not ignore whitespace when performing move detection."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Shell in Windows: patch's default character encoding is UCS-2 Little Endian - how to change this to ANSI or UTF-8 without BOM?\nWhen creating a diff patch with Git Shell in Windows (when using GitHub for Windows), the character encoding of the patch will be UCS-2 Little Endian according to Notepad++ (see the screenshots below). \nHow can I change this behavior, and force git to create patches with ANSI or UTF-8 without BOM character encoding?\nIt causes a problem because UCS-2 Little Endian encoded patches can not be applied, I have to manually convert it to ANSI. If I don't, I get \"fatal: unrecognized input\" error.\n\n\n\nSince then, I also realized that I have to manually convert the EOL from Windows format (\\r\\n) to UNIX (\\n) in Notepad++ (Edit > EOL Conversion > UNIX). If I don't do this, I get \"trailing whitespace\" error (even if all the whitespaces are trimmed: \"TextFX\" > \"TextFX Edit\" > \"Trim Trailing Spaces\").\nSo, the steps I need to do for the patch to be applied:\n\ncreate patch (here is the result)\nconvert character encoding to ANSI\nEOL conversion to UNIX format\napply patch\n\nPlease, take a look at this screenshot:"
},
{
"role": "assistant",
"content": "I'm not a Windows user, so take my answer with a grain of salt. According to the Windows PowerShell Cookbook, PowerShell preprocesses the output of git diff, splitting it in lines. Documentation of the Out-File Cmdlet suggests, that > is the same as | Out-File without parameters. We also find this comment in the PowerShell documentation:\n\nThe results of using the Out-File cmdlet may not be what you expect if you are used to traditional output redirection. To understand its behavior, you must be aware of the context in which the Out-File cmdlet operates.\nBy default, the Out-File cmdlet creates a Unicode file. This is the best default in the long run, but it means that tools that expect ASCII files will not work correctly with the default output format. You can change the default output format to ASCII by using the Encoding parameter:\n[...]\nOut-file formats file contents to look like console output. This causes the output to be truncated just as it is in a console window in most circumstances. [...]\nTo get output that does not force line wraps to match the screen width, you can use the Width parameter to specify line width.\n\nSo, apparently it is not Git which chooses the character encoding, but Out-File. This suggests a) that PowerShell redirection really should only be used for text and b) that\n| Out-File -encoding ASCII -Width 2147483647 my.patch\n\nwill avoid the encoding problems. However, this still does not solve the problem with Windows vs. Unix line-endings . There are Cmdlets (see the PowerShell Community Extensions) to do conversion of line-endings.\nHowever, all this recoding does not increase my confidence in a patch (which has no encoding itself, but is just a string of bytes). The aforementioned Cookbook contains a script Invoke-BinaryProcess, which can be used redirect the output of a command unmodified.\nTo sidestep this whole issue, an alternative would be to use git format-patch instead of git diff. format-patch writes directly to a file (and not to stdout), so its output is not recoded. However, it can only create patches from commits, not arbitrary diffs.\nformat-patch takes a commit range (e.g. master^10..master^5) or a single commit (e.g. X, meaning X..HEAD) and creates patch files of the form NNNN-SUBJECT.patch, where NNNN is an increasing 4-digit number and subject is the (mangled) subject of the patch. An output directory can be specified with -o."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitfaq"
},
{
"role": "assistant",
"content": "Frequently asked questions about using Git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout-index - Copy files from the index to the working tree --temp"
},
{
"role": "assistant",
"content": "Instead of copying the files to the working directory,\nwrite the content to temporary files. The temporary name\nassociations will be written to stdout."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -s --no-patch"
},
{
"role": "assistant",
"content": "Suppress all output from the diff machinery. Useful for\ncommands like git show that show the patch by default to\nsquelch their output, or to cancel the effect of options like --patch , --stat earlier on the command line in an alias."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitmailmap"
},
{
"role": "assistant",
"content": "Map author/committer names and/or E-Mail addresses"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --abbrev[=<n>]"
},
{
"role": "assistant",
"content": "Instead of showing the full 40-byte hexadecimal object\nname in diff-raw format output and diff-tree header\nlines, show the shortest prefix that is at least <n> hexdigits long that uniquely refers the object.\nIn diff-patch output format, --full-index takes higher\nprecedence, i.e. if --full-index is specified, full blob\nnames will be shown regardless of --abbrev .\nNon default number of digits can be specified with --abbrev=<n> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database unknownType"
},
{
"role": "assistant",
"content": "(ERROR) Found an unknown object type."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Difference between Github's \"Environment\" and \"Repository\" secrets?\n\nIn the GitHub documentation it states that the precedence of secrets is from lowest to highest (Environment > Repository > Organization), it also states that the Organization secrets are available for all repositories in the organization. But it doesn't state anything about Environment and Repository secrets.\nMy questions are:\n\nWhat is the difference is between Environment and Repository secrets?\nWhen should I use Environment secrets?\nWhen should I use Repository secrets?"
},
{
"role": "assistant",
"content": "Well, environment secrets are specific to an environment in Github Actions which allow you to run different configurations for jobs in a single repository, e.g. to deploy to staging first and later to production.\nRepository secrets are specific to a single repository (and all environments used in there), while organisation secrets are specific to an entire organisation and all repositories under it.\nYou can use environment secrets if you have secrets which are specific to an environment.\nIf you are unsure, you could also start with repository secrets for everything. If you later introduce different environments which require different secrets, you can move the repository secrets to the specific environments. Due to the inheritance chain, this should be transparent to the jobs."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.indentHeuristic"
},
{
"role": "assistant",
"content": "Set this option to false to disable the default heuristics\nthat shift diff hunk boundaries to make patches easier to read."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab issue while running helm command as - Error: unknown command \"sh\" for \"helm\"\n\nI have a packge script which needs to run on alpina:helm image . I have used this before but for some reason this is always giving me error as - Error: unknown command \"sh\" for \"helm\"\npackage:\n <<: *artifacts\n stage: package\n image: alpine/helm\n variables:\n GIT_STRATEGY: none\n script:\n - echo $VERSION\n - helm package ./keycloak --app-version=$VERSION\n artifacts:\n paths: \n - \"*.tgz\"\n\nCan anybody tell me what is the issue here I am not very sure . Helm command should be running as per my assumption but not sure why isnt it ."
},
{
"role": "assistant",
"content": "As explained in the docs, the runner in gitlab is started this way\n\nthe runner starts the docker container specified in image and uses the entrypoint of this container\nthe runner attaches itself to the container\nthe runner combines before_script, script and after_script into a single script\nthe runner sends the combined script to the container's shell\n\nIf you take a look at the entrypoint of the alpine/helm image, you see that the entrypoint is helm and when the container starts it runs helm. The gitlab runner expects no entrypoint or that the entrypoint is set to start a shell so you get the Error: unknown command \"sh\" for \"helm\" as there is no running shell.\nWith overriding the entrypoint we make sure the runner finds a shell in the container which can execute the script.\npackage:\n stage: package\n image: \n name: alpine/helm\n entrypoint: [\"\"] \n variables:\n GIT_STRATEGY: none\n script:\n - echo $VERSION\n - helm package ./keycloak --app-version=$VERSION\n artifacts:\n paths: \n - \"*.tgz\"\n\nEDIT:\nBy reading the docs again I changed the entrypoint to an empty entrypoint for docker 17.06 and later (entrypoint: [\"\"]) as this is more concise."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Difference between git-log and git-whatchanged?\nGiven this answer to another question, and\ngiven that the man pages for both git-log and git-whatchanged say they pull from git-rev-list...\n\n...what then is the difference between the two commands? Why bother having both of them?"
},
{
"role": "assistant",
"content": "The commit 52f425e1 (August, 30th 2013) mentions:\n\nEncourage new users to use 'log' instead. These days, these commands are unified and just have different defaults.\n'git log' only allowed you to view the log messages and no diffs when it was added in early June 2005. It was only in early April 2006 that the command learned to take diff options.\n Because of this, power users tended to use 'whatchanged' that already existed since mid May 2005 and supported diff options.\n\n\nThat is what the new version of the man page for git whatchanged will say now:\n\nNew users are encouraged to use git log instead. The\n whatchanged command is essentially the same as git log\n but defaults to show the raw format diff output and to skip merges.\nThe command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.\n\nAs torek comments, the git whatchanged equivalent would be:\ngit log --raw --no-merges\n\n(That would avoid this question)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to permanently remove few commits from remote branch\nI know that's rewriting of history which is bad yada yada.\nBut how to permanently remove few commits from remote branch?"
},
{
"role": "assistant",
"content": "You git reset --hard your local branch to remove changes from working tree and index, and you git push --force (or git push --force-with-lease) your revised local branch to the remote.\n(other solution here, involving deleting the remote branch, and re-pushing it)\nThis SO answer illustrates the danger of such a command, especially if people depends on the remote history for their own local repos.\nYou need to be prepared to point out people to the RECOVERING FROM UPSTREAM REBASE section of the git rebase man page.\nPlus, as noted by ringo in the comments, if the remote branch is protected against force push, a git revert, as in this answer, might be preferable.\n\nWith Git 2.23 (August 2019, nine years later), you would use the new command git switch.\nThat is: git switch -C mybranch origin/mybranch~n\n(replace n by the number of commits to remove)\nThat will restore the index and working tree, like a git reset --hard would.\nThe documentation adds:\n\n-C <new-branch>\n--force-create <new-branch>\n\nSimilar to --create except that if <new-branch> already exists, it will be reset to <start-point>.\nThis is a convenient shortcut for:\n$ git branch -f <new-branch>\n$ git switch <new-branch>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Azure pipeline does't allow to git push throwing 'GenericContribute' permission is needed\nI'm trying push some changes done during Azure pipeline using cmd component as follows,\nsteps:\n- script: |\n git config user.email [email protected]\n git config user.name \"your name\"\n git diff\n git add .\n git commit -m \"version update [skip ci]\"\n git push origin HEAD:master\n\nBut it fails showing following error.\n\nremote: 0000000000aaTF41027: You need the Git 'GenericContribute'\n permission to perform this action. Details: identity\n 'Build\\sdfdfjjkk', scope 'repository'\n\nI already set the necessary permission as follows:\n\nAnd the Allow scripts to access the OAuth token is also enabled as mentioned here\nWhat other permissions do I need to give this to work?"
},
{
"role": "assistant",
"content": "If you get the following error in your build:\n\nYou need the Git ‘GenericContribute’ permission to perform this action. Details: identity 'Build\\7be59e48-a479-XXXX-a453-XXXXXXXXXXXX', scope 'repository'.)\n\n...then, to fix it:\n\nIMPORTANT: Copy the 7be59e48-a479-XXXX-a453-XXXXXXXXXXXX guid part of the identity name from the error message\nGo to the repository settings\nPaste the guid into the permissions search box for user or group.\n\nThis will then display a “Project Collection Build Service (OrganisationName)”. Select that user\nSet the permissions as stated in other answers."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git push error: src refspec main does not match any on linux\n\nwhenever I'm trying to upload my files using git push -u origin main\nI'm getting error which is as follows\nerror: src refspec main does not match any\nerror: failed to push some refs to 'github.com:xxxxxx/xxx-project.git'\n\nbut if I do git push -u origin master it is working perfectly and uploading my files to a separate branch named master. upon checking .git/refs/heads in my project i saw that there is only one file named master so i performed git remote update which added .git/refs/remotes/origin/main but still git push -u origin main didn't work.\nI tried git push origin HEAD:main but produced error:\n! [rejected] HEAD -> main (non-fast-forward) error: failed to push some refs to 'github.com:xxxxxxx/xxx-project.git' hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. Check out this branch and integrate the remote changes hint: (e.g. 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.\nI want to push my code to main branch using git push -u origin main. how do I do that ?\nP.S - git version 2.29.2, pop_os 20.10.1\nEdit1 - git push -f origin HEAD:main pushes my code to main branch but how can i replace master file with main file in refs/heads so that i don't have to mention head and force my push ?"
},
{
"role": "assistant",
"content": "This is a multi-part answer because there are two separate issues here that are tangling together now. Here's a summary of what we'll cover:\n\nmain vs master\nerror: src refspec main does not match any\nreconciling separate main and master branches\n\nEach of these is in its own section.\nmain vs master\nGit itself has no special branch names.1 You could use main, master, trunk, or any other name as the name of your first branch. Git has traditionally used the name master here, but there is a project to make this configurable, so that if you are French or Spanish you can use the name principal or première or primero, or if you prefer Maori, you can use matua or tuatahi. Currently, you can do this manually during or after a git init,2 but the project makes Git just do it automatically, without requiring a second step: If for any reason you want any other name by default, you can configure that.\nMeanwhile, GitHub have already chosen to leap ahead and make their default initial branch name main instead of master. But this leaves your Git and GitHub's Git out of sync, as it were. For more about GitHub's changeover, see\nDifference Between Main Branch and Master Branch in Github?\n\n1There are some technical flaws in this kind of claim. As we know, technically correct is the best kind of correct, so let me add a few caveats in this footnote:\n\nMerging auto-generates a message of the form merge branch X into Y when you are on branch Y and run git merge X. However, when you're on master, Git traditionally generates only a message of the form merge branch X.\n\nA new, empty repository created by git init has no commits and therefore has no branches (because a branch can only exist by having commits on it). However, you must be on some branch in this new empty repository. So Git stores some name in the symbolic ref named HEAD. This is the branch name that you're on, even if that branch name does not exist (yet). For a long time, Git has had, hard-coded into it, some code to stick the branch name master in there. (This is, in effect, what GitHub changed.)\n\nThere are a bunch of other string literals reading master in the source and documentation as well; they're being converted to use the configuration settings but this will all take time.\n\n\n2If you have Git 2.28 or later, run git init --initial-branch=name, and/or set init.defaultBranch with git config in your system or global configuration. If you have an earlier version of Git installed, or have already run git init, simply use git branch -m to rename master to whatever name you like.\n\nerror: src refspec main does not match any\nThis error message from Git is quite cryptic to newbies, but is actually pretty simple. The problems are that it's loaded with jargon (webster; wikipedia), and abbreviates \"source\" to \"src\".\nGit is all about commits. When we clone a repository, we have our Git reach out to some other Git. That other Git looks up a repository, and that other repository is full of commits. We then have our Git create a new repository locally, transfer into it all of their commits, and turn all of their branch names into remote-tracking names. Then our Git creates, in this new repository, one branch name, based on one of their branch names. At least, that's the normal process. (And, if you know what all these terms mean, good! If not, don't worry too much about them right now. The point to remember here is that we get all their commits and none of their branches, and then we normally have our Git create one branch to match one of theirs.)\nSince Git is all about commits, this process—of copying all their commits, but only copying one of their branch names to a name spelled the same in our own repository—is all we need. The fact that our Git renames all of their branch names—so that with the one exception, we don't have any branches at all—isn't normally very important. Our own Git deals with this later, automatically, if and when it's necessary.\nWhen we use git push, we are asking our Git program, which is reading our own Git repository, to connect to some other Git program—typically running on a server machine—that can then write to some other Git repository. We'd like our Git to send their Git some of our commits. In particular, we want to send them our new commits: the ones we just made. Those are, after all, where we put all our good new stuff. (Git is all about commits, so that's the only place we can put anything.)\nOnce we've sent these commits, though, we need to their Git to set one of their branch names to remember our new commits. That's because the way Git finds commits is to use branch names.3 The real names of each commit are big ugly hash ID numbers, which nobody wants to remember or look at; so we have Git remember these numbers using the branch names. That way, we only have to look at the branch names, and these names can be meaningful to us: trunk, or feature/tall, or tuatahi, or whatever.\nBy default and convention, the way we do this using git push is pretty simple:\ngit push origin main\n\nfor instance. The git push part is the command that means send commits and ask them to set a name. The origin part is what Git calls a remote: a short name that, mostly, holds a URL. The main part at the end, here, is our branch name. That's the one our Git is using to find our commits. We'll have our Git send our commits, then ask their Git to set their main too.\nThis last part—where we've put in main here—is what Git calls a refspec. Refspecs actually let us put in two names, separated by a colon, or a couple of other forms. We can, for instance, use HEAD:main as in Arka's answer (although for technical reasons we might want to use HEAD:refs/heads/main in many cases). But in simple cases, we can just use one branch name: git push origin main. The simple branch name is a simple form of refspec.\nFor this to work, the source name must be the name of an existing branch in our own Git repository. This is where things are going wrong.\n(See also Message 'src refspec master does not match any' when pushing commits in Git)\n\n3Git can use any name, not just a branch name. For instance, a tag name works fine. But this answer is about branch names because the question is about branch names, and branch names are the most common ones to use here.\n\nWhat if our Git created only master?\nSuppose we're using GitHub and we've asked GitHub to make a new repository for us. They run a form of git init that supplies, as the new repository's initial branch name, the name main. They may or may not create one commit, too. Let's say we do have them create this one commit. That one commit will hold README and/or LICENSE files, based on what we choose using the web interface. Creating that initial commit actually creates the branch name main.\nIf we now clone their repository, we'll get their one commit, which will be under their branch name main. Our Git will rename their main to origin/main and then create one new branch name, main, to match theirs. So all will be good.\nBut, if we create our own empty Git repository, using git init ourselves, our Git may set us up so that our first commit will create the name master. We won't have a main branch: we'll have a master branch instead.\nOr, if we don't have GitHub create an initial commit, the GitHub repository will be totally empty. Because it has no commits, it has no branches: a branch name is only allowed to exist if it specifies some commit. So if we clone this empty repository, we'll have no branches either, and our Git won't know to use main: our Git may instead use master. We're back in that same situation, where our Git think the first name to create should be master.\nSo, in these various situations, we make our first commit(s), and they all go on a branch named master. If we now run:\ngit push -u origin main\n\n(with or without the -u; I won't go into the details about the -u here) our Git looks around in our Git repository for a branch named main. There isn't one! So our Git just gives us that:\nerror: src refspec main does not match any\n\nerror message.\nTo fix this, we can either git push origin master—which sends our commits and then asks GitHub to create a new branch in the GitHub repository, with that branch name being master—or rename our master to whatever name we wanted, and then use that name:\ngit branch -m master xyzzy\ngit push -u origin xyzzy\n\nwill make the (single) branch name that we both use be xyzzy. If you want main here, rename your master to main.\nWhat if you've accidentally made both branches?\nSuppose we used GitHub to create a new repository, with their new default branch name main, that includes one initial commit with the usual README and LICENSE files. Then, without thinking about it, we used git init on our own machine to create our own new repository, with its default branch name master, and we made a commit or two on our master.\nIf we now rename our master to main:\ngit branch -m master main\n\nand then try to push:\ngit push -u origin main\n\nwe get a different error:\n ! [rejected] main -> main (non-fast-forward)\n\nThe reason for this is simple enough: They have a commit, that they find using their name main, that we do not have. If they change their name main to find the last commit that we're sending them, they'll lose the initial commit they made, with the README and LICENSE files.\nYou have a bunch of options here:\n\nYou can ignore the initial commit they made. It's just a boilerplate commit, after all. You can tell them to throw it away entirely. Use git push --force as outlined in any of many existing StackOverflow answers.\n\nYou can obtain their initial commit and rebase your commits on those commits. This can be slightly tricky, because your first commit is a root commit. If your first commit contains README and/or LICENSE files, you'll get an add/add conflict here. In this case it's probably simpler to just force-push.\n\nYou can obtain their initial commit and merge your commits. In a modern Git, this requires using the --allow-unrelated-histories option. As with the rebase method, if your commits contain README and/or LICENSE files, you'll get add/add conflicts. The resulting repository will also have two root commits. None of these are serious problems, but they might prove slightly annoying.\n\n\nTo obtain their commit, simply run git fetch origin. That will get GitHub's first commit, and use the name origin/main in your own Git repository to remember it. You can then:\ngit rebase origin/main\n\nor:\ngit merge --allow-unrelated-histories origin/main\n\nto achieve the rebase or merge. You can choose whether to rename your branch to main, if you have not already done so, at any time before or after doing all of this."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %gs"
},
{
"role": "assistant",
"content": "reflog subject"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options repack.cruftWindow repack.cruftWindowMemory repack.cruftDepth repack.cruftThreads"
},
{
"role": "assistant",
"content": "Parameters used by git-pack-objects when generating\na cruft pack and the respective parameters are not given over\nthe command line. See similarly named pack.* configuration\nvariables for defaults and meaning."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the difference between git push origin and git push origin master\nIs there any difference in pushing the master branch of a local git repository to the master branch of a remote repository called origin with git push origin master\nor with git push origin?"
},
{
"role": "assistant",
"content": "The default action of git push and git push origin has changed since git version 1.7.11:\n\nBefore 1.7.11, git push by default pushes all branches that also exist remotely with the same name.\nSince 1.7.11, git push by default pushes the current branch to a remote branch with the same name.\n\nBefore and after version 1.7.11, the default behavior can be configured with the push.default configuration option. This configuration option has been introduced in git version 1.6.3."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I display the current branch and folder path in terminal?\nI've been watching some of the Team Treehouse videos and they have a very nice looking terminal when working with Git.\nFor example they have (something similar):\nmike@treehouseMac: [/Work/test - feature-branch-name] $ git add .\nmike@treehouseMac: [/Work/test - feature-branch-name] $ git commit -m \"Some feature.\"\nmike@treehouseMac: [/Work/test - feature-branch-name] $ git checkout master\nmike@treehouseMac: [/Work/test - master] $ git status\n\nHow can my terminal show me some useful information of what branch I'm on, with colors to distinguish bits of the data I want? Is there some sort of de-facto plugin I haven't found yet?\nI'm using Mac OSX 10.8"
},
{
"role": "assistant",
"content": "For anyone looking for how to do this in macOS Catalina or above (10.15+ incl. Big Sur 11.0) which has deprecated bash in favour of zsh, here is my .zshrc file:\nparse_git_branch() {\n git branch 2> /dev/null | sed -n -e 's/^\\* \\(.*\\)/[\\1]/p'\n}\nCOLOR_DEF='%f'\nCOLOR_USR='%F{243}'\nCOLOR_DIR='%F{197}'\nCOLOR_GIT='%F{39}'\n# About the prefixed `$`: https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_03.html#:~:text=Words%20in%20the%20form%20%22%24',by%20the%20ANSI%2DC%20standard.\nNEWLINE=$'\\n'\n# Set zsh option for prompt substitution\nsetopt PROMPT_SUBST\nexport PROMPT='${COLOR_USR}%n@%M ${COLOR_DIR}%d ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF}${NEWLINE}%% '\n\nIf you don't like the colours I have used, replace the 243/197/39 values with the colour codes as defined here:\nhttps://misc.flogisoft.com/bash/tip_colors_and_formatting\nPrompt substitutions used:\n\n%n: username\n%M: full machine hostname\n%d: current working directory\n%%: escape sequence to print a %"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to reject merge request in GitLab?\n\nIs there any way in GitLab UI to reject a merge request because code has issue?\nIf not what is the right way to track this?"
},
{
"role": "assistant",
"content": "I agree with Phil Lucks. In my opinion gitlab is missing functionality. A merge request is a request and as such should be able to be rejected/denied.\nThe following thread gives insight into the thought process that was going on with Closing a request versus denying one. https://gitlab.com/gitlab-org/gitlab-foss/-/issues/23355"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Rebasing a Git merge commit\nTake the following case:\nI have some work in a topic branch and now I'm ready to merge back to master:\n* eb3b733 3 [master] [origin/master]\n| * b62cae6 2 [topic]\n|/ \n* 38abeae 1\n\nI perform the merge from master, resolve the conflicts and now I have:\n* 8101fe3 Merge branch 'topic' [master]\n|\\ \n| * b62cae6 2 [topic]\n* | eb3b733 3 [origin/master]\n|/ \n* 38abeae 1\n\nNow, the merge took me some time, so I do another fetch and notice that the remote master branch has new changes:\n* 8101fe3 Merge branch 'topic' [master]\n|\\ \n| * b62cae6 2 [topic]\n| | * e7affba 4 [origin/master]\n| |/ \n|/| \n* | eb3b733 3\n|/ \n* 38abeae 1\n\nIf I try git rebase origin/master from master, I'm forced to resolve all conflicts again, and I also lose the merge commit:\n* d4de423 2 [master]\n* e7affba 4 [origin/master]\n* eb3b733 3\n| * b62cae6 2 [topic]\n|/ \n* 38abeae 1\n\nIs there a clean way to rebase the merge commit so I end up with a history like the one I show below?\n* 51984c7 Merge branch 'topic' [master]\n|\\ \n| * b62cae6 2 [topic]\n* | e7affba 4 [origin/master]\n* | eb3b733 3\n|/ \n* 38abeae 1"
},
{
"role": "assistant",
"content": "There are two options here.\nOne is to do an interactive rebase and edit the merge commit, redo the merge manually and continue the rebase.\nAnother is to use the --rebase-merges option on git rebase, which is described as follows from the manual:\n\nBy default, a rebase will simply drop merge commits from the todo list, and put the rebased commits into a single, linear branch. With --rebase-merges, the rebase will instead try to preserve the branching structure within the commits that are to be rebased, by recreating the merge commits. Any resolved merge conflicts or manual amendments in these merge commits will have to be resolved/re-applied manually.\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to update my fork to have the same branches and tags as the original repository on github?\nWhen you fork a repository on github your forked repo contains all branches and tags.\nOver time these branches and tags gets outdated.\nHow does one as easy it is with fork make sure your fork has all branches and tags without having to reclone ?\ni.e. a git magicpull --rebase upstream/* myremote/*\nwhich would fetch all the branches and tags in upstream and make sure the same are present in myremote."
},
{
"role": "assistant",
"content": "This assumes your \"upstream\" remote is named \"origin\" and you have your custom fork under your username (i.e. \"maxandersen\")\nWhen you have your clone run the following one-liner (refresh of Track all remote git branches as local branches :\nremote=origin ; for brname in `git branch -r | grep origin | grep -v master | grep -v HEAD | sed -e 's/^[^\\/]*\\///'`; do git branch --track $brname $remote/$brname ; done\n\nThis will setup tracking branches for all the branches found in the remote named 'origin'.\nIf you already have a checkout with this branchname it will not change anything except ensure the tracking is in place.\n(Optional) Now ensure all your branches are uptodate (useful if you have already branches checked out):\ngit pull --rebase --all\n\nNow with all branches setup for tracking and uptodate push branches and tags to your remote (replace 'maxandersen' with your remote name):\ngit push --all maxandersen\ngit push --tags maxandersen\n\nAfter this your fork is in sync.\nThe following script does all this including asking for confirmation:\n## Checkout all branches from remote as tracking branches. Based on https://stackoverflow.com/questions/379081/track-all-remote-git-branches-as-local-branches/6300386#6300386\n\nUPSTREAM=$1\nMYREPO=$2\n\nusage() {\n echo \"Usage:\"\n echo \"$0 <upstream-remote> <target-remote>\"\n echo \"\"\n echo \"Example which ensures remote named 'maxandersen' have all the same branches and tags as 'origin'\"\n echo \"$0 origin maxandersen\"\n exit 1\n}\n\nif [ -z \"$UPSTREAM\" ]\nthen\n echo Missing upstream remote name.\n usage\nfi\n\nif [ -z \"$MYREPO\" ]\nthen\n echo Missing target remote name. \n usage\nfi\n\nread -p \"1. This will setup '$MYREPO' to track all branches in '$UPSTREAM' - Are you sure ?\" -n 1 -r\n\nif [[ $REPLY =~ ^[Yy]$ ]]\nthen\n for brname in `git branch -r | grep \"$UPSTREAM\" | grep -v master | grep -v HEAD | sed -e 's/.*\\///g'`; do git branch --track $brname $UPSTREAM/$brname ; done\nfi\n\nread -p \"2. This will push all local branches and tags into '$MYREPO' - Are you sure ?\" -n 1 -r\n\nif [[ $REPLY =~ ^[Yy]$ ]]\nthen\n git push --all $MYREPO\n git push --tags $MYREPO\nfi\n\nSave it as 'updateallbranchestags.sh' and execute it with:\nsh updateallbranches.sh origin maxandersen\n\nAnd all branches/tags from 'origin' will be made available in remote named 'maxandersen'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-reflog - Manage reflog information -n --dry-run"
},
{
"role": "assistant",
"content": "Do not actually prune any entries; just show what would have\nbeen pruned."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_DIFF_PATH_TOTAL"
},
{
"role": "assistant",
"content": "The total number of paths."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.xfuncname"
},
{
"role": "assistant",
"content": "The regular expression that the diff driver should use to\nrecognize the hunk header. A built-in pattern may also be used.\nSee gitattributes for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-update-index - Register file contents in the working tree to the index"
},
{
"role": "assistant",
"content": "CONFIGURATION The command honors core.filemode configuration variable. If\nyour repository is on a filesystem whose executable bits are\nunreliable, this should be set to false (see git-config ).\nThis causes the command to ignore differences in file modes recorded\nin the index and the file mode on the filesystem if they differ only on\nexecutable bit. On such an unfortunate filesystem, you may\nneed to use git update-index --chmod= . Quite similarly, if core.symlinks configuration variable is set\nto false (see git-config ), symbolic links are checked out\nas plain files, and this command does not modify a recorded file mode\nfrom symbolic link to regular file. The command looks at core.ignorestat configuration variable. See Using \"assume unchanged\" bit section above. The command also looks at core.trustctime configuration variable.\nIt can be useful when the inode change time is regularly modified by\nsomething outside Git (file system crawlers and backup systems use\nctime for marking files processed) (see git-config ). The untracked cache extension can be enabled by the core.untrackedCache configuration variable (see git-config )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc cumulative"
},
{
"role": "assistant",
"content": "Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --ita-invisible-in-index"
},
{
"role": "assistant",
"content": "By default entries added by \"git add -N\" appear as an existing\nempty file in \"git diff\" and a new file in \"git diff --cached\".\nThis option makes the entry appear as a new file in \"git diff\"\nand non-existent in \"git diff --cached\". This option could be\nreverted with --ita-visible-in-index . Both options are\nexperimental and could be removed in future."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: what exactly is a merge commit in git?\nI went through couple of blogs to understand a merge commit, but not completely clear as to what it is and what is the best practice to avoid it. And the tree diagram of the git log added further confusion to my understanding of merge commits. Help?"
},
{
"role": "assistant",
"content": "A merge commit is just like another commit, the state of your repository at a given point in time plus the history it evolved from.\nThe one thing special about a merge commit is that it has at least two predecessors, therefore a plain vanilla diff doesn't make sense, you can only compare the merge with one of the predecessor, which yields the changes from the other parent(s)\nTo avoid merge commits, you can rebase your changes before pushing them to a remote repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Branches have apparently diverged, but commit history is identical\ngit status tells me that my branch and the one I started from on another repository have diverged:\n# On branch master\n# Your branch and 'origin/master' have diverged,\n# and have 13 and 13 different commit(s) each, respectively.\n\nbut the commit history for each is identical. That is, git log shows the same commits, in the same order, with the same SHA-1 hashes. That's for the last 13 commits, and everything before that too.\nWhat's going on?! Or have I misunderstood something fundamental - git's all new to me.\nIt's quite a long story how I got into this mess - git-svn, cygwin, EGit, pull --rebase with spurious conflicts - but I'm wondering if it's possible this \"divergence without any differences\" is due to newlines? I've opened files in notepad, and read lots about svn/git/cygwin and CRLF but without any revelations.\nEdit OK. Most of the above isn't really the problem. Maybe I don't understand git log or something has got messed up somewhere...\nI have two repositories. If I go to rep_A and run git log I get the same result (notably same SHA-1) as if I go to rep_B and run git log.\nAt rep_A, if I run git log origin/master I get the different commit history I expect. (Different SHA-1s, but same messages - how I created this mess is another story.)\ngit remote -v show assures me that the origin is where I expect it to be.\ngit log, on rep_B, isn't behaving how I expected. It's like it's giving me the commit history for rep_A. What have I missed?"
},
{
"role": "assistant",
"content": "It looks like you also forgot to update remote repositories. So do git remote update in rep_A (it will probably warn it is not fast-forward update as you seem to do rebase on both ends) and then the histories should be identical."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I move a Git branch out into its own repository?\nI have a branch that I'd like to move into a separate Git repository, and ideally keep that branch's history in the process. So far I've been looking at git filter-branch, but I can't make out whether it can do what I want to do.\nHow do I extract a Git branch out into its own repository?"
},
{
"role": "assistant",
"content": "You can simply push a branch to a new repository. All of its history will go with it. You can then choose whether to delete the branch from the original repository.\ne.g.\ngit push url://to/new/repository.git branch-to-move:new-branch-name\n\nFor a new repository, new-branch-name is typically master.\nCreating a new, empty repository can be done with git init."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to make github follow directory history after renames?\n\nOnce a directory is renamed, \"git log\" no longer shows its history, unless you force it to, by using \"git log --follow\".\nIs there a way to force the \"history\" function on the GitHub web UI to use \"--follow\"?\nAlternatively - is there any way to see pre-rename history on GitHub?"
},
{
"role": "assistant",
"content": "Update June 2022: GitHub now supports viewing commit history across file renames and moves!\n.\n\n2011: This was requested in 2009 (Request 129), and then in 2010 (Request 897), and then in 2021 (github/feedback discussion 6964):\n\nI like this.\nThere could be other issues preventing us from plopping the --follow argument in.\nI'll take a look and let you know.\n\n... and then nothing for now.\n\nNote: Git 2.6+ (Q3 2015) will propose that in command line: see \"Why does git log not default to git log --follow?\"\n\nNote: Git 2.6.0 has been released and includes this feature. Following path changes in the log command can be enabled by setting the log.follow config option to true as in:\ngit config log.follow true"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %ch"
},
{
"role": "assistant",
"content": "committer date, human style (like the --date=human option of git-rev-list )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "can't add all files to git due to permissions\nI want to add all the files in the current directory to git:\ngit add .\nerror: open(\".mysql_history\"): Permission denied\nfatal: unable to index file .mysql_history\n\nThat's fine. That file happens to be in this directory and owned by root. I want to add all other files. Is there a way to do that without having to manually add each file by hand?\nI know that I could add the file to exclude or .gitignore, but I'd like to have it just ignore things based on permissions (there's a good chance other files like this will end up in the directory, and adding them to .gitignore all the time is a pain)."
},
{
"role": "assistant",
"content": "Use git add --ignore-errors .\nThis will still give an error for the unreadable file(s), but not a fatal one. The other files will be added."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "When coding in TypeScript should the generated .js files be committed to git?\nWhen using TypeScript to write node.js application, what is the recommended way to deal with generated .js files?\nShould I add generated .js files to .gitignore and commit only the .ts files or is it OK to commit both .ts and generated .js files?"
},
{
"role": "assistant",
"content": "Any build artifacts for any and every VCSes have to be excluded from storing in repository. Just because repository must hold sources, using which you can re-build results in any environment and in any intermediate stored state"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together -v --verbose"
},
{
"role": "assistant",
"content": "Be verbose."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Should I store git repository in Home or Eclipse Workspace?\nI'm just moving from svn to git, and am keen to lay some good foundations.\nBy default Eclipse wants to store my local clone repository in ~/git. I'm more comfortable keeping all data for a task in the same workspace - so I'm inclined to keep it in my workspace.\nAre there any significant pros/cons I should consider?\nI don't intend doing a lot of branching - I'm really going down the dvcs route mostly to overcome some unreliable internet comms issues."
},
{
"role": "assistant",
"content": "I'm too switching to Git in Eclipse, and reading about this issue. It seems that current wisdom (though not everyone agrees) is:\n\nGet used to NOT having your projects below the workspace directory.\nHave one git repository for each group of related eclipse projects (and perhaps more files, of course). The concept of \"related projects\" is up to your convenience [*]\nFor each repository, one first level directory for each Java project. This implies that you'll have a .git/ directory, and, at the same level, the project directories.\n\nExample: suppose that, \"before GIT\", you had one eclipse workspace with several projects:\n/wk/workspace/.metadata/ \n/wk/workspace/projXXX/ \n/wk/workspace/projXXXtest/ (related with the previous)\n/wk/workspace/projYYY1/ |\n/wk/workspace/projYYY2/ > three related projects\n/wk/workspace/projYYY3/ |\n/wk/workspace/projZ/ (a project you are not going to version in git)\n\nThen you'll create two empty directories, one for each repository, say:\n~/repositories/XXX/ \n~/repositories/YYY/ \n\nand afterwards, with the new GIT layout, you'll have:\n/wk/workspace/.metadata/ \n/wk/workspace/projZ/ \n\n~/repositories/XXX/.git/ (XXX related repository - non-bare)\n~/repositories/XXX/projXXX/\n~/repositories/XXX/projXXXtest/\n\n~/repositories/YYY/.git/ (YYY related repository - non-bare)\n~/repositories/YYY/projYYY1/\n~/repositories/YYY/projYYY2/\n~/repositories/YYY/projYYY3/\n\nEclipse (EGit) does all this for you when you click Team->Share over an existing project and specify (in the example) ~/repositories/XXX/.git/ as repository, (~/repositories/XXX/ as \"Working directory\", leave \"Path within repository\" blank).\n[*] Bear in mind that here each group of projects is, from the Git point-of-view, just a set of directories inside a repository. Some relevant implications: in the above example, you'll never have in the Eclipse workspace two different branches/versions of projects projYYY1 -projYYY2 simultaneously; and, say, when you tag a project commit, you are actually tagging the full repository (group of projects) commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Clone Fails with sslRead() error on OS X Yosemite\n\nI'm currently on OS X Yosemite 10.10.3, and trying to git clone an existing repo which works fine on Windows. I've tried a combo of installing git through homebrew with curl/openssl with no luck. When i run the git clone, i get the following ssl read error:\nGIT_CURL_VERBOSE=1 git clone http://myURL/gitlab/project/project.git\n\n> remote: Counting objects: 1641, done. remote: Compressing objects:\n> 100% (1588/1588), done.\n> * SSLRead() return error -98061641), 136.73 MiB | 1.71 MiB/s \n> * Closing connection 2 remote: Total 1641 (delta 910), reused 0 (delta 0) error: RPC failed; result=56, HTTP code = 200 Receiving objects:\n> 100% (1641/1641), 137.48 MiB | 1.64 MiB/s, done. Resolving deltas:\n> 100% (910/910), done.\n\nI've tried using both the Https & Http with no luck. Has anyone else hit something similar to this?\nBelow are outputs of git, curl, & openssl versions if that helps.\ncurl --version\ncurl 7.37.1 (x86_64-apple-darwin14.0) libcurl/7.37.1 SecureTransport zlib/1.2.5\nProtocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp \nFeatures: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz \n\ngit --version\ngit version 2.4.1\n\nopenssl version\nOpenSSL 0.9.8zd 8 Jan 2015\n\nThanks in advance for any direction!"
},
{
"role": "assistant",
"content": "Javabrett's link got me to the answer, it revolves around Yosemite using an incorrect SSL dependency, which Git ends up using. \nInstalling Git via homebrew with these flags works:\nbrew install git --with-brewed-curl --with-brewed-openssl\n\nOr:\nbrew reinstall git --with-brewed-curl --with-brewed-openssl"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to remove a Github Environment\n\nMy question is about cleaning up the \"Environments\" tab on a Github repository.\nI previously deployed via Heroku, using automatic deployment from two separate Github branches (one for staging, one for production).\nThis created a tab \"Environments\" on the repository, in which both Heroku environments were shown - exactly as intended.\nOnce I started to dive into Heroku pipelines, I have now configured the app to be promoted to production from staging, so the production environment no longer auto-deploys from a branch.\nThe Environments tab on my Github repo has no way to remove the environment that I no longer use. I can't seem to find any place on Github or Heroku to make Github \"forget\" this deployment environment.\nI hope my question is clear enough; if I can elaborate on anything, please let me know."
},
{
"role": "assistant",
"content": "I made a little webpage/script too, to automate the process (I don't have Python installed, and I didn't see that someone else had already made a script), and this is online and putting your info will do the process automatically.\nStackblitz - Github Deployments deleter\nEdit 18/07/2020: I copied the script from Stackblitz to a local snippet code in here too, just in case Stackblitz disappears:\n\n\n// RECOMMENDED: Disconnect HEROKU from Github before doing this (though not strictly necessary, I think).\n//See https://stackoverflow.com/a/61272173/6569950 for more info.\n\n// PARAMETERS\nconst TOKEN = \"\"; // MUST BE `repo_deployments` authorized\nconst REPO = \"your-repo\"; // e.g. \"monorepo\"\nconst USER_OR_ORG = \"your-name\"; // e.g. \"your-name\"\n\n// GLOBAL VARS\nconst URL = `https://api.github.com/repos/${USER_OR_ORG}/${REPO}/deployments`;\nconst AUTH_HEADER = `token ${TOKEN}`;\n\n// UTILITY FUNCTIONS\nconst getAllDeployments = () =>\n fetch(`${URL}`, {\n headers: {\n authorization: AUTH_HEADER\n }\n }).then(val => val.json());\n\nconst makeDeploymentInactive = id =>\n fetch(`${URL}/${id}/statuses`, {\n method: \"POST\",\n body: JSON.stringify({\n state: \"inactive\"\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/vnd.github.ant-man-preview+json\",\n authorization: AUTH_HEADER\n }\n }).then(() => id);\n\nconst deleteDeployment = id =>\n fetch(`${URL}/${id}`, {\n method: \"DELETE\",\n headers: {\n authorization: AUTH_HEADER\n }\n }).then(() => id);\n\n// MAIN\ngetAllDeployments()\n .catch(console.error)\n .then(res => {\n console.log(`${res.length} deployments found`);\n return res;\n })\n .then(val => val.map(({\n id\n }) => id))\n .then(ids => Promise.all(ids.map(id => makeDeploymentInactive(id))))\n .then(res => {\n console.log(`${res.length} deployments marked as \"inactive\"`);\n return res;\n })\n .then(ids => Promise.all(ids.map(id => deleteDeployment(id))))\n .then(res => {\n console.log(`${res.length} deployments deleted`);\n return res;\n })\n .then(finalResult => {\n const appDiv = document.getElementById(\"app\");\n appDiv.innerHTML = `\n<h1>CLEANUP RESULT</h1>\n<br>\nRemoved Deployments: ${finalResult.length}\n<br>\n<br>Ids:<br>\n${JSON.stringify(finalResult)}\n<br><br><br><br><br><br>\n <p>(Open up the console)</p>\n`;\n });\nh1,\nh2 {\n font-family: Lato;\n}\n<div id=\"app\">\n <h1>Github Deployment's Cleaner</h1>\n <p> You need to put the parameters in!</p>\n</div>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options fetch.fsckObjects"
},
{
"role": "assistant",
"content": "If it is set to true, git-fetch-pack will check all fetched\nobjects. See transfer.fsckObjects for what’s\nchecked. Defaults to false. If not set, the value of transfer.fsckObjects is used instead."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --output=<file>"
},
{
"role": "assistant",
"content": "Output to a specific file instead of stdout."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "If I fork someone else's private Github repo into my account, is it going to appear in my account as a public repo?\nSomeone gave me access to one of their private repo on Github. What I want to do is to fork that project into my own account, so I could make use of Github's pull request feature.\nI only have a basic account on Github, so I cannot make private repos on my own, but if I fork someone else's private repo into my account, is it going to appear in my account as public?"
},
{
"role": "assistant",
"content": "No. You can fork it and it still remains private.\n\nPrivate collaborators may fork any private repository you’ve added\n them to without their own paid plan. Their forks do not count against\n your private repository quota.\n\nhttps://github.com/plans"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-quiltimport"
},
{
"role": "assistant",
"content": "Applies a quilt patchset onto the current branch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip drop"
},
{
"role": "assistant",
"content": "The commit will be dropped. This is the default behavior."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to know if there is a git rebase in progress?\nWhen I start a git rebase -i, I can issue commands like git rebase --continue, or git rebase --abort. Those commands only work if a rebase is in progress.\nHow can I know if there is a rebase in progress?\n(I would greatly appreciate some details on how rebase works internally; what does git do to a repo that gives it the \"rebase in progress\" status,?)"
},
{
"role": "assistant",
"content": "Update 2021:\nAs I mentioned in \"git stash is slow on windows\", with Git for Windows 2.19 (Sept. 2018), git stash (and git rebase) are no longer script-only, but actually a binary compiled with git.exe.\nTim's answer illustrates how it is still difficult to ascertain if a rebase is in progress.\nThat was discussed in the mailing list, leading to patch like \"status: rebase and merge can be in progress at the same time\":\n\nSince git rebase -r was introduced, that is possible.\nBut our machinery did not think that possible, and failed to say anything about the rebase in progress when in the middle of a merge.\n\nThere was a case of \"rebase in progress\" detection before that (2016), with \"worktree.c: check whether branch is rebased in another worktree\"\nThis function find_shared_symref() is used in a couple places:\n\n\nin builtin/branch.c: it's used to detect if a branch is checked out elsewhere and refuse to delete the branch.\nin builtin/notes.c: it's used to detect if a note is being merged in another worktree\nin branch.c, the function die_if_checked_out() is actually used by \"git checkout\" and \"git worktree add\" to see if a branch is already checked out elsewhere and refuse the operation.\n\nIn cases 1 and 3, if a rebase is ongoing \"HEAD\" will be in detached mode.\nfind_shared_symref() fails to detect it and declares \"no branch is checked out here\", which is not really what we want.\n\n\nOriginal answer: 2010\nFor one thing, there is a ORIG_HEAD in place during a rebase (but that is not limited to the rebase command)\nBut you can also look at the 2010 Git 1.7.0 git-rebase.sh script itself (which is as \"internal\" as you can get ;) ).\nLines like those can give you another clue:\ndotest=\"$GIT_DIR\"/rebase-merge\ntest -d \"$dotest\" -o -d \"$GIT_DIR\"/rebase-apply || die \"No rebase in progress?\"\n\nsabgenton comments:\n\nThe folder rebase-apply seems to appear with rebase,\nbut a folder rebase-merge shows up only with with rebase -i.\n\nAnd hippy also comments, in 2017, that:\n\nThe coding guidelines discourage the usage of -o (see Documentation/CodingGuidelines), so the correct way now (2017, but also since 2011, Git 1.7.6) is:\n(test -d \".git/rebase-merge\" || test -d \".git/rebase-apply\") || die \"No rebase in progress?\"\n\n\nJelaby suggests in the comments:\n\n(test -d \"$(git rev-parse --git-path rebase-merge)\" || \\\n test -d \"$(git rev-parse --git-path rebase-apply)\" )\n\nThis correctly handles worktrees and unusual or non-standard layouts that don't have a .git directory, and also allows you to run this test from a subdir of the working directory.\n\nThat is because the git rev-parse --git-path <path>: does resolve \"$GIT_DIR/<path>\".\nAnd Elizandro - SparcBR adds in the comments:\n\nCould also redirect the error to null:\n(test -d \"$(git rev-parse --git-path rebase-merge)\" || test -d \"$(git rev-parse --git-path rebase-apply) 2>/dev/null\"\n\n\n\nGit 2.6+ (Q3 2015) will print more information during a rebase:\nSee commit 592e412, commit 84e6fb9 (06 Jul 2015), commit 84e6fb9 (06 Jul 2015), and commit df25e94, commit 05eb563 (30 Jun 2015) by Guillaume Pagès (gitster).\n(Merged by Junio C Hamano -- gitster -- in commit 178d2c7, 03 Aug 2015)\n\nstatus: give more information during rebase -i\n\n\ngit status gives more information during rebase -i, about the list of commands that are done during the rebase.\nIt displays:\n\nthe last two commands executed and\nthe next two lines to be executed.\n\nIt also gives hints to find the whole files in .git directory.\n\n\nTrying and detect the prompt won't work with Git 2.26+, as shown in commit 6d04ce7\n\"git rebase\" has learned to use the merge backend (i.e. the machinery that drives \"rebase -i\") by default, while allowing \"--apply\" option to use the \"apply\" backend (e.g. the moral equivalent of \"format-patch piped to am\").\n(The rebase.backend configuration variable can be set to customize.)\nSee commit 10cdb9f, commit 2ac0d62, commit 8295ed6, commit 76340c8, commit 980b482, commit c2417d3, commit 6d04ce7, commit 52eb738, commit 8af14f0, commit be50c93, commit befb89c, commit 9a70f3d, commit 93122c9, commit 55d2b6d, commit 8a997ed, commit 7db00f0, commit e98c426, commit d48e5e2 (15 Feb 2020), and commit a9ae8fd, commit 22a69fd (16 Jan 2020) by Elijah Newren (newren).\n(Merged by Junio C Hamano -- gitster -- in commit 8c22bd9, 02 Mar 2020)\n\ngit-prompt: change the prompt for interactive-based rebases\n\n\nIn the past, we had different prompts for different types of rebases:\nREBASE: for am-based rebases\nREBASE-m: for merge-based rebases\nREBASE-i: for interactive-based rebases\n\nIt's not clear why this distinction was necessary or helpful; when the\nprompt was added in commit e752019 (\"Improve bash prompt to detect\nvarious states like an unfinished merge\", 2007-09-30, Git v1.5.5-rc0), it simply added these three different types.\nPerhaps there was a useful purpose back then, but there have been some changes:\n\nThe merge backend was deleted after being implemented on top of the interactive backend, causing the prompt for merge-based rebases to change from REBASE-m to REBASE-i.\nThe interactive backend is used for multiple different types of non-interactive rebases, so the \"-i\" part of the prompt doesn't really mean what it used to.\nRebase backends have gained more abilities and have a great deal of overlap, sometimes making it hard to distinguish them.\nBehavioral differences between the backends have also been ironed out.\nWe want to change the default backend from am to interactive, which means people would get \"REBASE-i\" by default if we didn't change the prompt, and only if they specified --am or --whitespace or -C would they get the \"REBASE\" prompt.\nIn the future, we plan to have \"--whitespace\", \"-C\", and even \"--am\" run the interactive backend once it can handle everything the am-backend can.\n\nFor all these reasons, make the prompt for any type of rebase just be \"REBASE\".\n\n\nSince Git 2.17 (March 2018), you also have:\ngit rebase --show-current-patch\n\nIt shows the content of .git/REBASE_HEAD during an interactive rebase which can be paused during conflict."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-merge-tree"
},
{
"role": "assistant",
"content": "Perform merge without touching index or working tree"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Revert to local commit?\nI've pulled code down from my repo which has messed things up. I'd like to revert my entire project to my last local commit. How would I do this?"
},
{
"role": "assistant",
"content": "This will reset everything to your current commit (getting rid of all changes, staged or otherwise:\ngit reset HEAD --hard\n\nThis will reset everything to the previous commit (also getting rid of all changes, staged or otherwise)\ngit reset HEAD^ --hard\n\nthe ^ next to HEAD means one commit before HEAD, HEAD being where you are currently. You can go two commits back by using ^^, or three with ^^^. Additionally you can use a tilde to specify the number of commits: ~3 for three commits back.\ngit reset HEAD~3 --hard\n\nAlso keep in mind that the --hard option means that these commands will throw away any changes you have that are not stashed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I delete a Git remote branch from the NetBeans IDE? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I delete a Git branch locally and remotely?\n\n (41 answers)\n \n\nClosed 10 years ago.\n\n\n\nHow do I delete a Git remote branch?\nI work with NetBeans, and I tried to delete a remote branch from IDE, but on the delete branch it deleted only locally."
},
{
"role": "assistant",
"content": "You can also use\n\ngit push origin --delete <yourBranchName>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git pull --rebase vs git rebase : what's the danger?\nI don't understand the difference between git pull --rebase and git rebase, without any other options.\nI don't understand if they are safe, a good practice, or very dangerous.\nCan I break the history of commits by doing a git pull --rebase in local?"
},
{
"role": "assistant",
"content": "I don't recommend rebasing at all but just for private branches. By private I mean branches that you're pretty sure only you have pulled.\nA rebase changes the starting point of the branch to some newer commit, thus merging all the commits to that point. This could lead to merge conflicts to people that had in their repository the old branch base. I would recommend plain merge always and leave rebasing only for certain situations (feature branches, for example).\nRegarding your question:\n\ngit rebase rebases the branch you want.\ngit pull --rebase performs a fetch + rebase in the branches you pull. Normally a pull would fetch + merge."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Rolling back a remote Git repository\nI have a remote Git repository, and I need to roll back the last n commits into cold oblivion."
},
{
"role": "assistant",
"content": "You can use git revert <commit>… for all the n commits, and then push as usual, keeping history unchanged.\nOr you can \"roll back\" with git reset --hard HEAD~n. If you are pushing in a public or shared repository, you may diverge and break others work based on your original branch. Git will prevent you doing so, but you can use git push -f to force the update."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I remove a commit on GitHub? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nUndoing a 'git push'\n\n (17 answers)\n \n\nClosed 4 years ago.\nThe community reviewed whether to reopen this question 8 months ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\nI \"accidentally\" pushed a commit to GitHub.\nIs it possible to remove this commit?\nI want to revert my GitHub repository as it was before this commit."
},
{
"role": "assistant",
"content": "Note: please see an alternative to git rebase -i in the comments below—\ngit reset --soft HEAD^\n\nFirst, remove the commit on your local repository. You can do this using git rebase -i. For example, if it's your last commit, you can do git rebase -i HEAD~2 and delete the second line within the editor window that pops up.\nThen, force push to GitHub by using git push origin +branchName --force\nSee Git Magic Chapter 5: Lessons of History - And Then Some for more information (i.e. if you want to remove older commits).\nOh, and if your working tree is dirty, you have to do a git stash first, and then a git stash apply after."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %GG"
},
{
"role": "assistant",
"content": "raw verification message from GPG for a signed commit"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to Add Linux Executable Files to .gitignore?\nHow do you add Linux executable files to .gitignore without giving them an explicit extension and without placing them in a specific or /bin directory? Most are named the same as the C file from which they were compiled without the .c extension."
},
{
"role": "assistant",
"content": "Can you ignore all, but source code files?\nFor example:\n*\n!*.c\n!Makefile"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git diff HEAD:file1 file2"
},
{
"role": "assistant",
"content": "compares an (o)bject and a (w)ork tree entity;"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options pushUpdateRejected"
},
{
"role": "assistant",
"content": "Set this variable to false if you want to disable pushNonFFCurrent , pushNonFFMatching , pushAlreadyExists , pushFetchFirst , pushNeedsForce , and pushRefNeedsUpdate simultaneously."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_AUTHOR_NAME"
},
{
"role": "assistant",
"content": "The human-readable name used in the author identity when creating commit or\ntag objects, or when writing reflogs. Overrides the user.name and author.name configuration settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Renaming RStudio project under version control\nWhat's the right way to rename an RStudio project (esp., when that project is under version control)?\nE.g., I created an RStudio project with version control in \"~/myproject\". Then I decided I wanted to rename the project to \"myproject1\". So I \n\nrenamed \"~/myproject\" as \"~/myproject1\"\nrenamed \"myproject.Rproj\" as \"myproject1.Rproj\"\ncommitted the \"rename\" changes with git via RStudio.\n\nEverything seems to be fine. But I have a suspicion I'm missing something and that I'm going to be surprised by some project behavior down the line."
},
{
"role": "assistant",
"content": "If your project is also an R package, you need to edit the DESCRIPTION file and change the value of \"Package\" property to reflect the new name."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --simplify-merges"
},
{
"role": "assistant",
"content": "Additional option to --full-history to remove some needless\nmerges from the resulting history, as there are no selected\ncommits contributing to this merge."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Where can I find the GitHub ID in my account?\n\nWhat is the difference between GitHub username and GitHub ID? I was asked for my Github ID for a certain project and I happened to give my username. But the person is unable to find me on GitHub with my username. So I got a GitHub ID from the below URL:\nhttp://caius.github.io/github_id/\nBut I'm unable to find this ID from my account directly. Where can I find this in my GitHub account? It would be great to elaborate on this."
},
{
"role": "assistant",
"content": "It can be easily retrieved using GitHub API: \nhttps://api.github.com/users/your_github_user_name\n\nwhere instead of your_github_user_name you must use the desired GitHub username.\n\nExample:\nhttps://api.github.com/users/github"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "R and version control for the solo data analyst [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 2 years ago.\n\n\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\n\n Improve this question\n \n\n\n\nMany data analysts that I respect use version control.\nFor example: \n\nhttp://github.com/hadley/\nSee comments on http://permut.wordpress.com/2010/04/21/revision-control-statistics-bleg/\n\nHowever, I'm evaluating whether adopting a version control system such as git would be worthwhile.\nA brief overview:\nI'm a social scientist who uses R to analyse data for research publications.\nI don't currently produce R packages.\nMy R code for a project typically includes a few thousand lines of code for data input, cleaning, manipulation, analyses, and output generation.\nPublications are typically written using LaTeX.\nWith regards to version control there are many benefits which I have read about, yet they seem to be less relevant to the solo data analyst.\n\nBackup: I have a backup system already in place. \nForking and rewinding: I've never felt the need to do this, \n but I can see how it could be useful (e.g., you are preparing multiple \n journal articles based on the same dataset; you are preparing a report \n that is updated monthly, etc)\nCollaboration: Most of the time I am\nanalysing data myself, thus, I\nwouldn't get the collaboration\nbenefits of version control.\n\nThere are also several potential costs involved with adopting version control:\n\nTime to evaluate and learn a version control system\nA possible increase in complexity over my current file management system\n\nHowever, I still have the feeling that I'm missing something.\nGeneral guides on version control seem to be addressed more towards computer scientists than data analysts.\nThus, specifically in relation to data analysts in circumstances similar to those listed above:\n\nIs version control worth the effort?\nWhat are the main pros and cons of adopting version control? \nWhat is a good strategy for getting started with version control\n for data analysis with R (e.g., examples, workflow ideas, software, links to guides)?"
},
{
"role": "assistant",
"content": "I feel the answer to your question is a resounding yes- the benefits of managing your files with a version control system far outweigh the costs of implementing such a system.\nI will try to respond in detail to some of the points you raised:\n\n\nBackup: I have a backup system already in place.\n\n\nYes, and so do I. However, there are some questions to consider regarding the appropriateness of relying on a general purpose backup system to adequately track important and active files relating to your work. On the performance side:\n\nAt what interval does your backup system take snapshots? \nHow long does it take to build a snapshot? \nDoes it have to image your entire hard drive when taking a snapshot, or could it be easily told to just back up two files that just received critical updates?\nCan your backup system show you, with pinpoint accuracy, what changed in your text files from one backup to the next?\n\nAnd most importantly:\n\nHow many locations are the backups saved in? Are they in the same physical location as your computer?\nHow easy is it to restore a given version of a single file from your backup system?\n\nFor example, have a Mac and use Time Machine to backup to another hard drive in my computer. Time Machine is great for recovering the odd file or restoring my system if things get messed up. However it simply doesn't have what it takes to be trusted with my important work:\n\nWhen backing up, Time Machine has to image the whole hard drive which takes a considerable amount of time. If I continue working, there is no guarantee that my file will be captured in the state that it was when I initiated the backup. I also may reach another point I would like to save before the first backup finishes.\nThe hard drive to which my Time Machine backups are saved is located in my machine- this makes my data vulnerable to theft, fire and other disasters.\n\nWith a version control system like Git, I can initiate a backup of specific files with no more effort that requesting a save in a text editor- and the file is imaged and stored instantaneously. Furthermore, Git is distributed so each computer that I work at has a full copy of the repository.\nThis amounts to having my work mirrored across four different computers- nothing short of an act of god could destroy my files and data, at which point I probably wouldn't care too much anyway.\n\n\nForking and rewinding: I've never felt the need to do this, but I can see how it could be useful (e.g., you are preparing multiple journal articles based on the same dataset; you are preparing a report that is updated monthly, etc)\n\n\nAs a soloist, I don't fork that much either. However, the time I have saved by having the option to rewind has single-handedly paid back my investment in learning a version control system many, many times. You say you have never felt the need to do this- but has rewinding any file under your current backup system really been a painless, feasible option?\nSometimes the report just looked better 45 minutes, an hour or two days ago.\n\n\nCollaboration: Most of the time I am\n analysing data myself, thus, I\n wouldn't get the collaboration\n benefits of version control.\n\n\nYes, but you would learn a tool that may prove to be indispensable if you do end up collaborating with others on a project.\n\n\nTime to evaluate and learn a version control system\n\n\nDon't worry too much about this. Version control systems are like programming languages- they have a few key concepts that need to be learned and the rest is just syntactic sugar. Basically, the first version control system you learn will require investing the most time- switching to another one just requires learning how the new system expresses key concepts.\nPick a popular system and go for it!\n\n\nA possible increase in complexity over my current file management system\n\n\nDo you have one folder, say Projects that contains all the folders and files related to your data analysis activities? If so then slapping version control on it is going to increase the complexity of your file system by exactly 0. If your projects are strewn about your computer- then you should centralize them before applying version control and this will end up decreasing the complexity of managing your files- that's why we have a Documents folder after all.\n\n\nIs version control worth the effort?\n\n\nYes! It gives you a huge undo button and allows you to easily transfer work from machine to machine without worrying about things like losing your USB drive.\n\n2 What are the main pros and cons of adopting version control?\n\nThe only con I can think of is a slight increase in file size- but modern version control systems can do absolutely amazing things with compression and selective saving so this is pretty much a moot point.\n\n3 What is a good strategy for getting started with version control for data analysis with R (e.g., examples, workflow ideas, software, links to guides)?\n\nKeep files that generate data or reports under version control, be selective. If you are using something like Sweave, store your .Rnw files and not the .tex files that get produced from them. Store raw data if it would be a pain to re-acquire. If possible, write and store a script that acquires your data and another that cleans or modifies it rather than storing changes to raw data.\nAs for learning a version control system, I highly recommend Git and this guide to it.\nThese websites also have some nice tips and tricks related to performing specific actions with Git:\n\nhttp://www.gitready.com/\nhttp://progit.org/blog.html"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-daemon - A really simple server for Git repositories none"
},
{
"role": "assistant",
"content": "Disable all logging."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cat-file - Provide contents or details of repository objects"
},
{
"role": "assistant",
"content": "OUTPUT If -t is specified, one of the <type> . If -s is specified, the size of the <object> in bytes. If -e is specified, no output, unless the <object> is malformed. If -p is specified, the contents of <object> are pretty-printed. If <type> is specified, the raw (though uncompressed) contents of the <object> will be returned."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-am - Apply a series of patches from a mailbox -k --keep"
},
{
"role": "assistant",
"content": "Pass -k flag to git mailinfo (see git-mailinfo )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs log.showSignature"
},
{
"role": "assistant",
"content": "If true, makes git-log , git-show , and git-whatchanged assume --show-signature ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip"
},
{
"role": "assistant",
"content": "DESCRIPTION If <branch> is specified, git rebase will perform an automatic git switch <branch> before doing anything else. Otherwise\nit remains on the current branch. If <upstream> is not specified, the upstream configured in branch.<name>.remote and branch.<name>.merge options will be used (see git-config for details) and the --fork-point option is\nassumed. If you are currently not on any branch or if the current\nbranch does not have a configured upstream, the rebase will abort. All changes made by commits in the current branch but that are not\nin <upstream> are saved to a temporary area. This is the same set\nof commits that would be shown by git log <upstream>..HEAD ; or by git log 'fork_point'..HEAD , if --fork-point is active (see the\ndescription on --fork-point below); or by git log HEAD , if the --root option is specified. The current branch is reset to <upstream> or <newbase> if the --onto option was supplied. This has the exact same effect as git reset --hard <upstream> (or <newbase> ). ORIG_HEAD is set\nto point at the tip of the branch before the reset. Note ORIG_HEAD is not guaranteed to still point to the previous branch tip\nat the end of the rebase if other commands that write that pseudo-ref\n(e.g. git reset ) are used during the rebase. The previous branch tip,\nhowever, is accessible using the reflog of the current branch\n(i.e. @{1} , see gitrevisions ). The commits that were previously saved into the temporary area are\nthen reapplied to the current branch, one by one, in order. Note that\nany commits in HEAD which introduce the same textual changes as a commit\nin HEAD..<upstream> are omitted (i.e., a patch already accepted upstream\nwith a different commit message or timestamp will be skipped). It is possible that a merge failure will prevent this process from being\ncompletely automatic. You will have to resolve any such merge failure\nand run git rebase --continue . Another option is to bypass the commit\nthat caused the merge failure with git rebase --skip . To check out the\noriginal <branch> and remove the .git/rebase-apply working files, use\nthe command git rebase --abort instead. Assume the following history exists and the current branch is \"topic\": A---B---C topic\n /\n D---E---F---G master From this point, the result of either of the following commands: git rebase master\ngit rebase master topic would be: A'--B'--C' topic\n /\n D---E---F---G master NOTE: The latter form is just a short-hand of git checkout topic followed by git rebase master . When rebase exits topic will\nremain the checked-out branch. If the upstream branch already contains a change you have made (e.g.,\nbecause you mailed a patch which was applied upstream), then that commit\nwill be skipped and warnings will be issued (if the merge backend is\nused). For example, running git rebase master on the following\nhistory (in which A' and A introduce the same set of changes, but\nhave different committer information): A---B---C topic\n /\n D---E---A'---F master will result in: B'---C' topic\n /\n D---E---A'---F master Here is how you would transplant a topic branch based on one\nbranch to another, to pretend that you forked the topic branch\nfrom the latter branch, using rebase --onto . First let’s assume your topic is based on branch next .\nFor example, a feature developed in topic depends on some\nfunctionality which is found in next . o---o---o---o---o master\n \\\n o---o---o---o---o next\n \\\n o---o---o topic We want to make topic forked from branch master ; for example,\nbecause the functionality on which topic depends was merged into the\nmore stable master branch. We want our tree to look like this: o---o---o---o---o master\n | \\\n | o'--o'--o' topic\n \\\n o---o---o---o---o next We can get this using the following command: git rebase --onto master next topic Another example of --onto option is to rebase part of a\nbranch. If we have the following situation: H---I---J topicB\n /\n E---F---G topicA\n /\n A---B---C---D master then the command git rebase --onto master topicA topicB would result in: H'--I'--J' topicB\n /\n | E---F---G topicA\n |/\n A---B---C---D master This is useful when topicB does not depend on topicA. A range of commits could also be removed with rebase. If we have\nthe following situation: E---F---G---H---I---J topicA then the command git rebase --onto topicA~5 topicA~3 topicA would result in the removal of commits F and G: E---H'---I'---J' topicA This is useful if F and G were flawed in some way, or should not be\npart of topicA. Note that the argument to --onto and the <upstream> parameter can be any valid commit-ish. In case of conflict, git rebase will stop at the first problematic commit\nand leave conflict markers in the tree. You can use git diff to locate\nthe markers (<<<<<<) and make edits to resolve the conflict. For each\nfile you edit, you need to tell Git that the conflict has been resolved,\ntypically this would be done with git add <filename> After resolving the conflict manually and updating the index with the\ndesired resolution, you can continue the rebasing process with git rebase --continue Alternatively, you can undo the git rebase with git rebase --abort"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to download and write a file from Github using Requests\n\nLets say there's a file that lives at the github repo:\nhttps://github.com/someguy/brilliant/blob/master/somefile.txt\nI'm trying to use requests to request this file, write the content of it to disk in the current working directory where it can be used later. Right now, I'm using the following code:\nimport requests\nfrom os import getcwd\n\nurl = \"https://github.com/someguy/brilliant/blob/master/somefile.txt\"\ndirectory = getcwd()\nfilename = directory + 'somefile.txt'\nr = requests.get(url)\n\nf = open(filename,'w')\nf.write(r.content)\n\nUndoubtedly ugly, and more importantly, not working. Instead of the expected text, I get:\n<!DOCTYPE html>\n<!--\n\nHello future GitHubber! I bet you're here to remove those nasty inline styles,\nDRY up these templates and make 'em nice and re-usable, right?\n\nPlease, don't. https://github.com/styleguide/templates/2.0\n\n-->\n<html>\n <head>\n <meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\">\n <title>Page not found · GitHub</title>\n <style type=\"text/css\" media=\"screen\">\n body {\n background: #f1f1f1;\n font-family: \"HelveticaNeue\", Helvetica, Arial, sans-serif;\n text-rendering: optimizeLegibility;\n margin: 0; }\n\n .container { margin: 50px auto 40px auto; width: 600px; text-align: center; }\n\n a { color: #4183c4; text-decoration: none; }\n a:visited { color: #4183c4 }\n a:hover { text-decoration: none; }\n\n h1 { letter-spacing: -1px; line-height: 60px; font-size: 60px; font-weight: 100; margin: 0px; text-shadow: 0 1px 0 #fff; }\n p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }\n\n ul { list-style: none; margin: 25px 0; padding: 0; }\n li { display: table-cell; font-weight: bold; width: 1%; }\n #error-suggestions { font-size: 14px; }\n #next-steps { margin: 25px 0 50px 0;}\n #next-steps li { display: block; width: 100%; text-align: center; padding: 5px 0; font-weight: normal; color: rgba(0, 0, 0, 0.5); }\n #next-steps a { font-weight: bold; }\n .divider { border-top: 1px solid #d5d5d5; border-bottom: 1px solid #fafafa;}\n\n #parallax_wrapper {\n position: relative;\n z-index: 0;\n }\n #parallax_field {\n overflow: hidden;\n position: absolute;\n left: 0;\n top: 0;\n height: 370px;\n width: 100%;\n }\n\netc etc.\n \nContent from Github, but not the content of the file. What am I doing wrong?"
},
{
"role": "assistant",
"content": "The content of the file in question is included in the returned data. You are getting the full GitHub view of that file, not just the contents.\nIf you want to download just the file, you need to use the Raw link at the top of the page, which will be (for your example):\nhttps://raw.githubusercontent.com/someguy/brilliant/master/somefile.txt\n\nNote the change in domain name, and the blob/ part of the path is gone.\nTo demonstrate this with the requests GitHub repository itself:\n>>> import requests\n>>> r = requests.get('https://github.com/kennethreitz/requests/blob/master/README.rst')\n>>> 'Requests:' in r.text\nTrue\n>>> r.headers['Content-Type']\n'text/html; charset=utf-8'\n>>> r = requests.get('https://raw.githubusercontent.com/kennethreitz/requests/master/README.rst')\n>>> 'Requests:' in r.text\nTrue\n>>> r.headers['Content-Type']\n'text/plain; charset=utf-8'\n>>> print r.text\nRequests: HTTP for Humans\n=========================\n\n\n.. image:: https://travis-ci.org/kennethreitz/requests.png?branch=master\n[... etc. ...]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Issue in installing php7.2-mcrypt\n\nAs I'm trying to load mcrypt extension module from PHP 7.2.X version.\nSo I tried to make use of PECL library that is compatible to the current version of my PHP, in order to get installed\nand followed this link:\nInstalling mcrypt on PHP 7.2 during installation!\nThese below are the result's obtained after executing certain commands on the terminal.\nroot@YYY:/var/www/html/orocrm# apt install php-pear\nReading package lists... Done\nBuilding dependency tree \nReading state information... Done\nThe following package was automatically installed and is no longer required:\n libllvm4.0\nUse 'sudo apt autoremove' to remove it.\nThe following NEW packages will be installed:\n php-pear\n0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.\nNeed to get 285 kB of archives.\nAfter this operation, 2,107 kB of additional disk space will be used.\nGet:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 php-pear all 1:1.10.5+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1 [285 kB]\nFetched 285 kB in 1s (230 kB/s) \nSelecting previously unselected package php-pear.\n(Reading database ... 215503 files and directories currently installed.)\nPreparing to unpack .../php-pear_1%3a1.10.5+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1_all.deb ...\nUnpacking php-pear (1:1.10.5+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1) ...\nProcessing triggers for man-db (2.7.5-1) ...\nSetting up php-pear (1:1.10.5+submodules+notgz-1+ubuntu16.04.1+deb.sury.org+1) ...\n\nYYY@YYY:/var/www/html/orocrm$ sudo apt-get -y install gcc make autoconf libc-dev pkg-config\n[sudo] password for YYY: \nReading package lists... Done\nBuilding dependency tree \nReading state information... Done\nNote, selecting 'libc6-dev' instead of 'libc-dev'\ngcc is already the newest version (4:5.3.1-1ubuntu1).\nmake is already the newest version (4.1-6).\npkg-config is already the newest version (0.29.1-0ubuntu1).\nlibc6-dev is already the newest version (2.23-0ubuntu9).\nThe following package was automatically installed and is no longer required:\n libllvm4.0\nUse 'sudo apt autoremove' to remove it.\nSuggested packages:\n autoconf-archive gnu-standards autoconf-doc libtool\nThe following NEW packages will be installed:\n autoconf automake autotools-dev libsigsegv2 m4\n0 upgraded, 5 newly installed, 0 to remove and 14 not upgraded.\nNeed to get 1,079 kB of archives.\nAfter this operation, 3,998 kB of additional disk space will be used.\nGet:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libsigsegv2 amd64 2.10-4 [14.1 kB]\nGet:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 m4 amd64 1.4.17-5 [195 kB]\nGet:3 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 autoconf all 2.69-9 [321 kB]\nGet:4 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 autotools-dev all 20150820.1 [39.8 kB]\nGet:5 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 automake all 1:1.15-4ubuntu1 [510 kB]\nFetched 1,079 kB in 2s (447 kB/s) \nSelecting previously unselected package libsigsegv2:amd64.\n(Reading database ... 215198 files and directories currently installed.)\nPreparing to unpack .../libsigsegv2_2.10-4_amd64.deb ...\nUnpacking libsigsegv2:amd64 (2.10-4) ...\nSelecting previously unselected package m4.\nPreparing to unpack .../archives/m4_1.4.17-5_amd64.deb ...\nUnpacking m4 (1.4.17-5) ...\nSelecting previously unselected package autoconf.\nPreparing to unpack .../autoconf_2.69-9_all.deb ...\nUnpacking autoconf (2.69-9) ...\nSelecting previously unselected package autotools-dev.\nPreparing to unpack .../autotools-dev_20150820.1_all.deb ...\nUnpacking autotools-dev (20150820.1) ...\nSelecting previously unselected package automake.\nPreparing to unpack .../automake_1%3a1.15-4ubuntu1_all.deb ...\nUnpacking automake (1:1.15-4ubuntu1) ...\nProcessing triggers for install-info (6.1.0.dfsg.1-5) ...\nProcessing triggers for man-db (2.7.5-1) ...\nProcessing triggers for doc-base (0.10.7) ...\nProcessing 1 added doc-base file...\nSetting up libsigsegv2:amd64 (2.10-4) ...\nSetting up m4 (1.4.17-5) ...\nSetting up autoconf (2.69-9) ...\nSetting up autotools-dev (20150820.1) ...\nSetting up automake (1:1.15-4ubuntu1) ...\nupdate-alternatives: using /usr/bin/automake-1.15 to provide /usr/bin/automake (automake) in auto mode\nProcessing triggers for libc-bin (2.23-0ubuntu9) ...\n\nYYY@YYY:/var/www/html/orocrm$ sudo apt-get -y install libmcrypt-dev\nReading package lists... Done\nBuilding dependency tree \nReading state information... Done\nThe following package was automatically installed and is no longer required:\n libllvm4.0\nUse 'sudo apt autoremove' to remove it.\nThe following NEW packages will be installed:\n libmcrypt-dev\n0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.\nNeed to get 83.7 kB of archives.\nAfter this operation, 438 kB of additional disk space will be used.\nGet:1 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 libmcrypt-dev amd64 2.5.8-3.3 [83.7 kB]\nFetched 83.7 kB in 0s (105 kB/s) \nSelecting previously unselected package libmcrypt-dev.\n(Reading database ... 215484 files and directories currently installed.)\nPreparing to unpack .../libmcrypt-dev_2.5.8-3.3_amd64.deb ...\nUnpacking libmcrypt-dev (2.5.8-3.3) ...\nProcessing triggers for man-db (2.7.5-1) ...\nSetting up libmcrypt-dev (2.5.8-3.3) ...\n\nYYY@YYY:/var/www/html/orocrm$ sudo pecl7.2-sp install --nodeps mcrypt-snapshot\nsudo: pecl7.2-sp: command not found\n\nAs I'm getting this type of Error as pecl7.2-sp: command not found\nFrom the documentation section, it had been clearly stated that it had been deprecated and no longer will be available from the security point of view — since then, from the release version of PHP 7.2.X onward's. \nBut some of the project's need those dependencies, in order to carry out the required functionality as necessary. How do I need to solve the above issue?\n\nUPDATE:\nTL;DR:\nI had a lot of response from the votes to the posted answer. The answers need to be triaged depending upon the OS Architecture level.\nSince I'm using the shared server for hosting, there are more than one projects residing over it & which are coded with the version of PHP 5.X.X, so I decided to downgrade to PHP 7.1.X that \nsupports mcrypt extension by default in my Debian based OS.\nAs I already mentioned in the link while Installing mcrypt Extension on PHP 7.2, by Server Pilot community.\nThese peoples had told a newer version of pecl-7.2 is available to install mcrypt on PHP-7.2. Unfortunately, it ended with \npecl7.2-sp: command not found from the executed commands which were put up. Later the website page got an update, so the commands over there doesn't match the commands that were tried while executing.\nFinally, whichever might be the solutions fit's to your OS Architecture level, Just go for it!.\nOR \nIf the below approaches didn't yield to solve the root cause.\nAlternatively, you can go for PHP 7.1.X version which supports mcrypt extension by default"
},
{
"role": "assistant",
"content": "I followed below steps to install mcrypt for PHP7.2 using PECL.\n\nInstall PECL\n\n\napt-get install php-pecl\n\n\nBefore installing MCRYPT you must install libmcrypt\n\n\napt-get install libmcrypt-dev libreadline-dev\n\n\nInstall MCRYPT 1.0.1 using PECL\n\n\npecl install mcrypt-1.0.1\n\n\nAfter the successful installation \n\n\nYou should add \"extension=mcrypt.so\" to php.ini\n\nPlease comment below if you need any assistance. :-) \n\nIMPORTANT !\nAccording to php.net reference many (all) mcrypt functions have\n been DEPRECATED as of PHP 7.1.0. Relying on this function is\n highly discouraged."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Advice on multiple release lines and git-flow, for git non-gurus\nOur software product line requires developing and maintaining multiple software versions concurrently. We are relative Git newbies and recently adopted Git Flow to take advantage of Driessen's branching model. We have a very small software team with few dedicated developers (we all wear many hats) and no \"integration guru.\"\nMuch searching has turned up little specific advice on how to adapt Git and Git Flow to our needs. What has turned up is that Git Flow is not well suited to supporting multiple versions concurrently. One related discussion on SO has answers indicating separate branch names need to be used to track separate versions' histories. This, and related strategies, eliminates Git Flow unless it is modified; see our team limitations above for a reason why this isn't practical for us.\nThe key question is what have others found to be a good approach for implementing Driessen's branching model as closely as possible while supporting multiple release lines?\nUPDATES:\nDistilling the answers below (particularly @Rasmus') with more targeted searching and internal discussions on a few options leads to the following solution that we are implementing, and which I offer as one approach that may be relevant to similar teams under similar conditions.\nWe won't continue to use Git Flow. Instead, we will apply Driessen's model to each individual release line in a repo by prefacing each branch name with its intended release string, e.g.:\nr1.5/develop\n\nAll versions of a project are contained in the Git repository. Starting a new project version consists of creating a small set of new long-lived branches prefaced by the release string (e.g. r1.6/develop and, in our case, r1.6/release; no master with its implication of the single current good buildable state).\nWe establish one central public repository per project on a server that will be the main avenue for sharing code through local repo remote links. A push to this repository signifies code that is ready to be consumed by others. Merging RX.Y/develop into and then pushing the RX.Y/release branch signifies code that is intended for release. feature, hotfix, et. al. branches are handled similarly. The branch merge/commit history for a given release line is clean and understandable. We don't want the typical Git distributed repo strategy in favor of avoiding the complexity of merging such repos that, over time, are likely to diverge in structure.\nIn some Git GUIs (such as SourceTree for example) this branch structure is recognized and displayed as hierarchical, which helps understand the top-level history of a project from the branch structure.\nApologies for not up-voting any answers; my reputation on SO is not yet the minimum required to do so."
},
{
"role": "assistant",
"content": "we are having a similar setup except we have more than 300 dedicated developers, we have exactly what you described several revision we need to deliver to different customers. \nWe have divided it so we have an initial ref like refs/heads/platformX.Y/ then we build on that \nSo depending on what you need to do you checkout platformX.Y/develop and start working from that point on a feature branch and you merge back to develop when you are done. \nThis works for us and we can follow the nvie model. \non top of everything we are merging all these platformX.Y branch to our main develop branch so errors corrected on those branches are released in to the latest software as well."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Undo “git add <dir>”?\nI mistakenly added files using the command \"git add dir\". I have not yet run \"git commit\". Is there a way to remove this dir and everything contained within it from the commit?\nI have tried git reset dir, but it didn't work. Apparently git reset file is the way to undo it. But I have so many files and so little time."
},
{
"role": "assistant",
"content": "To remove a directory and everything inside it from the index,\ngit rm --cached -r dir\nThe --cached switch makes git rm operate on the index only and not touch the working copy. The -r switch makes it recursive."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Trigger Github Actions only when PR is merged\nI have a github actions yaml file as follows:\nname: Test deployment\non:\n pull_request:\n branches:\n - master\n\njobs:\n deploy:\n runs-on: ubuntu-18.04\n steps:\n - name: Random name\n run: date\n\n\nWhen I raise a PR from a branch to master branch, Github Action gets triggered. So, I updated my YAML to:\nname: Test deployment\non:\n pull_request:\n types:\n - closed\n branches:\n - master\n\n\nNow it is triggered when I merge the PR rather than while raising it. But it also gets triggered when I close the PR without merging it.\nI found nothing like merged type in docs\nEven the following syntax i tried does not work as expected:\njobs:\n ...\n if: github.event_name == 'pull_request' && github.event.action == 'closed'\n\nCan anyone pls help me out here?\nIs it possible for me to check if the PR is approved by atleast one reviewer? (I can enable branch protection, but wanted to know if any option exists for doing it in github actions)"
},
{
"role": "assistant",
"content": "There is no pull-request-merged event.\nThe closest thing you can get is to subscribe to push event, since a merged PR will always create a push event to the branch it's being merged onto.\nIf you only care about PRs to master then you can specify that:\non:\n push:\n branches:\n - master\n\nThe other thing you can do is filter on each step individually\n - name: Do something\n if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true\n run: ...\n\n(Edit, as of 2022)\nPer the GitHub docs, this should be possible now via:\non:\n pull_request:\n types:\n - closed\n\njobs:\n if_merged:\n if: github.event.pull_request.merged == true\n runs-on: ubuntu-latest\n steps:\n - run: |\n echo The PR was merged"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs git log -L '/int main/',/^}/:main.c"
},
{
"role": "assistant",
"content": "Shows how the function main() in the file main.c evolved\nover time."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Show git ahead and behind info for all branches, including remotes\nOn a github project you can go to a /branches page and se pretty graphs like this one that for each branch show how far behind and how far ahead each branch is with respect to master.\n\nIs there a command line tool that does something similar? Something that works with remotes as well? For example,\ngit branch -v -v\n\nis close to what I am looking for, but only works for local branches."
},
{
"role": "assistant",
"content": "I've been curious about this as well, so i just whipped up a git branch-status script that gives this information using git for-each-ref\n#!/bin/bash\n# by http://github.com/jehiah\n# this prints out some branch status (similar to the '... ahead' info you get from git status)\n \n# example:\n# $ git branch-status\n# dns_check (ahead 1) | (behind 112) origin/master\n# master (ahead 2) | (behind 0) origin/master\n \ngit for-each-ref --format=\"%(refname:short) %(upstream:short)\" refs/heads | \\\nwhile read local remote\ndo\n [ -z \"$remote\" ] && continue\n git rev-list --left-right \"${local}...${remote}\" -- 2>/dev/null >/tmp/git_upstream_status_delta || continue\n LEFT_AHEAD=$(grep -c '^<' /tmp/git_upstream_status_delta)\n RIGHT_AHEAD=$(grep -c '^>' /tmp/git_upstream_status_delta)\n echo \"$local (ahead $LEFT_AHEAD) | (behind $RIGHT_AHEAD) $remote\"\ndone\n\nUsage:\n$ git branch-status\ndns_check (ahead 1) | (behind 112) origin/master\nmaster (ahead 2) | (behind 0) origin/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to show gitlab badges per branch in readme.md\n\nI am trying to show the build status of my branch on that branch's readme.md.\nhttps://mygitlab.com/<namespace>/<project>/badges/<branch>/coverage.svg I tried this but branch place holder isn't getting evaluated."
},
{
"role": "assistant",
"content": "You could create a README.md with the following for each branch\n[](https://gitlab.com/<namespace>/<project>/)\n\nfor example:\nMaster Branch README.md\n\nOther Branch README.md"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules"
},
{
"role": "assistant",
"content": "NAME git-submodule - Initialize, update or inspect submodules"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitlab-ci-runner choose executer \"Please enter the executor:\"\n\nI have ran gitlab-ci-multi-runner in a container by docker.\nWhen I execute the gitlab-ci-multi-runner register in the container,it ask \n\nPlease enter the executor: docker...?\n\nIf I choose docker,does it mean a docker container will run on the current container?\nSorry for my poor english :)"
},
{
"role": "assistant",
"content": "By choosing 'docker' as the CI runner executor a docker container will be created to run the builds. If you are unsure about which executor to use the 'shell' executor is probably your best choice. gitlab-ci-multi-runner configuration documentation has more information on how to configure the various executors."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission -M[<n>] --find-renames[=<n>]"
},
{
"role": "assistant",
"content": "Detect renames.\nIf n is specified, it is a threshold on the similarity\nindex (i.e. amount of addition/deletions compared to the\nfile’s size). For example, -M90% means Git should consider a\ndelete/add pair to be a rename if more than 90% of the file\nhasn’t changed. Without a % sign, the number is to be read as\na fraction, with a decimal point before it. I.e., -M5 becomes\n0.5, and is thus the same as -M50% . Similarly, -M05 is\nthe same as -M5% . To limit detection to exact renames, use -M100% . The default similarity index is 50%."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to suppress the editor for `git rebase --continue`?\nI'm often rebasing interactive to make tiny changes in the history (for example removing a blank line, or editing one line). In most cases those changes are based on some peer review.\nAt first I do my change like that:\ngit rebase --interactive 83bbeb27fcb1b5e164318fa17c55b7a38e5d3c9d~\n# replace \"pick\" by \"edit\" on the first line\n# modify code\ngit commit --all --amend --no-edit\ngit rebase --continue\n\nIf there are merge conflicts in one of the following commits, I resolve them and do this:\ngit rebase --continue\n# the commit message is shown, but does not have to be changed, so I just save and exit the editor\ngit rebase --continue\n# the commit message is shown, but does not have to be changed, so I just save and exit the editor\ngit rebase --continue\n# the commit message is shown, but does not have to be changed, so I just save and exit the editor\n...\n\nIs there anything like a --no-edit argument to git rebase --continue that avoids the editor (similar to git commit)?"
},
{
"role": "assistant",
"content": "First approach, through Git configuration:\ngit -c core.editor=true rebase --continue\n\nOr, with environment variables:\nGIT_EDITOR=true git rebase --continue\n\nThis will override the editor that git uses for message confirmation. true command simply ends with zero exit code. It makes git continue rebase as if user closed interactive editor.\nOn Windows, you would need to use CMD /V /C\ncmd /V /C \"set \"GIT_EDITOR=true\" && git rebase --continue\n\nIn both OS, you can use aliases\n# Linux\nalias grc='GIT_EDITOR=true git rebase --continue'\n\n# Windows\ndoskey grc=cmd /V /C \"set \"GIT_EDITOR=true\" && git rebase --continue\"\n\nThen a simple grc will be enough to continue the rebase without the editor popping up.\n\nDavid Gardiner adds in the comments:\n\nIn PowerShell, use:\n$env:GIT_EDITOR = \"true -and git rebase --continue\"\n\nthen tidy up with\n $env:GIT_EDITOR = \"\"\n\n\n\nTo set that globally (without alias), maybe consider this approach:\n\nspecifying the core.commentChar detected from the .git/rebase-merge/message (here @):\ngit --global core.commentChar @\n\n\nThere is also GIT_SEQUENCE_EDITOR=:, but you cannot always leave it at that value, because that would break all the rebase operation where you want an editor.\nThat is why having an alias remains the most flexible and accurate approach, rather than relying on a global setting which might break other rebase editor use cases."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git squash history after merge\nI merged an upstream of a large project with my local git repo. Prior to the merge I had a small amount of history that was easy to read through, but after the merge a massive amount of history is now in my repo. I have no need for all the history commits from the upstream repo.\nThere have been other commits made after this upstream merge that I would like to keep. How do I squash all that history that was merged from the upstream into one commit while keeping the commits made after the upstream merge?"
},
{
"role": "assistant",
"content": "I was able to squash several commits after multiple merges from the master branch using the strategy found here: https://stackoverflow.com/a/17141512/1388104\ngit checkout my-branch # The branch you want to squash\ngit branch -m my-branch-old # Change the name to something old\ngit checkout master # Checkout the master branch\ngit checkout -b my-branch # Create a new branch\ngit merge --squash my-branch-old # Get all the changes from your old branch\ngit commit # Create one new commit\n\nYou will have to force an update if you need to push your squashed branch to a remote repository that you have previously pushed to, e.g. git push origin my-branch -f"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-clone"
},
{
"role": "assistant",
"content": "Clone a repository into a new directory"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to check the differences between a local and GitHub repository before the pull [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\ngit diff between cloned and original remote repository\n\n (3 answers)\n \n\nClosed 10 years ago.\n\n\n\nBefore using pull, I want to check if there are any differences between my local and GitHub master.\nHow can I do it?"
},
{
"role": "assistant",
"content": "git pull is really equivalent to running git fetch and then git merge. The git fetch updates your so-called \"remote-tracking branches\" - typically these are ones that look like origin/master, github/experiment, etc. that you see with git branch -r. These are like a cache of the state of branches in the remote repository that are updated when you do git fetch (or a successful git push).\nSo, suppose you've got a remote called origin that refers to your GitHub repository, you would do:\ngit fetch origin\n\n... and then do:\ngit diff master origin/master\n\n... in order to see the difference between your master, and the one on GitHub. If you're happy with those differences, you can merge them in with git merge origin/master, assuming master is your current branch.\nPersonally, I think that doing git fetch and git merge separately is generally a good idea."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to unmerge a Git merge?\nI accidentally did a git pull origin master from dev, and master got merged into dev.\nIs it possible to unmerge?\nI've already seen different solutions, i tried this one from both dev and master :\ngit revert -m 1 <commit> (once each)\nBut i got : Everything is up-to-date, each time"
},
{
"role": "assistant",
"content": "You can reset your branch to the state it was in just before the merge if you find the commit it was on then.\nOne way is to use git reflog, it will list all the HEADs you've had.\nI find that git reflog --relative-date is very useful as it shows how long ago each change happened.\nOnce you find that commit just do a git reset --hard <commit id> and your branch will be as it was before.\nIf you have SourceTree, you can look up the <commit id> there if git reflog is too overwhelming."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree -s --stage"
},
{
"role": "assistant",
"content": "Show staged contents' mode bits, object name and stage number in the output."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitrevisions - Specifying revisions and ranges for Git MERGE_HEAD"
},
{
"role": "assistant",
"content": "records the commit(s) which you are merging into your branch when you\nrun git merge ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit - Record changes to the repository --status"
},
{
"role": "assistant",
"content": "Include the output of git-status in the commit\nmessage template when using an editor to prepare the commit\nmessage. Defaults to on, but can be used to override\nconfiguration variable commit.status."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options trace2.eventNesting"
},
{
"role": "assistant",
"content": "Integer. Specifies desired depth of nested regions in the\nevent output. Regions deeper than this value will be\nomitted. May be overridden by the GIT_TRACE2_EVENT_NESTING environment variable. Defaults to 2."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --expand-tabs=<n> --expand-tabs --no-expand-tabs"
},
{
"role": "assistant",
"content": "Perform a tab expansion (replace each tab with enough spaces\nto fill to the next display column that is a multiple of <n> )\nin the log message before showing it in the output. --expand-tabs is a short-hand for --expand-tabs=8 , and --no-expand-tabs is a short-hand for --expand-tabs=0 ,\nwhich disables tab expansion. By default, tabs are expanded in pretty formats that indent the log\nmessage by 4 spaces (i.e. medium , which is the default, full ,\nand fuller )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to un-commit last un-pushed git commit without losing the changes\nIs there a way to revert a commit so that my local copy keeps the changes made in that commit, but they become non-committed changes in my working copy? Rolling back a commit takes you to the previous commit - I want to keep the changes made but I committed them to the wrong branch.\nThis has not been pushed, only committed."
},
{
"role": "assistant",
"content": "There are a lot of ways to do so, for example:\nin case you have not pushed the commit publicly yet:\ngit reset HEAD~1 --soft \n\nThat's it, your commit changes will be in your working directory, whereas the LAST commit will be removed from your current branch. See git reset man\n\nIn case you did push publicly (on a branch called 'master'):\ngit checkout -b MyCommit //save your commit in a separate branch just in case (so you don't have to dig it from reflog in case you screw up :) )\n\nrevert commit normally and push \ngit checkout master\ngit revert a8172f36 #hash of the commit you want to destroy\n# this introduces a new commit (say, it's hash is 86b48ba) which removes changes, introduced in the commit in question (but those changes are still visible in the history)\ngit push origin master\n\nnow if you want to have those changes as you local changes in your working copy (\"so that your local copy keeps the changes made in that commit\") - just revert the revert commit with --no-commit option:\ngit revert --no-commit 86b48ba (hash of the revert commit).\n\nI've crafted a small example: https://github.com/Isantipov/git-revert/commits/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-grep - Print lines matching a pattern --no-recursive"
},
{
"role": "assistant",
"content": "Same as --max-depth=0 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-gui command crashes on macOS Sierra\nAfter update to macOS Sierra, git-gui command crashes with an error:\n\nWish[23862:202062] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [0 nan]'\n*** First throw call stack:\n(\n 0 CoreFoundation 0x00007fff8cd9252b __exceptionPreprocess + 171\n 1 libobjc.A.dylib 0x00007fffa146acad objc_exception_throw + 48\n 2 CoreFoundation 0x00007fff8ce10a0d +[NSException raise:format:] + 205\n 3 QuartzCore 0x00007fff92938980 _ZN2CA5Layer12set_positionERKNS_4Vec2IdEEb + 152\n 4 QuartzCore 0x00007fff92938af5 -[CALayer setPosition:] + 44\n 5 QuartzCore 0x00007fff9293914b -[CALayer setFrame:] + 644\n 6 CoreUI 0x00007fff986e2112 _ZN20CUICoreThemeRenderer26MakeOrUpdateScrollBarLayerEPK13CUIDescriptoraPP7CALayer + 1284\n 7 CoreUI 0x00007fff986de317 _ZN20CUICoreThemeRenderer19CreateOrUpdateLayerEPK13CUIDescriptorPP7CALayer + 1755\n 8 CoreUI 0x00007fff986604d1 _ZN11CUIRenderer19CreateOrUpdateLayerEPK14__CFDictionaryPP7CALayer + 175\n 9 CoreUI 0x00007fff98663185 CUICreateOrUpdateLayer + 221\n 10 AppKit 0x00007fff8b3c7623 -[NSCompositeAppearance _callCoreUIWithBlock:options:] + 226\n 11 AppKit 0x00007fff8aa74a9d -[NSAppearance _createOrUpdateLayer:options:] + 76\n 12 AppKit 0x00007fff8aced143 -[NSScrollerImp _animateToRolloverState] + 274\n 13 AppKit 0x00007fff8acacb79 __49-[NSScrollerImp _installDelayedRolloverAnimation]_block_invoke + 673\n 14 AppKit 0x00007fff8ab73331 -[NSScrollerImp _doWork:] + 15\n 15 Foundation 0x00007fff8e770c88 __NSFireDelayedPerform + 417\n 16 CoreFoundation 0x00007fff8cd11e14 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20\n 17 CoreFoundation 0x00007fff8cd11a9f __CFRunLoopDoTimer + 1071\n 18 CoreFoundation 0x00007fff8cd115fa __CFRunLoopDoTimers + 298\n 19 CoreFoundation 0x00007fff8cd09021 __CFRunLoopRun + 2065\n 20 CoreFoundation 0x00007fff8cd085b4 CFRunLoopRunSpecific + 420\n 21 Tcl 0x0000000101834b43 Tcl_WaitForEvent + 314\n 22 Tcl 0x00000001018045cd Tcl_DoOneEvent + 274\n 23 Tk 0x0000000101672f4f Tk_MainLoop + 33\n 24 Tk 0x000000010167ea5b Tk_MainEx + 1566\n 25 Wish 0x0000000101658542 Wish + 9538\n 26 libdyld.dylib 0x00007fffa1d48255 start + 1\n)\nlibc++abi.dylib: terminating with uncaught exception of type NSException\nerror: git-gui died of signal 6\n\nDoes anybody have the same problem and a solution for this?"
},
{
"role": "assistant",
"content": "Try:\ngit config --local --unset gui.geometry \nThis error occurs due to Tk Geometry manager does not work, due to older version or if it is corrupt.\nIf the above command didn't work try updating your xcode:\nxcode-select --install"
}
] |
Subsets and Splits