messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-var" }, { "role": "assistant", "content": "Show a Git logical variable" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to set up a git project to use an external repo submodule?\nI'd like to create a repo which pulls in a remote repo.\nFor example, let's say jQuery as a submodule:\ngit://github.com/jquery/jquery.git\n\nWhat would be the process of creating a repo with jQuery as a submodule and adding my own external as a remote repo.\nAlso once this is setup, if I push / pull to my own remote, will the external remain intact?" }, { "role": "assistant", "content": "You have a project -- call it MyWebApp that already has a github repo\nYou want to use the jquery repository in your project\nYou want to pull the jquery repo into your project as a submodule.\n\nSubmodules are really, really easy to reference and use. Assuming you already have MyWebApp set up as a repo, from terminal issue these commands:\ncd MyWebApp\ngit submodule add git://github.com/jquery/jquery.git externals/jquery\n\nThis will create a directory named externals/jquery* and link it to the github jquery repository. Now we just need to init the submodule and clone the code to it: \ngit submodule update --init --recursive\n\nYou should now have all the latest code cloned into the submodule. If the jquery repo changes and you want to pull the latest code down, just issue the submodule update command again. Please note: I typically have a number of external repositories in my projects, so I always group the repos under an \"externals\" directory.\nThe online Pro Git Book has some good information on submodules (and git in general) presented in an easy-to-read fashion. Alternately, git help submodule will also give good information. Or take a look at the Git Submodule Tutorial on the git wiki.\nI noticed this blog entry which talks about submodules and compares them to Subversion's svn:externals mechanism: http://speirs.org/blog/2009/5/11/understanding-git-submodules.html \n* As a best practice, you should always place your submodules in their own directory, such as Externals. If you don't, your root project directory can become very cluttered very fast." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git submodule update --remote vs git pull\nWhat is the difference between running \ngit submodule update --remote\n\nvs \ncd <submodule directoy>\ngit pull\n\nAssuming that the submodule was previously set to track some branch:\ngit submodule add -b master [URL to Git repo]" }, { "role": "assistant", "content": "The difference is:\n\ngit pull will only update your submodule branch, but it can be any branch that you could have checked out yourself in that submodule repo.\ngit submodule update --remote will only update the branch registered in the .gitmodule, and by default, you will end up with a detached HEAD, unless --rebase or --merge is specified or the key submodule.$name.update is set to rebase, merge or none.\n\nIn both cases, you still have to go back to the parent repo, add and commit the new submodule SHA1 reference.\nThat is because in both instances, the SHA1 of the submodule changes, which means the gitlink (special entry in the index of the parent repo, named after to root folder of the submodule) must be added and committed.\nA git submodule update --init --remote is like:\n\ngit submodule init: to initialize (checkout) the submodules recorded in the index\ngit submodule update --remote: to pull from the registered branch (or master by default), once the submodule has been initialized (checked out)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-receive-pack" }, { "role": "assistant", "content": "Receive what is pushed into the repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Command-line Git on Windows\nI have installed msysGit 1.7.10 on my Windows 7 machine.\nWhat I need to know is if I can still use Git from command line?\nWhen I try the git command in the command line right now I see:\n\n'git' is not recognized as an internal or external command, operable program or batch file.\n\nIs there any way I can enable the Git command line?" }, { "role": "assistant", "content": "I had the same issue and resolved it by adding the /bin directory location to the PATH Environment Variable.\n\nSearch for the file location where Git was installed, mine is C:\\Users\\(My UserName)\\AppData\\Local\\GitHub. It may also be C:\\Program Files (x86)\\Git\nOnce you have the location of Git you should see a /bin sub-folder. It may be in a PortableGit folder (mine is\nPortableGit_015aa71ef18c047ce8509ffb2f9e4bb0e3e73f13). Copy this path.\nGo to Control Panel > System > System Protection > Advanced > Environment Variables\nChoose PATH, click edit and paste the bin path there. If there are already any values in your PATH paste your Git path at the end separated with a semi-colon.\n\nNow you can access Git command from CMD." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --prefix <arg>" }, { "role": "assistant", "content": "Behave as if git rev-parse was invoked from the <arg> subdirectory of the working tree. Any relative filenames are\nresolved as if they are prefixed by <arg> and will be printed\nin that form. This can be used to convert arguments to a command run in a subdirectory\nso that they can still be used after moving to the top-level of the\nrepository. For example: prefix=$(git rev-parse --show-prefix)\ncd \"$(git rev-parse --show-toplevel)\"\n# rev-parse provides the -- needed for 'set'\neval \"set $(git rev-parse --sq --prefix \"$prefix\" -- \"$@\")\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git, whitespace errors, squelching and autocrlf, the definitive answers\nPlease can you explain about whitespace errors in git, what do they mean, what is 'squelching', and do I need to worry about it?\n(Running msysgit, but with other users on linux).\nThere is already a 'definitive' answer for autocrlf here (set it to false git config --global core.autocrlf false\n)" }, { "role": "assistant", "content": "Squelching is initially a function used in telecommunication to set a threshold above which a signal is or isn't alllowed through.\nIn your case, when you see:\nwarning: squelched 104 whitespace errors\nwarning: 109 lines add whitespace errors. \n\nIt means: instead of displaying 100+ error messages, it warns you it should have displayed those errors (but it won't, in order to not clutter the output)\nI have no definitive recommendations for whitespace policy, except from identifying why they are introduced in the first place.\nIf your editor doesn't convert the eol (end of lines) characters between Window and Unix, then it means it somehow add or remove automatically whitespaces, which is not always useful.\nA first test (as in this blog post) is to de-activate the policy:\ngit config core.whitespace nowarn\n\nor try \ngit config core.whitespace fix\n\nand see if that facilitates your rebase operations." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "\"fatal: HttpRequestException encountered.\" Error with GitHub/Bitbucket Repositories due to dropping TLS-1.0 support\n\nProblem\nI recently encountered the following message when I pushed to a GitHub repo:\n\"fatal: HttpRequestException encountered. \"\nfollowed by being prompted for my username and password again. \nFrom previous searches, Visual Studio and various others have the same root problem. For those lazier than I am, a summary of the various solutions for different applications/OS are here with relevant discussions. Hopefully people find this helpful.\nReason\nCan't really call updating sercurity a problem, so here's the reason. The issue is GitHub has removed TLS-1.0 support which is causing the problem with clients including Microsoft Visual Studio's built in git client, versions of Git below 1.14 as well as GUI clients includint tortoiseGit, etc. The full release notes can be found here: \nhttps://githubengineering.com/crypto-removal-notice/\nBitbucket will drop TLSv1.0 and TLSv1.1 starting 1 Dec 2018. I expect similar problems as before. \nSolution\nEdit: moved my self-answer to an answer box. See below." }, { "role": "assistant", "content": "Git hub has removed TLS-1.0 from it's authentication services. https://githubengineering.com/crypto-removal-notice/\nSolutions\nWindows Clients\nUse Version 2.14.3 (or newer) of Git for Windows and newer include an up-to-date Git Credential Manager for Windows: https://gitforwindows.org/\nYou can also explicitly update your Git Windows Credential Manager to the latest version, 1.14.0, to get TLS-1.2 support: https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.14.0\nVisual Studio Clients\nIt is suggested to update your client to VS 2017 or, if you cannot upgrade, there are two machine-wide registry keys you can set that affect all .NET-based applications on the client machine that you can change... https://developercommunity.visualstudio.com/content/problem/201457/unable-to-connect-to-github-due-to-tls-12-only-cha.html\nJDK\nTLS-1.2 is default in JDK8 and available in JDK7.\nhttps://blogs.oracle.com/java-platform-group/diagnosing-tls,-ssl,-and-https\nRed Hat native Git clients\nRH 5 does not support TLS-1.2 and GitHubEngineering suggest updating to newer versions of the OS. RH 6.8 and 7.2 will support TLS-1.2. https://www.linuxquestions.org/questions/blog/mensawater-183304/rhel5-wont-support-tlsv1-1-or-higher-36951/" } ]
[ { "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?\n\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": "How to set up a code review using Gitlab?\nHow does one set up a code review using Gitlab? I see it listed as a feature on the Gitlab website, but I can't seem to find instructions on how to set one up (For that matter, any link to a Gitlab user manual would be most appreciated). \nSome of my searching has indicated that 'Merge Requests' are the way to go... but I'm finding them limiting. An issued merge request shows all of the commits between one branch and the other. I seem to only be able to view diffs generated for each individual commit. For example, let's say I have a file I want to review. It is a new file but I've submitted changes to it over 10 commits on a dev branch. If I issue a merge request for that dev branch from integration I see 10 commits each of which show the incremental changes made to the file... I want to review the entire thing. It is new! \nAm I barking up the wrong tree here? Is there an actual code-review tool I can use in GitLab, or are merge requests the way to go, and if they are am I using them incorrectly? what's the best way to set up a proper code review here?" }, { "role": "assistant", "content": "Note: since GitLab 6.4, side-by-side diff view is available: see \"pull request 5308\".\n(July 2013)There is no possibility yet to comment on each line though, only at the file level.\nDaniel Sokolowski mentions in the comments that Per line comments are now supported (09/2014):\n\nYour team members can comment on the merge request in general or on specific lines with line comments.\n\nThat still can help for code review activity.\n\n\n6 years later, for GitLab 13.1 (June 2020):\n\nMerge Request Reviews moved to Core\n\n\nOriginally introduced in GitLab 11.4 as a GitLab Premium feature, Merge Request Reviews allow merge request reviewers to:\n\nsubmit multiple comments at once,\ncutting down on notification noise for the merge request author, and\nallowing for a more cohesive and streamlined review process.\n\n\n\n\nSince its introduction, we’ve re-evaluated its place in our buyer-based pricing model and as part of 13.1 we’re excited to announce this feature has now moved to GitLab Core.\n\nSee Documentation and Issue\n\nWith GitLab 13.9 (February 2021), you also have:\n\nRequest a follow-up review from a Reviewer\nMerge request authors receive feedback from reviewers. Often, this feedback needs to be re-reviewed to make sure all issues have been appropriately addressed. As the author of the contribution, you need to communicate the need for a follow-up to your reviewer.\nFor reviewers who have already reviewed a merge request, you can now request a re-review. This request triggers a To-Do item and email notification to alert the user that you need a follow-up review of your contribution.\n\nSee Documentation and Issue.\n\n\nWith GitLab 13.11 (April 2021)\n\nAdd standalone comments to merge request reviews\nWhen you’re reviewing changes, you may want to summarize your feedback, or comment on something unrelated to the specific changes. Reviews in GitLab only allowed commenting on the changes or replying to existing comments, which meant that other kinds of comments had to be made after submitting the review.\nAs part of your review process, you can now submit a general comment along with your replies or change-specific comments. General comments make it simple to provide feedback to the author and use quick actions to update items across the merge request.\nThanks to Lee Tickett for the contribution!\n\nSee Documentation and Issue." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to make git push origin --force ; in Visual Studio Team Explorer\nI recently had an issue where I had to disregard my last commit, so on the command line I did following:\ngit push origin --force\n\nthis works fine, however I normally make my push/pulls from inside Visual Studio Team Explorer, however I could not find out how to --force a push from there\nIs it possible or can it only be done from command line?" }, { "role": "assistant", "content": "You can enable --force without using command prompt in visual studio 2017 as follows Open team explorer.\n\nTeam Explorer>Settings>Git>Global Settings\n\ncheck the enable push --force checkbox and that should do the trick like so \nFor more info check out this link\nPS. **This feature is only available in visual studio 2017+ **" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Force push current branch\nI often rebase feature branches and then want to force push them to the server.\ngit push --force origin feature-mongodb-support\n\nIs there any shortcut for git push --force origin <current branch>?" }, { "role": "assistant", "content": "You can use aliases to shorten the command. Use it like this:\ngit config --global alias.fpush \"push --force origin\"\n\nNow to push your branch just type:\ngit fpush feature-mongodb-support\n\nOr you can even hardcode the branch name into the command:\ngit alias fpush \"push --force origin feature-mongodb-support\"\n\nand use only git fpush to push your precious work into the upstream.\nHowever, non-fast-forward updates are dangerous since you will basically overwrite all the history on server that occurred between the last merge/rebase into your local branch and the forced push. If you need to do them often there is definitely something wrong in your workflow." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push existing repo to a new and different remote repo server?\nSay I have a repository on git.fedorahosted.org and I want to clone this into my account at github to have my own playground aside from the more \"official\" repo on fedorahosted.\nWhat would be the steps to initially copy that over?\nWithin github there is this nice \"fork\" button, but I can't use this for obvious reasons.\nAnd how would I track changes in the fedorahosted repo into the github one?" }, { "role": "assistant", "content": "Create a new repo at github.\nClone the repo from fedorahosted to your local machine.\ngit remote rename origin upstream\ngit remote add origin URL_TO_GITHUB_REPO\ngit push origin master\n\nNow you can work with it just like any other github repo. To pull in patches from upstream, simply run git pull upstream master && git push origin master.\nGitHub has recently renamed its master branch to main so (depending on whether your branch is called master or main) in step 5 you might have to use git push origin main and for pulling patches from upstream git pull upstream main && git push origin main, otherwise you will receive an error message." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Minimum hardware requirements for gitlab-runner\n\nHow can I determine what is the minimum hardware requirement for install the gitlab-runner on a host? \nI want a specific runner which will run tests, build docker images, and deploy the apps." }, { "role": "assistant", "content": "Gitlab documentation gives some advices and put focus on memory :\n\nDepending on how you decide to configure GitLab Runner and what tools you use to exercise your application in the CI environment, GitLab Runner can consume significant amount of available memory.\n\nAfter that, it's really depending the type of application you want to test/build/deploy. Test and build job will be the largest resource consumers. You can also set limits on cpu/memory for docker runner." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to find a Github file 's SHA blob\nI'm using this API to update a file on my repo, it requires me to have a valid SHA blob for a file that I want to update:\nhttp://developer.github.com/v3/repos/contents/\nHow do I find the SHA blob for the specific file? Supposed in my testrepo in the test account here, what is the SHA blob for the test.txt file?\nhttps://github.com/testacc01/testrepo01\nThank you so much!" }, { "role": "assistant", "content": "The docs for updating a file specify that you will need to provide the SHA for the file you will be replacing. The easiest way would be to query github for that, too. For example:\n> curl https://api.github.com/repos/testacc01/testrepo01/contents/test.txt\n{\n \"name\": \"test.txt\",\n \"path\": \"test.txt\",\n \"sha\": \"4f8a0fd8ab3537b85a64dcffa1487f4196164d78\",\n \"size\": 13,\n …\n\nSo, you can see what the SHA is in the \"sha\" field of the JSON response. Use that when you formulate your request to update the file with a new version. After you have successfully updated the file, the file will have a new SHA that you will need to request before it can be updated again. (Unless, I guess, your next update goes on a different branch.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to get back to most recent version in Git?\nI have recently moved from SVN to Git and am a bit confused about something. I needed to run the previous version of a script through a debugger, so I did git checkout <previous version hash> and did what I needed to do.\nNow I want to get back to the newest version, but I don't know the hash for it. When I type git log, I don't see it.\nHow can I do this? Also, is there an easier way to change versions than by typing out hashes - something like \"go back two versions\" or \"go to the most chronologically recent\"?" }, { "role": "assistant", "content": "git checkout master should do the trick. To go back two versions, you could say something like git checkout HEAD~2, but better to create a temporary branch based on that time, so git checkout -b temp_branch HEAD~2" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why is a git 'pull request' not called a 'push request'?\nThe terminology used to merge a branch with an official repository is a 'pull request'. This is confusing, as it appears that I am requesting to push my changes to the official repository.\nWhy is it called a pull request and not a push request?" }, { "role": "assistant", "content": "If you have a code change in your repository, and want to move it to a target repository, then:\n\n\"Push\" is you forcing the changes being present in the target repository (git push). \n\"Pull\" is the target repository grabbing your changes to be present there (git pull from the other repo).\n\nA \"pull request\" is you requesting the target repository to please grab your changes. \nA \"push request\" would be the target repository requesting you to push your changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Role of docker-in-docker (dind) service in gitlab ci\n\nAccording to the official gitlab documentation, one way to enable docker build within ci pipelines, is to make use of the dind service (in terms of gitlab-ci services).\nHowever, as it is always the case with ci jobs running on docker executors, the docker:latest image is also needed.\nCould someone explain:\n\nwhat is the difference between the docker:dind and the docker:latest images?\n(most importantly): why are both the service and the docker image needed (e.g. as indicated in this example, linked to from the github documentation) to perform e.g. a docker build whithin a ci job? doesn't the docker:latest image (within which the job will be executed!) incorporate the docker daemon (and I think the docker-compose also), which are the tools necessary for the commands we need (e.g. docker build, docker push etc)?\n\nUnless I am wrong, the question more or less becomes:\n\nWhy a docker client and a docker daemon cannot reside in the same docker (enabled) container" }, { "role": "assistant", "content": "what is the difference between the docker:dind and the docker:latest images?\n\n\ndocker:latest contains everything necessary to connect to a docker daemon, i.e., to run docker build, docker run and such. It also contains the docker daemon but it's not started as its entrypoint.\ndocker:dind builds on docker:latest and starts a docker daemon as its entrypoint.\n\nSo, their content is almost the same but through their entrypoints one is configured to connect to tcp://docker:2375 as a client while the other is meant to be used for a daemon.\n\nwhy are both the service and the docker image needed […]?\n\nYou don't need both. You can just use either of the two, start dockerd as a first step, and then run your docker build and docker run commands as usual like I did here; apparently this was the original approach in gitlab at some point. But I find it cleaner to just write services: docker:dind instead of having a before_script to setup dockerd. Also you don't have to figure out how to start & install dockerd properly in your base image (if you are not using docker:latest.)\nDeclaring the service in your .gitlab-ci.yml also lets you swap out the docker-in-docker easily if you know that your runner is mounting its /var/run/docker.sock into your image. You can set the protected variable DOCKER_HOST to unix:///var/run/docker.sock to get faster builds. Others who don't have access to such a runner can still fork your repository and fallback to the dind service without modifying your .gitlab-ci.yml." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to view multiple git branches at the same time for the same project?\nI have 2 branches, which are not ready to be merged yet, but have some complementary logic, which I'd like to review (before merging)\nCan I check out multiple git branches of the same project? Is it possible?" }, { "role": "assistant", "content": "You can simply copy the repository to a new location (either by literally copying the directory, or using git clone --shared) and check out one branch per location.\nYou can also use git-worktree for creating multiple working directories from a single instance of a repository.\nOtherwise, the primary means for comparing files between branches prior to merging them is git diff." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Which files generated by Autotools should I keep in version control repository?\nI am new to autotools and I am working on a C project. I want to add my project to a git repository. Which files generated by the autotools I need to track in my version control system and which should be ignored?" }, { "role": "assistant", "content": "You should not keep any files under version control that are not hand-edited. That means any generated file should be ignored by the version control system. I basically put only the following under version control:\n\nconfigure.ac \nMakefile.am \nthe documentation files such as AUTHORS, NEWS etc.\nMakefile.am in subdirectories\n\nTo address the point of having a \"ready-to-install\" version brought up by Scharron, some people include a script in the project's root directory, called bootstrap or autogen.sh, that you run once when you check a fresh copy out. You can see an example in one of my projects here. For a simpler project, your autogen.sh really only needs to consist of one line:\nautoreconf --install || exit 1\n\nalthough some people prefer to run ./configure automatically at the end of autogen.sh.\nWhy not track all the generated files in version control? Because their contents depend on the machine you are building on, the version of autotools you generated them with, and the phase of the moon. Any time any of these changes, the generated autotools files will change, and you will get a lot of junk in your commits.\nAlso, anyone who checks your code out of version control in order to build it should be expected to have proper development tools installed, so you really don't need to worry about people running into trouble because of missing autotools. \nWhat VonC says about C projects coming with a configure file to generate the Makefiles is true for source code distributions (the .tar.gz file that you get when you type make dist) but not necessarily for freshly checked out copies from version control." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to discard local changes and pull latest from GitHub repository\n\nI have a directory on my machine where I store all projects from GitHub. I opened one of them and made changes locally on my machine. Project got messed up and now I want to discard all the changes I made and pull the latest version from the repository. I am relatively new to GitHub, using Git Shell. \nWould git pull command be sufficient?\nDo I need to do anything extra to discard the changes made locally?\nCan anyone help?" }, { "role": "assistant", "content": "git reset is what you want, but I'm going to add a couple extra things you might find useful that the other answers didn't mention.\ngit reset --hard HEAD resets your changes back to the last commit that your local repo has tracked. If you made a commit, did not push it to GitHub, and want to throw that away too, see @absiddiqueLive's answer.\ngit clean -df will discard any new files or directories that you may have added, in case you want to throw those away. If you haven't added any, you don't have to run this.\ngit pull (or if you are using git shell with the GitHub client) git sync will get the new changes from GitHub.\nEdit from way in the future:\nI updated my git shell the other week and noticed that the git sync command is no longer defined by default. For the record, typing git sync was equivalent to git pull && git push in bash. I find it still helpful so it is in my bashrc." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes --ignore-missing" }, { "role": "assistant", "content": "Do not consider it an error to request removing notes from an\nobject that does not have notes attached to it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git diff [<options>] <commit>...<commit> [--] [<path>…​]" }, { "role": "assistant", "content": "This form is to view the changes on the branch containing\nand up to the second <commit>, starting at a common ancestor\nof both <commit>. git diff A...B is equivalent to git diff $(git merge-base A B) B . You can omit any one\nof <commit>, which has the same effect as using HEAD instead." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Activating conda environment during gitlab CI\n\nMy .gitlab-ci.yml file looks like this:\nanomalydetector:\n image: continuumio/miniconda:4.7.10\n stage: build\n tags:\n - docker\n script:\n - conda env create -f environment.yml\n - conda activate my-env\n - pytest tests/.\n\nOn Gitlab, this job starts fine, and the logs read\n$ conda env create -f environment.yml\nCollecting package metadata (repodata.json): ...working... done\nSolving environment: ...working... done\n\n\n==> WARNING: A newer version of conda exists. <==\n current version: 4.7.10\n latest version: 4.7.11\n\nOk, so I'm using a conda version later than 4.4, so conda activate should work. However, the job fails with the following:\n# To activate this environment, use\n#\n# $ conda activate my-env\n#\n# To deactivate an active environment, use\n#\n# $ conda deactivate\n\n$ conda activate my-env\n\nCommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.\nTo initialize your shell, run\n\n $ conda init <SHELL_NAME>\n\nI have then tried editing my .gitlab-ci.yml file so that there is a command\nconda init bash\n\nbut then get the message\n==> For changes to take effect, close and re-open your current shell. <==\n\nHow can I activate my conda environment in the gitlab CI process?" }, { "role": "assistant", "content": "conda init touches the .bashrc file. To reinitialize the shell you can source it:\n - conda create --name myenv\n - conda init bash\n - source ~/.bashrc # <- !!!\n - conda activate myenv \n\nWhether this is better or worse than source activate myenv is a separate discussion, I guess." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-reset - Reset current HEAD to the specified state git reset [-q] [<tree-ish>] [--] <pathspec>…​ git reset [-q] [--pathspec-from-file=<file> [--pathspec-file-nul]] [<tree-ish>]" }, { "role": "assistant", "content": "These forms reset the index entries for all paths that match the <pathspec> to their state at <tree-ish> . (It does not affect\nthe working tree or the current branch.) This means that git reset <pathspec> is the opposite of git add\n<pathspec> . This command is equivalent to git restore [--source=<tree-ish>] --staged <pathspec>... . After running git reset <pathspec> to update the index entry, you can\nuse git-restore to check the contents out of the index to\nthe working tree. Alternatively, using git-restore and specifying a commit with --source , you\ncan copy the contents of a path out of a commit to the index and to the\nworking tree in one go." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git ^<rev> (caret) Notation" }, { "role": "assistant", "content": "To exclude commits reachable from a commit, a prefix ^ notation is used. E.g. ^r1 r2 means commits reachable\nfrom r2 but exclude the ones reachable from r1 (i.e. r1 and\nits ancestors)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff-index - Compare a tree to the working tree or index" }, { "role": "assistant", "content": "CACHED MODE If --cached is specified, it allows you to ask: show me the differences between HEAD and the current index\ncontents (the ones I'd write using 'git write-tree') For example, let’s say that you have worked on your working directory, updated\nsome files in the index and are ready to commit. You want to see exactly what you are going to commit, without having to write a new tree\nobject and compare it that way, and to do that, you just do git diff-index --cached HEAD Example: let’s say I had renamed commit.c to git-commit.c , and I had\ndone an update-index to make that effective in the index file. git diff-files wouldn’t show anything at all, since the index file\nmatches my working directory. But doing a git diff-index does: torvalds@ppc970:~/git> git diff-index --cached HEAD\n:100644 000000 4161aecc6700a2eb579e842af0b7f22b98443f74 0000000000000000000000000000000000000000 D\tcommit.c\n:000000 100644 0000000000000000000000000000000000000000 4161aecc6700a2eb579e842af0b7f22b98443f74 A\tgit-commit.c You can see easily that the above is a rename. In fact, git diff-index --cached should always be entirely equivalent to\nactually doing a git write-tree and comparing that. Except this one is much\nnicer for the case where you just want to check where you are. So doing a git diff-index --cached is basically very useful when you are\nasking yourself \"what have I already marked for being committed, and\nwhat’s the difference to a previous tree\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to move a branch backwards in git?\n\nThe title is not very clear. What I actually need to do often is the following:\nLet's say I have a development going on with several commits c1,c2,... and 3 branches A,B,C\nc1--c2--c3--(B)--c4--(A,C)\n\nBranch A and C are at the same commit.\nNow I want branch A to go back where B is, so that it looks like this:\nc1--c2--c3--(A,B)--c4--(C)\n\nImportant is that this has to happen locally and on GitHub." }, { "role": "assistant", "content": "Use the reset subcommand:\ngit checkout A\ngit reset --hard B\ngit push --force github\n\nAs a sidenote, you should be careful when using git reset while a branch has been pushed elsewhere already. This may cause trouble to those who have already checked out your changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub pull request showing commits that are already in target branch\nI'm trying to review a pull request on GitHub to a branch that isn't master. The target branch was behind master and the pull request showed commits from master, so I merged master and pushed it to GitHub, but the commits and diff for them still appear in the pull request after refreshing. I've doubled checked that the branch on GitHub has the commits from master. Why are they still appearing in the pull request?\nI've also checked out the pull request locally and it only shows the un-merged commits." }, { "role": "assistant", "content": "Here's a good workaround. Use the Edit button when viewing the PR in GitHub to change the base branch to something other than master. Then switch it back to master and it will now correctly show only the changes from the most recent commits." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Ignore new commits for git submodule\nBackground\nUsing Git 1.8.1.1 on Linux. The repository looks as follows:\nmaster\n book\n\nThe submodule was created as follows:\n$ cd /path/to/master\n$ git submodule add https://[email protected]/user/repo.git book\n\nThe book submodule is clean:\n$ cd /path/to/master/book/\n$ git status\n# On branch master\nnothing to commit, working directory clean\n\nProblem\nThe master, on the other hand, shows there are \"new commits\" for the book submodule:\n$ cd /path/to/master/\n$ git status\n# On branch master\n# Changes not staged for commit:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: book (new commits)\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nGit should ignore the submodule directory completely, so that the master is also clean:\n$ cd /path/to/master/\n$ git status\n# On branch master\nnothing to commit, working directory clean\n\nFailed Attempt #1 - dirty\nInside the file master/.gitmodules is the following, as per this answer:\n[submodule \"book\"]\n path = book\n url = https://[email protected]/user/repo.git\n ignore = dirty\n\nFailed Attempt #2 - untracked\nChanged master/.gitmodules to the following, as per this answer:\n[submodule \"book\"]\n path = book\n url = https://[email protected]/user/repo.git\n ignore = untracked\n\nFailed Attempt #3 - showUntrackedFiles\nEdited master/.git/config to the following, as per this answer:\n[status]\n showUntrackedFiles = no\n\nFailed Attempt #4 - ignore\nAdded the book directory to the master ignore file:\n$ cd /path/to/master/\n$ echo book > .gitignore\n\nFailed Attempt #5 - clone\nAdded the book directory to the master as follows:\n$ cd /path/to/master/\n$ rm -rf book\n$ git clone https://[email protected]/user/repo.git book\n\nQuestion\nHow can the book submodule be in its own repository directory under the master repository yet have git ignore the book submodule? That is, the following should not display:\n#\n# modified: book (new commits)\n#\n\nHow to suppress that message when executing git status in the master repository?\nAn article about git submodule pitfalls suggests this an inappropriate submodule usage?" }, { "role": "assistant", "content": "Just run:\n$ git submodule update\n\nThis will revert the submodule the to old commit (specified in parent-repo), without updating the parent-repo with the latest version of the submodule." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I make Git ignore file mode (chmod) changes?\nI have a project in which I have to change the mode of files with chmod to 777 while developing, but which should not change in the main repo. \nGit picks up on chmod -R 777 . and marks all files as changed. Is there a way to make Git ignore mode changes that have been made to files?" }, { "role": "assistant", "content": "Try:\ngit config core.fileMode false\n\nFrom git-config(1):\n\ncore.fileMode\n Tells Git if the executable bit of files in the working tree\n is to be honored.\n\n Some filesystems lose the executable bit when a file that is\n marked as executable is checked out, or checks out a\n non-executable file with executable bit on. git-clone(1)\n or git-init(1) probe the filesystem to see if it handles the \n executable bit correctly and this variable is automatically\n set as necessary.\n\n A repository, however, may be on a filesystem that handles\n the filemode correctly, and this variable is set to true when\n created, but later may be made accessible from another\n environment that loses the filemode (e.g. exporting ext4\n via CIFS mount, visiting a Cygwin created repository with Git\n for Windows or Eclipse). In such a case it may be necessary\n to set this variable to false. See git-update-index(1).\n\n The default is true (when core.filemode is not specified\n in the config file).\n\n\nThe -c flag can be used to set this option for one-off commands:\ngit -c core.fileMode=false diff\n\nTyping the -c core.fileMode=false can be bothersome and so you can set this flag for all git repos or just for one git repo:\n# this will set your the flag for your user for all git repos (modifies `$HOME/.gitconfig`)\n# WARNING: this will be override by local config, fileMode value is automatically selected with latest version of git.\n# This mean that if git detect your current filesystem is compatible it will set local core.fileMode to true when you clone or init a repository.\n# Tool like cygwin emulation will be detected as compatible and so your local setting WILL BE SET to true no matter what you set in global setting.\ngit config --global core.fileMode false\n\n# this will set the flag for one git repo (modifies `$current_git_repo/.git/config`)\ngit config core.fileMode false\n\nAdditionally, git clone and git init explicitly set core.fileMode to true in the repo config as discussed in Git global core.fileMode false overridden locally on clone\nWarning\ncore.fileMode is not the best practice and should be used carefully. This setting only covers the executable bit of mode and never the read/write bits. In many cases you think you need this setting because you did something like chmod -R 777, making all your files executable. But in most projects most files don't need and should not be executable for security reasons.\nThe proper way to solve this kind of situation is to handle folder and file permission separately, with something like:\nfind . -type d -exec chmod a+rwx {} \\; # Make folders traversable and read/write\nfind . -type f -exec chmod a+rw {} \\; # Make files read/write\n\nIf you do that, you'll never need to use core.fileMode, except in very rare environment." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index" }, { "role": "assistant", "content": "DESCRIPTION Reads the supplied diff output (i.e. \"a patch\") and applies it to files.\nWhen running from a subdirectory in a repository, patched paths\noutside the directory are ignored.\nWith the --index option, the patch is also applied to the index, and\nwith the --cached option, the patch is only applied to the index.\nWithout these options, the command applies the patch only to files,\nand does not require them to be in a Git repository. This command applies the patch but does not create a commit. Use git-am to create commits from patches generated by git-format-patch and/or received by email." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can deleted .git be restored?\nThis happened when working with git on Ruby on Rails.\nseveral commits and branches were done and created.\ngit version 1.7.3.4\n\nI accidentally deleted the .git folder using\ngit -rf .git\n\nbut I have all the files and updates done on online git-hub repository.\nI want the .git folder restored. Questions ?\n\nAm I totally screwed up ? OR \nIf theres a way to restore .git from my online git-hub repository, how can\nthat be done ?" }, { "role": "assistant", "content": "The only way you can restore a deleted .git folder is by:\n\nCloning it again from somewhere\nChecking your recycling bin or backup (if no remote repository exists)\n\nSince your files are from the online github repository, then its simple. Just clone it again from the directory where you deleted the .git folder:\ngit init\ngit remote add origin <repo_address>\ngit pull origin master\n\nwhere repo_address can be [email protected]:yourname/yourproject.git\nYour local checkout will be back to normal. \nIf you have uncommitted changes in your working copy you would want to keep, instead of using git pull use git fetch and then git reset --soft your local branch to the remote branch it should be at. The soft reset will not change your working copy" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-read-tree - Reads tree information into the index -q --quiet" }, { "role": "assistant", "content": "Quiet, suppress feedback messages." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --root" }, { "role": "assistant", "content": "Treat the revision argument as a <revision-range>, even if it\nis just a single commit (that would normally be treated as a\n<since>). Note that root commits included in the specified\nrange are always formatted as creation patches, independently\nof this flag." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository --allow-empty" }, { "role": "assistant", "content": "Usually recording a commit that has the exact same tree as its\nsole parent commit is a mistake, and the command prevents you\nfrom making such a commit. This option bypasses the safety, and\nis primarily for use by foreign SCM interface scripts." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.<driver>.textconv" }, { "role": "assistant", "content": "The command that the diff driver should call to generate the\ntext-converted version of a file. The result of the\nconversion is used to generate a human-readable diff. See gitattributes for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Bash Command on Windows, yarn command not found\n\nI following this online tutorial on downloading and installing web files from GIT HUB. I got down to the topic: Starting Our Static Website, there I'm prompted to enter the commands to download and install the web files. However, when I enter the command yarn install, I get the following prompt: bash: yarn: command not found\nHow can this problem be resolved?\nI'm using GIT Bash command prompt on Windows 10." }, { "role": "assistant", "content": "If you are using Mintty (Bash) then you simply do npm install -g yarn" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-restore - Restore working tree files --conflict=<style>" }, { "role": "assistant", "content": "The same as --merge option above, but changes the way the\nconflicting hunks are presented, overriding the merge.conflictStyle configuration variable. Possible values\nare \"merge\" (default), \"diff3\", and \"zdiff3\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc" }, { "role": "assistant", "content": "NAME git-diff - Show changes between commits, commit and working tree, etc" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a way to squash a number of commits non-interactively?\nI'm trying to squash a range of commits - HEAD to HEAD~3. Is there a quick way to do this, or do I need to use rebase --interactive?" }, { "role": "assistant", "content": "Make sure your working tree is clean, then\ngit reset --soft HEAD~3\ngit commit -m 'new commit message'" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do you fork your own repository on GitHub?\nI have a public repository on GitHub. I want to replicate/copy it and work on a new project based on this repository, but I don't want to affect how it is now. I tried forking it using the GitHub UI but it didn't do anything." }, { "role": "assistant", "content": "I don't think you can fork your own repo.\nClone it and push it to a new repo is good but you need to:\ngit clone https://github.com/userName/Repo New_Repo\ncd New_Repo\ngit remote set-url origin https://github.com/userName/New_Repo\ngit remote add upstream https://github.com/userName/Repo\ngit push origin master\ngit push --all\n\n(see git push)\nSee the all process described at \"Fork your own project on GitHub\".\n\nSix years later (2016), you now have the GitHub importer which allows you to import a repo from another source... including GitHub.\nSee \"Importing a repository with GitHub Importer\"\n\nnarf's answer (upvoted) also illustrate that process.\nThat will allow you to create a new repository and import the full history of the old one into the new one, using its GitHub url.\nAgain: what you get is a copy, not a real fork: you cannot make pull request from the new repo to the old one.\nAgain (bis), as stated in the comments by mpersico, this is not a TRUE FORK.\n\nIf I have a foo which is the canonical source repo for an open source project that I want other people to fork and have access to do PR, then I do not want to work in that repo, I want a fork I can use to issue proper PRs against my project.\nI have solved this my creating a second account in GitHub and forking to that." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %p" }, { "role": "assistant", "content": "abbreviated parent hashes" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip find-renames[=<n>]" }, { "role": "assistant", "content": "Turn on rename detection, optionally setting the similarity\nthreshold. This is the default. This overrides the merge.renames configuration variable.\nSee also git-diff --find-renames ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options gc.repackFilterTo" }, { "role": "assistant", "content": "When repacking and using a filter, see gc.repackFilter , the\nspecified location will be used to create the packfile\ncontaining the filtered out objects. WARNING: The\nspecified location should be accessible, using for example the\nGit alternates mechanism, otherwise the repo could be\nconsidered corrupt by Git as it migh not be able to access the\nobjects in that packfile. See the --filter-to=<dir> option\nof git-repack and the objects/info/alternates section of gitrepository-layout ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git create branch from current checked out master?\nThere is a git controlled folder on a server where the main branch is checked out and a whole pile of files have been modified and not committed. Is there a way for me to commit the changes to a separate branch so I can go back to a clean version?\nie I want to effecitvely undo all this persons changes but store them in another chance so if that person wants their changes they can switch to that branch.\n(Yes I know this is not how git is designed to work but that is my situation!) Any ideas very much appreciated." }, { "role": "assistant", "content": "First of all moving to a different branch based in the current HEAD is performed like this:\ngit checkout -b newbranch\n\nCommit all the changes (assuming no newly added files, otherwise git add them):\ngit commit -a\n\nGo back to the master branch:\ngit checkout master\n\nThe previously uncommitted changes will all be on the newbranch branch, and master will still be at the state it was without those changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Removing/undoing a merge on Sourcetree\nI made quite few changes in my project (I was working on a remote branch and not the master), I committed them and created a pull request on BitBucket and merged the branch to master. I had forgotten to push my changes after the commit. Now, after trying switching the current branch to my remote branch and reverting to the commit before the merge, I managed to get all my changes back and back them up elsewhere in my system. What I want to do now is undo the bad merge that I did. Each time I click on the merge and select \"Reverse commit\", I get the following error message:\n\n\"error: Commit is a merge but no -m option was given.\nfatal: revert failed\"\n\nThe branches look like this now:\n\nI want to remove the merge and bring it to a state such that it doesn't say master(4 behind) anymore." }, { "role": "assistant", "content": "This method is based on history deletion:\n\nCheck out the branch you made the mistake on\nRight click on the commit you want to reset the branch to\nClick \"Reset current branch to this commit\"\nSelect \"Hard\" mode and click \"OK\"\nUnfortunately you need terminal to do this bit. Type git push origin name_of_branch --force into terminal (you may need to enter your git repo username and password for it to accept the command)\n\nUpdate: The current version of source tree supports forced pushes. That means you don't need to use the command mentioned in step 5! There is a check box visible when pushing that is labled \"force\". It is usually disabled.\nHow to enabled the force push checkbox:\n\n\"Tools\" (in the blue bar at the top of the screen)\n\"Options\"\n\"Git\" tab\n\"Enable Force Push\" (2nd section)\n\"OK\"\n\nCheck that checkbox when pushing to also fix the mistake on the origin server.\nThis is probably the easiest way to do it but since it is based on history deletion, If others are working on the project, make sure to let them all know what you are doing so you don't break anyone's git repository.\nUpdate 2: If you use Visual Studio Code as your code editor, I highly recommend installing the \"Git Graph\" extension. It allows you to do practically everything that Source Tree allows you to do, but you can do it from directly inside your code editor! The steps for doing this using Git Graph are roughly the same as the steps for doing this in Source Tree." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git push results in fatal: protocol error: bad line length character: This\nI am trying to get GitLab working on my server (running CentOS 6.5). I followed the gitlab-receipe to the line, but I just can't get it working. I am able to access the web interface, create new projects but pushing to the master branch returns the following error : \nfatal: protocol error: bad line length character: This\n\nI have done checks on the production environment, here are the results : \nChecking Environment ...\n\nGit configured for git user? ... yes\n\nChecking Environment ... Finished\n\nChecking GitLab Shell ...\n\nGitLab Shell version >= 1.7.9 ? ... OK (1.8.0)\nRepo base directory exists? ... yes\nRepo base directory is a symlink? ... no\nRepo base owned by git:git? ... yes\nRepo base access is drwxrws---? ... yes\nupdate hook up-to-date? ... yes\nupdate hooks in repos are links: ... \nASC / Wiki ... repository is empty\nRunning /home/git/gitlab-shell/bin/check\nCheck GitLab API access: OK\nCheck directories and files: \n /home/git/repositories: OK\n /home/git/.ssh/authorized_keys: OK\nTest redis-cli executable: redis-cli 2.4.10\nSend ping to redis server: PONG\ngitlab-shell self-check successful\n\nChecking GitLab Shell ... Finished\n\nChecking Sidekiq ...\n\nRunning? ... yes\nNumber of Sidekiq processes ... 1\n\nChecking Sidekiq ... Finished\n\nChecking LDAP ...\n\nLDAP is disabled in config/gitlab.yml\n\nChecking LDAP ... Finished\n\nChecking GitLab ...\n\nDatabase config exists? ... yes\nDatabase is SQLite ... no\nAll migrations up? ... yes\nGitLab config exists? ... yes\nGitLab config outdated? ... no\nLog directory writable? ... yes\nTmp directory writable? ... yes\nInit script exists? ... yes\nInit script up-to-date? ... no\n Try fixing it:\n Redownload the init script\n For more information see:\n doc/install/installation.md in section \"Install Init Script\"\n Please fix the error above and rerun the checks.\nprojects have namespace: ... \nASC / Wiki ... yes\nProjects have satellites? ... \nASC / Wiki ... can't create, repository is empty\nRedis version >= 2.0.0? ... yes\nYour git bin path is \"/usr/bin/git\"\nGit version >= 1.7.10 ? ... yes (1.8.3)\n\nChecking GitLab ... Finished\n\nFor the init script error, the receipt says \n\nDo not mind about that error if you are sure that you have downloaded\n the up-to-date\n\nso as I have downloaded the latest one, I can't really do much about it.\nI've been banging my head for the past week, and can not figure out why this error is occurring, any help would appreciated!!" }, { "role": "assistant", "content": "If anyone else has this problem, the solution is to change the login shell of the user 'git' (or whatever your user is called) to /bin/bash. This can be done via the command : usermod -s /bin/bash git (Link). The reason for changing the login shell is because the default shell for the git user is /sbin/nologin (or similar, depending on environment), which prevents the git application from logging in as the git user on the git server." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why is branching and merging easier in Mercurial than in Subversion?\nHandling multiple merges onto branches in Subversion or CVS is just one of those things that has to be experienced. It is inordinately easier to keep track of branches and merges in Mercurial (and probably any other distributed system) but I don't know why. Does anyone else know?\nMy question stems from the fact that with Mercurial you can adopt a working practice similar to that of Subversions/CVSs central repository and everything will work just fine. You can do multiple merges on the same branch and you won't need endless scraps of paper with commit numbers and tag names.\nI know the latest version of Subversion has the ability to track merges to branches so you don't get quite the same degree of hassle but it was a huge and major development on their side and it still doesn't do everything the development team would like it to do.\nThere must be a fundamental difference in the way it all works." }, { "role": "assistant", "content": "In Subversion (and CVS), the repository is first and foremost. In git\n and mercurial there is not really the concept of a repository in the\n same way; here changes are the central theme.\n\n+1\nThe hassle in CVS/SVN comes from the fact that these systems do not\nremember the parenthood of changes. In Git and Mercurial,\nnot only can a commit have multiple children, it can also have multiple\nparents!\nThat can easily observed using one of the graphical tools, gitk or hg\nview. In the following example, branch #2 was forked from #1 at\ncommit A, and has since been merged once (at M, merged with commit B):\no---A---o---B---o---C (branch #1)\n \\ \\\n o---o---M---X---? (branch #2)\n\nNote how A and B have two children, whereas M has two parents. These\nrelationships are recorded in the repository. Let's say the maintainer of\nbranch #2 now wants to merge the latest changes from branch #1, they can\nissue a command such as:\n$ git merge branch-1\n\nand the tool will automatically know that the base is B--because it\nwas recorded in commit M, an ancestor of the tip of #2--and\nthat it has to merge whatever happened\nbetween B and C. CVS does not record this information, nor did SVN prior to\nversion 1.5. In these systems, the graph\nwould look like:\no---A---o---B---o---C (branch #1)\n \\ \n o---o---M---X---? (branch #2)\n\nwhere M is just a gigantic \"squashed\" commit of everything that happened between A and B,\napplied on top of M. Note that after the deed is done, there is no trace\nleft (except potentially in human-readable comments) of where M did\noriginate from, nor of how many commits were collapsed together--making\nhistory much more impenetrable.\nWorse still, performing a second merge becomes a nightmare: one has to figure out\nwhat the merge base was at the time of the first merge (and one has to know\nthat there has been a merge in the first place!), then\npresent that information to the tool so that it does not try to replay A..B on\ntop of M. All of this is difficult enough when working in close collaboration, but is\nsimply impossible in a distributed environment.\nA (related) problem is that there is no way to answer the question: \"does X\ncontain B?\" where B is a\npotentially important bug fix. So, why not just record that information in the commit, since\nit is known at merge time!\nP.-S. -- I have no experience with SVN 1.5+ merge recording abilities, but the workflow seems to be much more\ncontrived than in the distributed systems. If that is indeed the case, it's probably because--as mentioned\nin the above comment--the focus is put on repository organization rather than on the changes themselves." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to protect \"master\" in github?\nI have a few contributors in my github project. I want to allow only one of them to \"push\" to master. And this guy is not me (the owner of the repository). Is it possible to do?" }, { "role": "assistant", "content": "Back then, when this question was posted, GitHub didn't allow you to specify access privileges on a branch level. You can only do it on a repository level. So what you are requesting wasn't possible.\nIf you want to work around this limitation, I personally see two options:\n\nyou could use some kind of commit hooks, etc. to at least inform someone that something wrong happened\nIf you really need this tight control, you could use two repositories, one only holding your \"master\" branch. You would then need to make sure that only your \"guy\" gets write access to the master repository\n\nI think it is easier to solve that with some organisation. In my team, we never push anything directly to master, but instead always create pull requests. That ensures that at least someone takes a look before code gets merged and you could also define a policy that only your \"guy\" is allowed to merge pull requests.\nUpdate\nGitHub now announced that they will roll-out a new feature called protected branches. This feature has been present in other git distributions like Atlassian Stash for years. It will allow you to protect some branches from pushes. However, it still doesn't allow complete ACL-based protection of individual branches. So you might want to check this feature out in case you don't want to rely on an organizational solution as outline above." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options commitGraph.generationVersion" }, { "role": "assistant", "content": "Specifies the type of generation number version to use when writing\nor reading the commit-graph file. If version 1 is specified, then\nthe corrected commit dates will not be written or read. Defaults to\n2." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-config" }, { "role": "assistant", "content": "Get and set repository or global options" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --no-ext-diff" }, { "role": "assistant", "content": "Disallow external diff drivers." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git pushing to a private repo\nI have been working on my local on a web app and I was ask to push it to an empty(only read me file on it) private repo created just for this project. I'm new to git and I'm having trouble doing so. \nCan someone tell me what am I doing wrong? \nI first navigate to the main folder of the app in my local using command line and initialize git. After, I try cloning the remote repo with:\ngit clone git://github.com/somename/Web-App.git\n\nbut I get the error:\n\nCloning into 'Web-App'... fatal: remote error: Repository not\n found.\n\nI know the repo is there.. Do I actually need to clone or pull from that remote first or is there a way to just push to that repo. \nAgain, all I'm trying to do is to get the files that I have in my local pushed to a specific repo that I was given access to. \nI will really appreciate any help." }, { "role": "assistant", "content": "Let us say 'yourWebApp' is the folder you have your local web app. Change it to the directory\ncd 'yourWebApp'\n\nInit git in the folder\ngit init\n\nNow add your github url as a remote\ngit remote add origin git://github.com/somename/Web-App.git\n\nHere origin is the short name for your url\nNow pull the read me file from the github repo\n git pull origin master\n\nNow push your web app to the github repository\ngit push origin master\n\nHere it is assumed that you are in your master, the default branch\nHere pulling your readme files is necessary to merge the readme file with your local work. If your github repository is empty, you can skip the pull and directly push to your github repository.\nOn the other hand, if you want to use clone, there is no need to init as clone automatically sets up git in the directory. clone also sets your remote git url. In that case, your workflow should be\n git clone https://github.com/path/to/your/repo\n make some changes\n git add your changes\n git commit your changes\n git push" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc files" }, { "role": "assistant", "content": "Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Jenkins not able to fetch code from remote git\nMy jenkins build is suddenly not working now.The error is as follows:-\nFetching changes from the remote Git repository\n > git config remote.origin.url <url> # timeout=10\nERROR: Error fetching remote repo 'origin'\nhudson.plugins.git.GitException: Failed to fetch from <url>\n at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:735)\n at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:983)\n at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1016)\n at hudson.scm.SCM.checkout(SCM.java:484)\n at hudson.model.AbstractProject.checkout(AbstractProject.java:1270)\n at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)\n at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)\n at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)\n at hudson.model.Run.execute(Run.java:1759)\n at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)\n at hudson.model.ResourceController.execute(ResourceController.java:89)\n at hudson.model.Executor.run(Executor.java:240)\nCaused by: hudson.plugins.git.GitException: Command \"git config remote.origin.url <url> returned status code 4:\nstdout: \nstderr: error: failed to write new configuration file .git/config.lock\n\nI am not able to figure out the root cause. \nI have checked the permission and ownership for jenkins home folder which is /var/lib/jenkins:-\ndrwxrwxrwx 17 jenkins jenkins 4096 Jun 25 04:30 jenkins\nPermission and ownership of .git folder inside workspace folder of jenkins is:-\ndrwxrwxrwx 8 jenkins jenkins 4096 Jun 30 21:51 .git\nPlease guide me fix the problem." }, { "role": "assistant", "content": "I was seeing the same issue, but disk space and VM memory were not the problem. What fixed it for me was making the job re-clone on build: \n\nGo to the job's \"Configure\" page \nUnder Source Code Management → Git → Additional Behaviors, add a behavior \"Wipe out repository & force clone\" \nSave \nBuild" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Changing .gitconfig location on Windows\nBy default on Windows Git places global .gitconfig in c:\\documents and settings\\user\\\nHow can I change that position so .gitconfig is stored in c:\\my_configuration_files\\?\nCan it be done at all?" }, { "role": "assistant", "content": "If you set HOME to c:\\my_configuration_files\\, then git will locate .gitconfig there. Editing environment variables is described here. You need to set the HOME variable, then re-open any cmd.exe window. Use the \"set\" command to verify that HOME indeed points to the right value.\nChanging HOME will, of course, also affect other applications. However, from reading git's source code, that appears to be the only way to change the location of these files without the need to adjust the command line. You should also consider Stefan's response: you can set the GIT_CONFIG variable. However, to give it the effect you desire, you need to pass the --global flag to all git invocations (plus any local .git/config files are ignored)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-for-each-ref - Output information on each ref contents:lines=N" }, { "role": "assistant", "content": "The first N lines of the message." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database missingEmail" }, { "role": "assistant", "content": "(ERROR) Email is missing in an author/committer line." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to copy commits from one Git repo to another?\n\nLast week I created a Github repo and forgot to select a license for the repo. Now there are already 3 large commits.\nI have asked the 3 contributors if it is ok if I delete the repo and then create it again with the same name and this time selecting the license when creating the repo, and they were fine with that.\nQuestion\nIs there a way I can get the commits into the new repo (this time the first commit is the LICENSE file) and still keep the commit meta info?" }, { "role": "assistant", "content": "Is there a way I have get the commits into new repo (this time the first commit is the LICENSE file) and still keep the commit meta info?\n\nYes, by adding a remote and cherry-picking the commits on top of your first commit.\n# add the old repo as a remote repository \ngit remote add oldrepo https://github.com/path/to/oldrepo\n\n# get the old repo commits\ngit remote update\n\n# examine the whole tree\ngit log --all --oneline --graph --decorate\n\n# copy (cherry-pick) the commits from the old repo into your new local one\ngit cherry-pick sha-of-commit-one\ngit cherry-pick sha-of-commit-two\ngit cherry-pick sha-of-commit-three\n\n# check your local repo is correct\ngit log\n\n# send your new tree (repo state) to github\ngit push origin master\n\n# remove the now-unneeded reference to oldrepo\ngit remote remove oldrepo\n\n\nThe rest of this answer is if you still want to add the LICENSE to your previous repo.\nYes. You can place your LICENSE commit as the first commit by rebasing.\nRebasing is gits way of rearranging commit order while keeping all the commit authors and commit dates intact.\nWhen working on a shared repo, it's generally discouraged unless your entire team is git-fluent. For those that aren't, they can just clone a fresh copy of the repository.\nHere's how you get your LICENSE commit as the first commit.\n1. Update and rebase your local copy\nCheck out your project and place the LICENSE file in a commit ON TOP of your current 3 commit stack.\n#create LICENSE file, edit, add content, save\ngit add LICENSE\ngit commit -m 'Initial commit'\n\nThen do an interactive rebase on the master branch to REARRANGE the commits.\ngit rebase -i --root\n\nIt will open an editor. Move the bottom line (your \"Initial commit\" commit, the most recent commit) to the top of the file. Then save and quit the editor.\nAs soon as you exit the editor, git will write the commits in the order you just specified.\nYou now have your local copy of the repository updated. do:\ngit log\n\nto verify.\n2. Force push your new repo state to github\nNow that your copy is updated, you have to force push it to github.\ngit push -f origin master\n\nThis will tell github to move the master branch to its new location.\nYou should only force push in rare occasions like this where everybody working with it is aware of the pending change, else it will confuse your collaborators.\n3. Synchronize collaborators to github\nLastly, all the collaborators will have to synchronize to this repository.\nFirst they must have clean repositories as the following command can be destructive if there are unsaved changes.\n# make sure there are no unsaved changes\ngit status \n\n# pull the latest version from github\ngit fetch \n\n# move their master branch pointer to the one you published to github.\ngit reset --hard origin/master\n\nThat's it. Everybody should be in sync now." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove a branch locally?\n\nI have a master and a dev branch in my repository. I want to remove the master branch from my computer so that I don't accidentally commit to it (it's happened..). \nThere are questions on here about how to delete branches locally and remotely, but I haven't been able to find out how to only delete a branch locally.\nOne answer said to use this:\ngit branch -d local_branch_name\n\nBut I tried that and the branch still shows up in the GitHub application." }, { "role": "assistant", "content": "To Force Delete a Local Branch:\n$ git branch -D <branch-name>\n\n\n[NOTE]:\n-D is a shortcut for --delete --force." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to do a pull request in GitHub with only the latest commit in the master branch of my forked repository\n\nI forked a repository on github. I made some changes and did a pull request.\nNow I made some other changes and want to do a new pull request, but on the preview screen before doing the pull request it shows the old commits too (the ones that were already accepted).\nHow do I select only the latest commit in the master branch of my forked repository so that I can do a pull request with only that commit?" }, { "role": "assistant", "content": "This answer from a coworker fixed my problem:\ngit checkout -b NEW_BRANCH_NAME LAST_COMMIT_NAME_BEFORE_THE_ONE_WANTED\ngit cherry-pick COMMIT_NAME_WANTED\ngit push origin NEW_BRANCH_NAME\n\nThen on GitHub you can do a pull request for the new branch you created.\nUPDATE\nI asked and answered this question when I first started working with git. Now that I know more about it, I'd like to expand this answer.\nWhen working with a fork you probably want to keep it updated with respect to the original repo. So these would be the steps I would follow today:\ngit remote add upstream GIT_URL_OF_THE_ORIGINAL_REPO\n\nNow you have a reference called upstream which points to that repo. By default you should also have another one called origin which would point to your fork in this case. upstream and origin is just how people usually name these references, but you can use whatever name you want.\nNow you need to get the latest changes:\ngit fetch upstream\n\nThen if you want to update your fork with changes from upstream you'd do this:\ngit checkout master //checkout your master branch\ngit merge upstream/master //merge changes from the master branch in upstream into the branch you checked out (master)\ngit push origin master //if you want to push your updated master to your remote fork\n\nNow, to answer the original question, what I would do today if I wanted to submit a new PR, would be:\ngit fetch upstream //get the latest changes from the original repo\ngit checkout -b my_new_feature upstream/master //create a new branch, starting from the master in the original repo\ngit cherry-pick WHATEVER_COMMIT_I_WANT //select the commit I want and add it to this new branch\ngit push origin my_new_feature //push a new branch to my fork\n\nThen I would request a new PR for the my_new_feature branch.\nYou can replace git cherry-pick WHATEVER_COMMIT_I_WANT with just modifying/adding a file and then doing git add FILENAME, git commit -m \"Fixing some stuff\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Combining Multiple Commits Into One Prior To Push\nThis question pertains not only to how to accomplish this task, but to whether doing so is good or bad practice with Git.\nConsider that locally I do most work on the main branch, but I have created a topical branch I will call feature_branch. In the process of working on feature_branch and switching back and forth to do other work on the main branch, it turns out that I have made more than one commit on feature_branch, but between each commit, I have done no push. My questions are:\n\nWould you consider this bad practice? Would it not be wiser to stick with one commit per branch per push? In what cases would it be good to have multiple commits on a branch before a push is made?\n\nHow should I best accomplish bringing the multiple commits on feature_branch into the main branch for a push? Is it a nuisance to not worry about it and just do the push where multiple commits get pushed, or is it less annoying to somehow merge the commits into one and then push? Again, how to do this?" }, { "role": "assistant", "content": "For your first question, no, there's nothing wrong with pushing multiple commits at once. Many times, you may want to break your work down into a few small, logical commits, but only push them up once you feel like the whole series is ready. Or you might be making several commits locally while disconnected, and you push them all once you're connected again. There's no reason to limit yourself to one commit per push.\nI generally find that it's a good idea to keep each commit a single, logical, coherent change, that includes everything it needs to work (so, it does not leave your code in a broken state). If you have a two commits, but they would cause the code to be broken if you only applied the first one, it might be a good idea to squash the second commit into the first. But if you have two commits where each one makes a reasonable change, pushing them as separate commits is fine.\nIf you do want to squash several commits together, you can use git rebase -i. If you're on feature_branch, you would run git rebase -i main. This will open an editor window, with a bunch of commits listed prefixed by pick. You can change all but the first to squash, which will tell Git to keep all of those changes, but squash them into the first commit. After you've done that, check out main and merge in feature_branch:\ngit checkout feature_branch\ngit rebase -i main\ngit checkout main\ngit merge feature_branch\n\nAlternatively, if you just want to squash everything in feature_branch into main, you could just do the following:\ngit checkout main\ngit merge --squash feature_branch\ngit commit\n\nWhich one you choose is up to you. Generally, I wouldn't worry about having multiple smaller commits, but sometimes you don't want to bother with extra minor commits, so you just squash them into one." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout - Switch branches or restore working tree files --pathspec-file-nul" }, { "role": "assistant", "content": "Only meaningful with --pathspec-from-file . Pathspec elements are\nseparated with NUL character and all other characters are taken\nliterally (including newlines and quotes)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Differences between git submodule and subtree\nWhat are the conceptual differences between using git submodule and subtree?\nWhat are the typical scenarios for each?" }, { "role": "assistant", "content": "submodule is link;\nsubtree is copy" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Error with renamed repo in GitHub: \"remote: This repository moved. Please use the new location\"\nI am receiving this notice when I push updates from my local instance to remote master on GitHub:\n\nremote: This repository moved. Please use the new location [new location]\n\nIs there a way to fix this?" }, { "role": "assistant", "content": "The simple way is:\ngit remote set-url origin [updated link url https://........git]\n\nAlternatively, if you like the long way it is:\ngit remote rm origin\ngit remote add origin [updated link]\n\nChanging a remote's URL GitHub documentation goes into further detail." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to connect local folder to Git repository and start making changes on branches?\nI'm new to source control; in the past, I've manually backed up copies of files and made changes on clones then transferred changes manually to master files once debugged. I realize this is similar to how branches work with Git repositories, however I've never used one.\nI downloaded Git and made an account on GitLab, and started a new project. My site is hosted on a local server and my files are saved locally. How do I connect these files to a Git repository and continue developing with branches?" }, { "role": "assistant", "content": "To register a project as a local Git repository the first thing you need to do is perform the following command at your project root:\ngit init\n\nThis will create a .git folder at your project root and will allow you to start using Git in that repository.\n\nIf you want to \"push\" your local Git repository to a remote Git server (in your case, to GitLab), you'll need to perform the following command first:\ngit remote add origin <Repository_Location>\n\nYou can call origin whatever you like, really, but origin is the standard name for Git remote repositories. <Repository_Location> is the URL to your remote repository. For example, if I had a new project called MyNewProject that I wanted to push to GitLab, I'd perform:\ngit remote add origin https://gitlab.com/Harmelodic/MyNewProject.git\n\nYou can then \"push\" your changes from your local machine to your remote repo using the following command:\ngit push origin <branch_name>\n\nwhere branch name is the name of the branch you want to push, e.g. master.\n\nYou can find a good beginners guide to Git here." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_INDEX_VERSION" }, { "role": "assistant", "content": "This environment variable specifies what index version is used\nwhen writing the index file out. It won’t affect existing index\nfiles. By default index file version 2 or 3 is used. See git-update-index for more information." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Automatically Deploy From GitHub To Server On Push\n\nWe have a VPS on Linode, and code hosted on GitHub. How do we setup so when we push to GitHub, it also pushes automatically to our Linode server. We are using PHP on the Linode server." }, { "role": "assistant", "content": "You probably want to use GitHub's post-receive hooks.\nIn summary, GitHub will POST to a supplied URL when someone pushes to the repo. Just write a short PHP script to run on your linode VPS and pull from GitHub when it receives said POST." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git diff on date?\nI'm accustomed to running a git comparison that will allow comparison with local git revs like:\ngit diff HEAD HEAD~110 -- some/file/path/file.ext\n\nIs it possible to use the date instead? And if so, how? I would like to be able insert in place of the \"110\" in the above example, a date such as \"4 Dec 2012\"." }, { "role": "assistant", "content": "git diff HEAD 'HEAD@{3 weeks ago}' -- some/file/path/file.ext\n\nThis is not, strictly speaking, the revision made three weeks ago. Instead, it's the position HEAD was at three weeks prior to the present. But it's probably close enough for your purposes - it will be very accurate if the current branch's HEAD moved forward steadily, as most tend to do. You can improve the accuracy by using a branch name instead of HEAD.\nInstead of an offset-from-the-present, you can also use a date/time, like HEAD@{1979-02-26 18:30:00}. See git help rev-parse." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there any way to make markdown tables sortable?\n\nI'd like to write my table in markdown text, but allow it to be sortable on github after its been rendered(simple asc/desc sorting by clicking on the column header.\nAny way to do this?" }, { "role": "assistant", "content": "Table sort is not supported in Github flavored markdown but one alternative is to use user script such as Github Sort Content\nIt's very easy to install, for instance from Chrome : \n\ninstall Tampermonkey\ninstall Github Sort Content from Greasyfork\n\nThen tables from github.com markdown pages can be sorted like :" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_COMMITTER_NAME" }, { "role": "assistant", "content": "The human-readable name used in the committer identity when creating commit or\ntag objects, or when writing reflogs. Overrides the user.name and committer.name configuration settings." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --anchored=<text>" }, { "role": "assistant", "content": "Generate a diff using the \"anchored diff\" algorithm. This option may be specified more than once. If a line exists in both the source and destination, exists only once,\nand starts with this text, this algorithm attempts to prevent it from\nappearing as a deletion or addition in the output. It uses the \"patience\ndiff\" algorithm internally." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --exit-code" }, { "role": "assistant", "content": "Make the program exit with codes similar to diff(1).\nThat is, it exits with 1 if there were differences and\n0 means no differences." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options gc.autoPackLimit" }, { "role": "assistant", "content": "When there are more than this many packs that are not\nmarked with *.keep file in the repository, git gc\n--auto consolidates them into one larger pack. The\ndefault value is 50. Setting this to 0 disables it.\nSetting gc.auto to 0 will also disable this. See the gc.bigPackThreshold configuration variable below. When in\nuse, it’ll affect how the auto pack limit works." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the difference between 'git pull' and 'git fetch'?\nWant to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.\n \n \n\n\n\n\n\n\nWhat are the differences between git pull and git fetch?" }, { "role": "assistant", "content": "In the simplest terms, git pull does a git fetch followed by a git merge.\n\ngit fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.\ngit pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.\nFrom the Git documentation for git pull:\n\ngit pull runs git fetch with the given parameters and then depending on configuration options or command line flags, will call either git rebase or git merge to reconcile diverging branches." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern" }, { "role": "assistant", "content": "NOTES ON THREADS The --threads option (and the grep.threads configuration) will be ignored when --open-files-in-pager is used, forcing a single-threaded execution. When grepping the object store (with --cached or giving tree objects), running\nwith multiple threads might perform slower than single-threaded if --textconv is given and there are too many text conversions. Thus, if low performance is\nexperienced in this case, it might be desirable to use --threads=1 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Not able to checkout branch even after removing worktree and running worktree prune\n\nI create a worktree for branch using the following command:\nGit add worktree <path> <branch-name>\n\nThis created a new worktree for me and checked out the branch at the path \nNow I thought of deleting/removing the worktree. Ran following commands:\nrm -rf <path>\ngit worktree prune\n\nThis should ideally remove the worktree and remove the reference for that path too. So now I should be able to checkout the branch. But when I run following command to checkout to that branch:\ngit checkout <branch-name>\n\nI get this error:\nfatal: '<branch-name>' is already checked out at ''\n\nCould someone help me with what is going on." }, { "role": "assistant", "content": "I worked around this by erasing .git/worktrees/<branch-name> from the repository directory." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Stash just a single file\nI'd like to be able to stash just the changes from a single file:\ngit stash save -- just_my_file.txt\n\nThe above doesn't work though. Any alternatives?" }, { "role": "assistant", "content": "If you do not want to specify a message with your stashed changes, pass the filename after a double-dash.\n$ git stash -- filename.ext\n\nIf it's an untracked/new file, you will have to stage it first.\nHowever, if you do want to specify a message, use push.\ngit stash push -m \"describe changes to filename.ext\" filename.ext\n\nBoth methods work in git versions 2.13+" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary submodule" }, { "role": "assistant", "content": "A repository that holds the history of a\nseparate project inside another repository (the latter of\nwhich is called superproject )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options branch.<name>.merge" }, { "role": "assistant", "content": "Defines, together with branch.<name>.remote, the upstream branch\nfor the given branch. It tells git fetch / git pull / git rebase which\nbranch to merge and can also affect git push (see push.default).\nWhen in branch <name>, it tells git fetch the default\nrefspec to be marked for merging in FETCH_HEAD. The value is\nhandled like the remote part of a refspec, and must match a\nref which is fetched from the remote given by\n\"branch.<name>.remote\".\nThe merge information is used by git pull (which first calls git fetch ) to lookup the default branch for merging. Without\nthis option, git pull defaults to merge the first refspec fetched.\nSpecify multiple values to get an octopus merge.\nIf you wish to setup git pull so that it merges into <name> from\nanother branch in the local repository, you can point\nbranch.<name>.merge to the desired branch, and use the relative path\nsetting . (a period) for branch.<name>.remote." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitmodules - Defining submodule properties submodule.<name>.ignore" }, { "role": "assistant", "content": "Defines under what circumstances git status and the diff family show\na submodule as modified. The following values are supported: all The submodule will never be considered modified (but will\nnonetheless show up in the output of status and commit when it has\nbeen staged). dirty All changes to the submodule’s work tree will be ignored, only\ncommitted differences between the HEAD of the submodule and its\nrecorded state in the superproject are taken into account. untracked Only untracked files in submodules will be ignored.\nCommitted differences and modifications to tracked files will show\nup. none No modifications to submodules are ignored, all of committed\ndifferences, and modifications to tracked and untracked files are\nshown. This is the default option. If this option is also present in the submodule’s entry in .git/config of the superproject, the setting there will override the one found in .gitmodules . Both settings can be overridden on the command line by using the --ignore-submodules option. The git submodule commands are not\naffected by this setting." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can I do a wildcard (*) search on github.com?\n\nI want to search a repository for any files that end in *Test.java* but if I search for *Test.java* I just get files that contain that exact string.\nI can't find any information anywhere that suggests this is possible. Is this just due to limitations of indexing such an enormous amount of data?\nI'd like to find a way to search a repo for all classes ending in Test." }, { "role": "assistant", "content": "The easiest way to find a file in a repository is to use the file finder. You can activate it at any time when you are in repository view by pressing t. See this screenshot from the official annoucement:\n\nThe file finder will perform some fuzzy matching using the characters you input into the \"search box\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_NO_LAZY_FETCH" }, { "role": "assistant", "content": "Setting this Boolean environment variable to true tells Git\nnot to lazily fetch missing objects from the promisor remote\non demand." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --dense" }, { "role": "assistant", "content": "Commits that are walked are included if they are not TREESAME\nto any parent." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-clone - Clone a repository into a new directory -j <n> --jobs <n>" }, { "role": "assistant", "content": "The number of submodules fetched at the same time.\nDefaults to the submodule.fetchJobs option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Build error while transitioning between branches: Your project is not referencing the \".NETFramework,Version=v4.7.2\" framework\nWe're using Git and we have a solution which is targeting the full net framework. A couple of days ago, I've started migrating the solution to .net core. Unfortunately, something comes up which made me go back to the master branch (which has the code for the full .NET framework). Whenever I try to build the app, I get the following error:\n\n1>D:\\Program Files (x86)\\Microsoft Visual\n Studio\\2017\\Community\\MSBuild\\Microsoft\\NuGet\\15.0\\Microsoft.NuGet.targets(186,5):\n error : Your project is not referencing the\n \".NETFramework,Version=v4.7.2\" framework. Add a reference to\n \".NETFramework,Version=v4.7.2\" in the \"frameworks\" section of your\n project.json, and then re-run NuGet restore.\n\nI've tried cleaning up the nuget packages, running a git reset, but nothing seems to help. Any idea on what's going on?" }, { "role": "assistant", "content": "I had a similiar issue when upgrading some projects from 4.6.2 to 4.7.2 - this happened for both our ASP.Net Core solution targetting full framework, and our WPF solution. \nInitially it seemed to be random projects that had this error, other projects with near exact same csproj were building fine and others were failing. The 're-run NuGet restore' in the message sent me down the wrong path aswell (some of these projects didn't even have NuGet references...)\nThe issue appears to stem from the projects obj folder containing a project.assets.json file, I'm not sure when this was generated - likely relics from the past, and cleaning the project does not remove this. The file points to the previous framework, in my case 4.6.2 - Manually deleting the bin/obj folders for each project that wouldn't build & then rebuilding resolved this error for me. This would also explain why when I cloned the repo for my sanity, it also built fine." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "whats the lifetime of Github OAuth API access token\n\nwhat is the expiry time of github oauth access token. And also how do I renew it. I don't see any refresh token in their documentation. Please guide me. Thanks in advance." }, { "role": "assistant", "content": "2014: As commented in this \"GitHub OAuth Busy Developer's Guide\"\n\nTokens don't have to expire.\nThey only send back the access token and an expiration (field \"expires_in\", seen as far back as 2013) if the offline_access scope is not requested (as it is the case for a refresh token).\nRight now, GitHub just assumes all apps want offline access.\n\nYou can check an OAuth application authorization, delete it or revoke it.\nBut the token itself doesn't seem to be bound to an expiry date unless they are not use for one year.\nbadsyntax adds in the comments:\n\nI also found this useful:\n\"An OAuth token does not expire until the person who authorized the OAuth App revokes the token.\"\nFrom \"Migrating OAuth Apps to GitHub Apps\".\n\nStokito points out in the comments to rfc6749 / 4.2.2 Access Token Response:\n\nexpires_in\nRECOMMENDED.\nThe lifetime in seconds of the access token.\nFor example, the value \"3600\" denotes that the access token will expire in one hour from the time the response was generated.\nIf omitted, the authorization server SHOULD provide the expiration time via other means or document the default value." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "\"Failed to connect to repository\" Error while setting up Github Jenkins Plugin\n\nI am getting an error when inputting my repo location into the \"Source Code Management > Git > Repository URL\" section of a new Job. I have searched all around and tried many different URLs with no success.\nError:\nFailed to connect to repository : Error performing command: git ls-remote -h https://github.com/micdoodle8/Crossbow_Mod_2.git HEAD\n\nAny ideas? Thanks." }, { "role": "assistant", "content": "You might need to set the path to your git executable in Manage Jenkins -> Configure System -> Git -> Git Installations -> Path to Git executable.\nFor example, I was getting the same error in Windows. I had installed git with chocolatey, and got the location via Powershell:\nGet-Command git.exe | Select Definition\n\nIn Unix, you should be able to do:\nwhich git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-switch - Switch branches <new-branch>" }, { "role": "assistant", "content": "Name for the new branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can't clone a github repo on Linux via HTTPS\nI'm trying to do a simple git clone https://github.com/org/project.git on a CentOS box but get:\n\nerror: The requested URL returned error: 401 while accessing\n https://github.com/org/project.git/info/refs\nfatal: HTTP request failed\n\nIt never prompts me for my username/password, just fails.\nI can make the exact same call on my Mac no problem- what am I missing?" }, { "role": "assistant", "content": "The answer was simple but not obvious:\nInstead of:\ngit clone https://github.com/org/project.git\n\ndo:\ngit clone https://[email protected]/org/project.git\n\nor (insecure)\ngit clone https://username:[email protected]/org/project.git\n\n(Note that in the later case, your password will may be visible by other users on your machine by running ps u -u $you and will appear cleartext in your shell's history by default)\nAll 3 ways work on my Mac, but only the last 2 worked on the remote Linux box. (Thinking back on this, it's probably because I had a global git username set up on my Mac, whereas on the remote box I did not? That might have been the case, but the lack of prompt for a username tripped me up... ) \nHaven't seen this documented anywhere, so here it is." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using git diff, how can I get added and modified lines numbers?\nAssuming I have a text file\nalex\nbob\nmatrix\nwill be removed\ngit repo\n\nand I have updated it to be\nalex\nnew line here\nanother new line\nbob\nmatrix\ngit\n\nHere, I have added lines number (2,3) and updated line number (6)\nHow can I get these line numbers info using git diff or any other git command?" }, { "role": "assistant", "content": "git diff --stat will show you the output you get when committing stuff which is the one you are referring to I guess.\ngit diff --stat\n\nFor showing exactly the line numbers that has been changed you can use\ngit blame -p <file> | grep \"Not Committed Yet\"\n\nAnd the line changed will be the last number before the ending parenthesis in the result. Not a clean solution though :(" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --intent-to-add" }, { "role": "assistant", "content": "When applying the patch only to the working tree, mark new\nfiles to be added to the index later (see --intent-to-add option in git-add ). This option is ignored unless\nrunning in a Git repository and --index is not specified.\nNote that --index could be implied by other options such\nas --cached or --3way ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options format.filenameMaxLength" }, { "role": "assistant", "content": "The maximum length of the output filenames generated by the format-patch command; defaults to 64. Can be overridden\nby the --filename-max-length=<n> command line option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In Jenkins, how to checkout a project into a specific directory (using GIT)\nSorry for the 'svn' style - we are in a process of migration from SVN to GIT (including our CI Jenkins environment).\nWhat we need is to be able to make Jenkins to checkout (or should I say clone?) the GIT project (repository?) into a specific directory. We've tried some refspecs magic but it wasn't too obvious to understand and use successfully.\nFurthermore, if in the same Jenkins project we need to checkout several private GitHub repositories into several separate dirs under a project root, how can we do it please?\nWe have GitHub plugin installed. Hope we've phrased the things right." }, { "role": "assistant", "content": "In the new Jenkins 2.0 pipeline (previously named the Workflow Plugin), this is done differently for:\n\nThe main repository\nOther additional repositories\n\nHere I am specifically referring to the Multibranch Pipeline version 2.9.\nMain repository\nThis is the repository that contains your Jenkinsfile.\nIn the Configure screen for your pipeline project, enter your repository name, etc.\nDo not use Additional Behaviors > Check out to a sub-directory. This will put your Jenkinsfile in the sub-directory where Jenkins cannot find it.\nIn Jenkinsfile, check out the main repository in the subdirectory using dir():\ndir('subDir') {\n checkout scm\n}\n\nAdditional repositories\nIf you want to check out more repositories, use the Pipeline Syntax generator to automatically generate a Groovy code snippet.\nIn the Configure screen for your pipeline project:\n\nSelect Pipeline Syntax. In the Sample\nStep drop down menu, choose checkout: General SCM.\nSelect your SCM system, such as Git. Fill in the usual information\nabout your repository or depot.\nNote that in the Multibranch Pipeline, environment variable\nenv.BRANCH_NAME contains the branch name of the main repository.\nIn the Additional Behaviors drop down menu, select\nCheck out to a sub-directory\nClick Generate Groovy. Jenkins will display the Groovy code snippet\ncorresponding to the SCM checkout that you specified.\nCopy this code into your pipeline script or Jenkinsfile." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts -y --no-prompt" }, { "role": "assistant", "content": "Don’t prompt before each invocation of the merge resolution\nprogram.\nThis is the default if the merge resolution program is\nexplicitly specified with the --tool option or with the merge.tool configuration variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-cat-file - Provide contents or details of repository objects objecttype" }, { "role": "assistant", "content": "The type of the object (the same as cat-file -t reports)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to only update specific git submodules?\nSo, updating all my submodules is done by running\ngit submodule foreach 'git pull origin master'\n\nHow do I update a specific submodule, located in say bundle/syntastic, without updating any other submodules?" }, { "role": "assistant", "content": "I end up there by searching how to update specific submodule only, which means for me, updating a submodule to the ref pointed by its super-repo.\nWhich is not the question nor the answer but only the title.\nSo in a hope of helping some others like me the answer to the question title is : \ngit submodule update <specific path to submodule>\n\nwhich will put this submodule in the state of the ref commited in the super-repo." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database unreachable <type> <object>" }, { "role": "assistant", "content": "The <type> object <object>, isn’t actually referred to directly\nor indirectly in any of the trees or commits seen. This can\nmean that there’s another root node that you’re not specifying\nor that the tree is corrupt. If you haven’t missed a root node\nthen you might as well delete unreachable nodes since they\ncan’t be used." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %N" }, { "role": "assistant", "content": "commit notes" } ]