messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to perform a 'grep search' in all the branches of a Git project?\nIs it possible to run git grep inside all the branches of a Git control sourced project? Or is there another command to run?" }, { "role": "assistant", "content": "The question \"How to grep (search) committed code in the Git history?\" recommends:\n git grep <regexp> $(git rev-list --all)\n\nThat searches through all the commits, which should include all the branches.\nAnother form would be:\ngit rev-list --all | (\n while read revision; do\n git grep -F 'yourWord' $revision\n done\n)\n\nYou can find even more example in this article:\n\nI tried the above on one project large enough that git complained about the argument size, so if you run into this problem, do something like:\ngit rev-list --all | (while read rev; do git grep -e <regexp> $rev; done)\n\n\n(see an alternative in the last section of this answer, below)\nDon't forget those settings, if you want them:\n# Allow Extended Regular Expressions\ngit config --global grep.extendedRegexp true\n# Always Include Line Numbers\ngit config --global grep.lineNumber true\n\nThis alias can help too:\ngit config --global alias.g \"grep --break --heading --line-number\"\n\n\nUpdate August 2016: R.M. recommends in the comments\n\nI got a \"fatal: bad flag '->' used after filename\" when trying the git branch version. The error was associated with a HEAD aliasing notation.\nI solved it by adding a sed '/->/d' in the pipe, between the tr and the xargs commands.\ngit branch -a | tr -d \\* | sed '/->/d' | xargs git grep <regexp>\n\n\nThat is:\nalias grep_all=\"git branch -a | tr -d \\* | sed '/->/d' | xargs git grep\"\ngrep_all <regexp>\n\nThis is an improvement over the solution chernjie had suggested, since git rev-list --all is an overkill.\n\nA more refined command can be:\n# Don't use this, see above\ngit branch -a | tr -d \\* | xargs git grep <regexp>\n\nWhich will allow you to search only branches (including remote branches)\nYou can even create a bash/zsh alias for it:\n# Don't use this, see above \nalias grep_all=\"git branch -a | tr -d \\* | xargs git grep\"\ngrep_all <regexp>\n\n\n\nJan. 2024: Gabriel Staples adds in the comments:\n\nFor anyone who wants to search just the tip commits on every branch in the repo, rather than every commit in the repo, and if you'd like to do parallel processes to speed up the search, see my very extensive answer here:\nAll about searching (via grep or similar) in your git repositories.\nI build upon some of the content in this answer." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Find when a file was deleted in Git\nI have a Git repository with n commits.\nI have a file that I need, and that used to be in the repository, and that I suddenly look for and think \"Oh! Where'd that file go?\"\nIs there a (series of) Git command(s) that will tell me that \"file really_needed.txt was deleted at commit n-13\"?\nIn other words, without looking at every individual commit, and knowing that my Git repo has every change of every file, can I quickly find the last commit that HAS that file, so I can get it back?" }, { "role": "assistant", "content": "To show the commits that changed a file, even if the file was deleted, run this command:\ngit log --all -- [file path]\n\nIf you want to see only the last commit, which deleted the file, use -1 in addition to the command above:\ngit log --all -1 -- [file path]\n\nNOTE: git log --full-history -- [file path] does NOT work in git version 2.42.0)\nSee also my article: Which commit deleted a file." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Get git not to show untracked files\nWhen doing git commit, is there a way to not display the untracked files in my editor (defined in $EDITOR)? I know how to do so in the shell (git status -uno), but I'd like do it in editor as well.\nNote that I do not want to ignore these files forever; I just don't want to see them on certain occasions." }, { "role": "assistant", "content": "If you don't ever want to commit them to your repo, use a .gitignore file to ignore them. More details can be found on the gitignore man page. They won't show up as untracked files when entering your commit message in your $EDITOR.\nIf you simply don't want to see them when committing in any repo, set the Git config variable status.showUntrackedFiles to no, as noted here:\n$ git config --global status.showUntrackedFiles no\n\nFor applying this to a single repo, instead use:\n$ git config --local status.showUntrackedFiles no" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to run a github-actions step, even if the previous step fails, while still failing the job\n\nI'm trying to follow an example Github has for testing my build with github actions, and then compressing the test results and uploading them as an artifact.\nhttps://help.github.com/en/actions/automating-your-workflow-with-github-actions/persisting-workflow-data-using-artifacts#uploading-build-and-test-artifacts\nI'm having trouble with what to do when my tests fail though. This is my action. When my tests pass everything works great, my results are zipped an exported as an artifact, but if my tests fail, it stops the rest of the steps in the job, so my results never get published.\n\nI tried adding the continue-on-error: true https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error\nThis makes it continue after it fails and uploads my test results. but then the job is marked as passed, even though my test step failed. Is there some way to have it upload my artifact even if a step fails, while still marking the overall job as failed?\nname: CI\non:\n pull_request:\n branches:\n - master\n push:\n branches:\n - master\n\njobs:\n build-and-test:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v1 \n - name: Test App\n run: ./gradlew test\n\n - name: Archive Rest Results\n uses: actions/upload-artifact@v1\n with:\n name: test-results\n path: app/build/reports/tests" }, { "role": "assistant", "content": "You can add\nif: always()\n\nto your step to have it run even if a previous step fails\nhttps://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions\nso for a single step it would look like this:\nsteps:\n- name: Build App\n run: ./build.sh\n\n- name: Archive Test Results\n if: always()\n uses: actions/upload-artifact@v1\n with:\n name: test-results\n path: app/build\n\nOr you can add it to a job:\njobs:\n job1:\n job2:\n needs: job1\n job3:\n if: always()\n needs: [job1, job2]\n\n\nAdditionally, as pointed out below, putting always() will cause the function to run even if the build is canceled. If you don't want the function to run when you manually cancel a job, you can instead put:\nif: success() || failure()\n\nor\nif: '!cancelled()'\n\n(Quotes are needed so that !cancelled() is not interpreted as a YAML tag.)\nLikewise, if you want to run a function ONLY when something has failed, you can put:\nif: failure()\n\n\nAlso, as mentioned in the comments, if a status check function is not used in if, like\nif: true\n\nthe result will (perhaps confusingly) behave like\nif: success() && true\n\nThis is documented in Expressions - GitHub Docs:\n\nStatus check functions\nYou can use the following status check functions as expressions in if conditionals. A default status check of success() is applied unless you include one of these functions." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I merge multiple commits onto another branch as a single squashed commit?\nI have a remote Git server, here is the scenario which I want to perform:\n\nFor each bug/feature I create a different Git branch\nI keep on committing my code in that Git branch with un-official Git messages\nIn top repository we have to do one commit for one bug with official Git message\n\nSo how can I merge my branch to remote branch so that they get just one commit for all my check-ins (I even want to provide commit message for this)?" }, { "role": "assistant", "content": "Say your bug fix branch is called bugfix and you want to merge it into master:\ngit checkout master\ngit merge --squash bugfix\ngit commit\n\nThis will take all the commits from the bugfix branch, squash them into 1 commit, and merge it with your master branch.\n\nExplanation:\ngit checkout master\n\nSwitches to your master branch.\ngit merge --squash bugfix\n\nTakes all commits from the bugfix branch and groups it for a 1 commit with your current branch.\n(no merge commit appears; you could resolve conflicts manually before following commit)\ngit commit\n\nCreates a single commit from the merged changes.\nOmitting the -m parameter lets you modify a draft commit message containing every message from your squashed commits before finalizing your commit." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options add.interactive.useBuiltin" }, { "role": "assistant", "content": "Unused configuration variable. Used in Git versions v2.25.0 to\nv2.36.0 to enable the built-in version of git-add 's\ninteractive mode, which then became the default in Git\nversions v2.37.0 to v2.39.0." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitrevisions - Specifying revisions and ranges for Git BISECT_HEAD" }, { "role": "assistant", "content": "records the current commit to be tested when you run git bisect\n--no-checkout ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Which files should I tell my VCS to ignore when using Sphinx for documentation? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 6 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI want to start using Sphinx to document my project. I told Sphinx to use separate source and build directories during sphinx-quickstart. Now my directory layout is the following:\nMyProject/\n myproject/\n __init__.py\n mymodule.py\n docs/\n source/\n .static/\n .templates/\n conf.py\n index.rst\n build/\n Makefile\n\nWhich files should be excluded from a VCS repository for a Sphinx project (i.e., since I use Git, what should I add to my .gitignore file)? For example, should I ignore the docs/build/ directory so that changes in the HTML pages generated from Sphinx aren't tracked?" }, { "role": "assistant", "content": "If you take a look at the contents of Makefile you'll see something as follows:\nBUILDDIR = build\n\n...\n\nclean:\n -rm -rf $(BUILDDIR)/*\n\nThis means that make clean just removes the build directory so, with regard to version control, ignoring the contents of the build directory should be enough as you already suspected." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "`--name` option doesn't work with `git submodule add` command\nI want to add a git submodule with different name like:\ngit submodule add --name foo [email protected]:ironsand/cookbook-foo.git\n\nI wanted to create a git submodule directory named foo, but the repository are created with the name cookbook-foo.\nMost likely I'm doing something wrong, but I don't know what was wrong.\nHow can I change the name of git submodule directory?" }, { "role": "assistant", "content": "Don't conflate the path and the name of a submodule. You want to run\ngit submodule add [email protected]:ironsand/cookbook-foo.git foo/\n\ninstead. For more details, see the git-submodule man page; the relevant git-submodule syntax here is\ngit submodule [--name <name>] <repository> [<path>]\n\nwhere...\n\n<repository> is the URL of the new submodule's origin repository.\n<path>, if specified, determines the name of the subdirectory (of the superproject's root directory) to receive the clone of the repo living at <repository>; if left unspecified, <path> defaults to the name of that repo.\n<name> is the submodule's name, i.e. the name that appear in the corresponding submodule entry in the .gitmodules file; if left unspecified, <name> simply defaults to <path>.\n\nHere is a toy example to fix ideas:\n$ cd ~/Desktop\n$ mkdir test\n$ cd test\n$ git init\n$ git submodule add --name brutus https://github.com/bradfitz/gitbrute bradfitz_bruteforce\n$ ls -a\n. .git bradfitz_bruteforce\n.. .gitmodules\n$ cat .gitmodules\n[submodule \"brutus\"]\n path = bradfitz_bruteforce\n url = https://github.com/bradfitz/gitbrute" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Which language has the best Git API Bindings? [closed]\nAs it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.\n \n \n\n\n\nClosed 12 years ago.\n\n\n\nI am looking at building an application with heavy ties to git..\nAre there language bindings available and if so which are the most comprehensive?\nWould it mean going to Bare Metal C?\nOr does perl / python / php / C# have a set of full bindings?\nThanks\nDaniel" }, { "role": "assistant", "content": "There are three different approaches with respect to using Git from within some programming language:\n\nReimplementation of Git in different language. That is what the following projects do:\n\nJGit which is reimplementation of Git in Java (used among others by EGit, the Eclipse Git plugin, and Gerrit Code Review),\nGrit is Ruby library for extracting information from a git repository in an object oriented manner, which includes a partial native Ruby implementation. Used e.g. by GitHub.\nGitSharp which is remplemantation of Git in C# for .NET and Mono, and which is following JGit wrt. functionality, \nDulwich which is pure-Python read-write implementation of the Git file formats and protocols.\nGit::PurePerl is pure Perl interface to Git repositories (it was mostly based on Grit, initially).\nGlip is \"git library in PHP\" - pure PHP implementation. Used by its author for eWiki.\nNGit .NET port of JGit used by Monodevelop\n\nThe problem with reimplementations is that they do not always implement the full functionality, and sometimes implement it wrong. On the other hand they are native, implement good performance; they may be licensed differently than C (original) implementation of Git, which is GPLv2.\nWrappers which call Git commands and wrap result it in some kind, suitably for target language.\n\nThe Git.pm module distributed with git (and used by some of its commands), Git::Wrapper and Git::Repository wrap git commands for Perl.\nJavaGit is a Java API that provides access to git repositories via calling git commands.\nGitPython is a Python library used to interact with Git repositories, by calling the Git executables and parsing output.\nhs-libgit is Haskell wrapper for git.\n\nThe problem with wrappers is that they can be slow (they require forking a git process), and that they require git to be installed to work.\nNote also that git itself is highly scriptable (e.g. using shell scripts), thanks to the fact that beside higher level commands meant for end user (porcelain) it also provides low level commands meant for scripting (plumbing).\nFinally there are bindings to libgit2, which means to be re-entrant linkable library with a solid API (was Google Summer of Code 2010 project).\n\nlibgit2 itself is a portable, pure C implementation.\nRugged - Ruby bindings.\nphp-git - PHP bindings.\nluagit2 - Lua bindings.\nGitForDelphi - Delphi bindings.\nlibgit2sharp - .NET bindings.\npygit2 - Python bindings.\nGeef is a simple Erlang NIF that exposes some of the libgit2 library functions to Erlang.\nMonodevelop uses a .NET port for JGit \n\nLibgit2 is quite new project; it is work in progress, so not everything is implemented at the time of being. See libgit2 homepage for details.\n\nAll this information can be found at InterfacesFrontendsAndTools page on Git Wiki" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-fetch-pack" }, { "role": "assistant", "content": "Receive missing objects from another repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects --no-recurse-submodules --recurse-submodules=check|on-demand|only|no" }, { "role": "assistant", "content": "May be used to make sure all submodule commits used by the\nrevisions to be pushed are available on a remote-tracking branch.\nIf check is used Git will verify that all submodule commits that\nchanged in the revisions to be pushed are available on at least one\nremote of the submodule. If any commits are missing the push will\nbe aborted and exit with non-zero status. If on-demand is used\nall submodules that changed in the revisions to be pushed will be\npushed. If on-demand was not able to push all necessary revisions it will\nalso be aborted and exit with non-zero status. If only is used all\nsubmodules will be pushed while the superproject is left\nunpushed. A value of no or using --no-recurse-submodules can be used\nto override the push.recurseSubmodules configuration variable when no\nsubmodule recursion is required. When using on-demand or only , if a submodule has a\n\"push.recurseSubmodules={on-demand,only}\" or \"submodule.recurse\" configuration,\nfurther recursion will occur. In this case, \"only\" is treated as \"on-demand\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git cannot lock ref 'HEAD': unable to resolve reference HEAD\nI'm trying to commit the changes to my repository but I receive the error below:\ngit -c diff.mnemonicprefix=false -c core.quotepath=false commit -q -F C:\\Users\\Contronym\\AppData\\Local\\Temp\\bkdweixb.mnu\nfatal: cannot lock ref 'HEAD': unable to resolve reference HEAD: Invalid argument\n\nCompleted with errors, see above.\n\nI'm using bitbucket and SourceTree.\nWhat's the reason for this commit failing? I was able to commit just fine the last 3 commits over the past week. Then, all of a sudden, I receive this error.\nEDIT\nI ran git gc and these are the results:\n$ git gc\nerror: bad ref for HEAD\nerror: bad ref for HEAD\nerror: inflate: data stream error (unknown compression method)\nfatal: loose object 53b65bd9b4fec7f6a7b0b3313c68199a18804327 (stored in .git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327) is corrupt\nerror: failed to run repack\n\nI checked the directory .git/objects/53/b65bd9b4fec7f6a7b0b3313c68199a18804327 but that doesn't exist. There's two other files there, but b65bd9b4fec7f6a7b0b3313c68199a18804327 doesn't exist." }, { "role": "assistant", "content": "I had the same problem and the only solution that I found was to navigate to the head like so:\n.git/refs/heads/branch_name \n\nAnd I deleted the head file. Then I went to the console and I used the command:\ngit reset\n\nThen all the files were unstaged so add them and commit them afterwards." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Monorepo Version Tags Conventions\nIs there a standard for using version tags in monorepos? Is something along the lines of 1.0.0-myapp1, and 2.1.0-myapp2 acceptable? Or is there another way to differentiate versions between applications?" }, { "role": "assistant", "content": "tags are organized in directories and files (all git references are, run tree .git/refs/tags to see that), so I would suggest naming the tags :\nmyapp1/1.0.0\nmyapp1/1.0.1\n ...\nmyapp2/2.1.0\nmyapp2/2.2.0\n ...\n\nThis will group versions for each app together, and some commands will treat the numbers \"naturally\" :\n# list tags, sorted by version number :\n$ git tag --list --sort=\"version:refname\"\nmyapp1/1.0.2\nmyapp1/1.0.10\nmyapp1/2.0.0\nmyapp1/10.0.0\nmyapp2/1.0.0\nmyapp2/2.0.0\nmyapp2/11.0.0\n\n\nIf you want to avoid the \"tags for myapp2\" showing up when you inspect the log for myapp1, you may use git log with the --decorate-refs=<pattern> option:\n# this will include tags starting with 'myapp1', and all branches :\n$ git log --oneline --graph --decorate-refs=refs/tags/myapp1 --decorate-refs=refs/heads\n\nIf you need this on a regular basis, you can add an alias for it :\n$ git config alias.logmyapp1 log --decorate-..." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Migrate project from RCS to git?\nI have a 20-year-old project that I would like to migrate from RCS to git, without losing the history. All web pages suggest that the One True Path is through CVS. But after an hour of Googling and trying different scripts, I have yet to find anything that successfully converts my RCS project tree to CVS. I'm hoping the good people at Stackoverflow will know what actually works, as opposed to what is claimed to work and doesn't.\n(I searched Stackoverflow using both the native SO search and a Google search, but if there's a helpful answer in the database, I missed it.)\nUPDATE: The rcs-fast-export tool at http://git.oblomov.eu/rcs-fast-export was repaired on 14 April 2009, and this version seems to work for me. This tool converts straight to git with no intermediate CVS. Thanks Giuseppe and Jakub!!!\n\nThings that did not work that I still remember:\n\nThe rcs-to-cvs script that ships in the contrib directory of the CVS sources\nThe rcs-fast-export tool at http://git.oblomov.eu/rcs-fast-export in versions before 13 April 2010\nThe rcs2cvs script found in a document called \"CVS-RCS- HOW-TO Document for Linux\"" }, { "role": "assistant", "content": "See Interfaces, frontends, and tools page on Git Wiki, in \"Tools\", \"Interaction with other Revision Control Systems\", \"Other\". There you would find a description and a link to rcs-fast-export (gitweb) Ruby script by Giuseppe \"Oblomov\" Bilotta.\n(Web search would find also Ohloh page and announcement for mentioned project)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission --no-renames" }, { "role": "assistant", "content": "Turn off rename detection, even when the configuration\nfile gives the default to do so." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitglossary - A Git Glossary Git archive" }, { "role": "assistant", "content": "Synonym for repository (for arch people)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Import existing source code to GitHub\nHow can I import source code from my computer to my GitHub account?" }, { "role": "assistant", "content": "If you've got local source code you want to add to a new remote new git repository without 'cloning' the remote first, do the following (I often do this - you create your remote empty repository in bitbucket/github, then push up your source)\n\nCreate the remote repository, and get the URL such as [email protected]:/youruser/somename.git or https://github.com/youruser/somename.git\nIf your local GIT repo is already set up, skips steps 2 and 3\n\nLocally, at the root directory of your source, git init\n2a. If you initialize the repo with a .gitignore and a README.md you should do a git pull {url from step 1} to ensure you don't commit files to source that you want to ignore ;)\nLocally, add and commit what you want in your initial repo (for everything, git add . then git commit -m 'initial commit comment')\n\nto attach your remote repo with the name 'origin' (like cloning would do)\ngit remote add origin [URL From Step 1]\nExecute git pull origin master to pull the remote branch so that they are in sync.\nto push up your master branch (change master to something else for a different branch):\ngit push origin master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Fork between GitHub and GitLab projects\n\nIs it possible to fork a GitHub project into a GitLab project and the other way around?" }, { "role": "assistant", "content": "When creating a new repository, you can choose to import another repository, and one of the options is to import it via its https://... url from another repository site, such as github. This starts a git clone --bare <url> to import the repository. In the GitLab documentation the process is described in detail. Whenever I tried that, the process kept refreshing to the same \"in progress\" state indefinetly. \n\nUpdate: This seems to work only for repositories you own. So to import a public repository, a workaround would be to fork it and import the fork.\n\nSo another way would be to clone the repository on the commandline before populating your new repository:\nWhen you create a new, empty repository at your gitlab site, you get a page full of suggestions how to proceed to populate this repository.\nSetting up a tracker for a github site is basically a variant of the \nExisting Git repository recipe with the minor difference of cloning the repository to track first, and instead of renaming the previous origin to old-origin as suggested in the recipe, you want to rename it to upstream instead to maintain conventions. So you'll end up with proceedings as outlined:\n\nClone the original repository you want to track:\n\ngit clone https://github.com/<author>/<repository.git> <repository>-tracker\n\nChange into the directory the repository was cloned into\n\ncd <repository>-tracker\n\nrename the source (origin) to something else (upstream), so you can still address it. \n\ngit remote rename origin upstream\n\ncreate your own repository located at your gitlab server, giving it a suitable name and description (don't miss to reference/link the original source there)\nadd the url of your own gitlab repository as origin. The exact line to use including the path to your own repository can be found in the Existing Git repository recipe you probably received as a result of the previous step.\n\ngit remote add origin git@<gitlab-server>/<path-to-your-repo>.git\n\npush the repository to your gitlab server:\n\ngit push -u origin --all\ngit push -u origin --tags\n\nafterwards:\n\ngit remote -v\norigin git@<gitlab-server>/<path-to-your-repo>.git (fetch)\norigin git@<gitlab-server>/<path-to-your-repo>.git (push)\nupstream https://github.com/<author>/<repository.git> (fetch)\nupstream https://github.com/<author>/<repository.git> (push)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to use git mergetool's filemerge\nThe documentation is here: http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html\nA handy guide is here: http://ryanflorence.com/git-for-beginners/\nHowever, neither of them explain how to use mergetool's filemerge.\nThe guide I read says \"I hit enter and FileMerge pops up and I deal with the conflicts:\" but it doesn't mention how to \"deal with the conflicts\".\nWhen I run:\ngit mergetool \n\n:and then hit return as prompted, and the filemerge window opens showing all the merge conflicts, it only responds to the commands cmd+D and cmd+shift+D (which allow cycling through the conflicts). However, there doesn't seem to be a mention of how to, for each conflict, choose left/right/neither. The combo-box dropdown does not seem to do anything.\nHave already looked at docs, guide, file system menu, and systematically pressed keys on the keyboard looking for a response =)" }, { "role": "assistant", "content": "I haven't found any official documentation for it, but here's the understanding I got from trial and error:\nThere's a split view with your two options on the left and right. You can't edit either of those. There's also a bottom view which you can edit. You might need to pull up on the little circle in the middle of the bottom of the screen to expand that section.\nFor each conflict, click on the area in middle of the left/right split view and choose from the drop down in the lower right either \"Choose Left\" if the left is what you want or \"Choose Right\" if that is what you want. If neither option is good, click \"Choose Neither\" and edit it in the bottom section.\nThere's an arrow in the middle column that will show whether you've chosen left or right by pointing at it. If you've chosen neither, the arrow will disappear. All three views scroll together using the scroll bar on the far right screen.\nWhen you're done, click File > Save Merge from the menubar." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "SSH key per project in Gitlab\n\ni have a problem that i don't know how to handle.\nI have 2 Repos in Gitlab , RepoA and RepoB. In my gitlab user i have 3 ssh keys, one from my laptop and 2 from the 2 VM (VMA and VMB) that work with the 2 repos. In this way i can pull and push easy from the VMs and from my laptop. \nOn RepoA i have a colaborator that also works. He has RepoA shared to his Gitlab account and he has access to VMA to push and pull code. He sould never have access to RepoB, so from here comes my problem. If he can guess the RepoB url , he can pull and see it on the VMA where he has access already just becouse Gitlab does not have a granular way o adding ssh keys per project. I probably am missing something very logical here but i just can't see what.\nHow can i give access to to my colaborator on VMA to only see RepoA.\nA hack-ish way of doing this is to generate a 3rd user in gitlab that handles just VMA an the ssh key from VMA will be introduced in this user account on Gitlab. But i bet there's got to be a better, cleaner way." }, { "role": "assistant", "content": "GitLab has the feature of project-specific SSH keys:\nThey are called Deploy keys. You can use them to provide read-only or read/write access for one or multiple repositories.\n\nUse deploy keys to access repositories that are hosted in GitLab.\nDeploy keys can’t be used for Git operations if external authorization is enabled." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-am - Apply a series of patches from a mailbox --show-current-patch[=(diff|raw)]" }, { "role": "assistant", "content": "Show the message at which git am has stopped due to\nconflicts. If raw is specified, show the raw contents of\nthe e-mail message; if diff , show the diff portion only.\nDefaults to raw ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does diff.mnemonicprefix do?\nI've noticed that SourceTree performs git commands with this configuration option:\ngit -c diff.mnemonicprefix=false \n\nThis is what the git docs say about this option:\n\ndiff.mnemonicprefix\n\nIf set, git diff uses a prefix pair that is different from the standard \"a/\" and \"b/\" depending on what is being compared. When this configuration is in effect, reverse diff output also swaps the order of the prefixes:\n\ngit diff compares the (i)ndex and the (w)ork tree;\ngit diff HEAD compares a (c)ommit and the (w)ork tree;\ngit diff --cached compares a (c)ommit and the (i)ndex;\ngit diff HEAD:file1 file2 compares an (o)bject and a (w)ork tree entity;\ngit diff --no-index a b compares two non-git things (1) and (2).\n\nI still don't understand what this means. Can someone explain?" }, { "role": "assistant", "content": "git diff shows some metadata about the files it is comparing. Ordinarily you might see something like this:\ndiff --git a/foo/bar.txt b/foo/bar.txt <--\nindex abcd123..1234abc 100644\n--- a/foo/bar.txt <--\n+++ b/foo/bar.txt <--\n\nNote how the files are differentiated using a/ and b/ on the three lines I have indicated with arrows. This is non-mnemonic; the characters a and b have no real significance.\nWith diff.mnemonicprefix enabled, these characters are chosen as described in the documentation you quoted. For example, if you have changes to your local copy and are comparing against the index (e.g. with git diff) you would see something like\ndiff --git i/foo/bar.txt w/foo/bar.txt\nindex abcd123..1234abc 100644\n--- i/foo/bar.txt\n+++ w/foo/bar.txt\n\ninstead. The characters i and w are used to indicate your index and working copy respectively.\nThe other cases listed in the documentation work similarly." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a way to customize the output of git blame?\ngit log has a nice --format option to specify how the output should be formatted.\nBut git blame doesn't seem to have an equivalent, although default output of blame is not quite human-friendly. I would like to see much less.\nFor example, instead of:\n5600cab7 js/sidebar/VehicleGrid.js (Rene Saarsoo 2009-10-08 18:55:24 +0000 127) if (x > y) {\nb5f1040c js/map/monitoring/VehicleGrid.js (Mihkel Muhkel 2010-05-31 07:20:13 +0000 128) return x;\n\nI would like to have:\n5600cab7 Rene Saarsoo (1 year ago) 127: if (x > y) {\nb5f1040c Mihkel Muhkel (5 months ago) 128: return x;\n\nI figure that I could write a script to parse the output of git blame --porcelain but given the horrendous default output of blame I feel that somebody out there must have already done something about it.\nAny ideas? Or any tips for implementing such a script?" }, { "role": "assistant", "content": "You can use alternate output format: git annotate or git blame -c.\nYou can change formatting of dates with --date=<format> option (or blame.date config variable), where <format> is one of relative, local, default, iso, rfc, short. See git-blame and git-log manpages for details." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "remote rejected master -> master (pre-receive hook declined)\nI'm working in rails 3.2 and I receive an error when I try to push to heroku:\n git push heroku master\nCounting objects: 496, done.\nDelta compression using up to 8 threads.\nCompressing objects: 100% (435/435), done.\nWriting objects: 100% (496/496), 5.17 MiB | 249 KiB/s, done.\nTotal 496 (delta 125), reused 216 (delta 8)\n\n-----> Heroku receiving push\n-----> Removing .DS_Store files\n ! Heroku push rejected, no Cedar-supported app detected\n\nTo [email protected]:lumeo.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:lumeo.git'\n\nI have tried the few methods recommended on this forum, including emptying and reinstalling the Gems and deleting and adding the remote, to no avail.\nany suggestions?" }, { "role": "assistant", "content": "Make sure that your Rails app is in the root of the repo, the Gemfile is present and properly named. It is basically not able to detect your code base as one of the supported project types and hence failing it. Also, even if you do have a proper project, make sure it is part of the repository and you have committed it fine (git status will help you here and a ls should help you verify the project structure)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-help - Display help information about Git" }, { "role": "assistant", "content": "SYNOPSIS git help [-a|--all] [--[no-]verbose] [--[no-]external-commands] [--[no-]aliases] git help [[-i|--info] [-m|--man] [-w|--web]] [<command>|<doc>] git help [-g|--guides] git help [-c|--config] git help [--user-interfaces] git help [--developer-interfaces]" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository -o <option> --server-option=<option>" }, { "role": "assistant", "content": "Transmit the given string to the server when communicating using\nprotocol version 2. The given string must not contain a NUL or LF\ncharacter. The server’s handling of server options, including\nunknown ones, is server-specific.\nWhen multiple --server-option=<option> are given, they are all\nsent to the other side in the order listed on the command line." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Bash (mintty) is extremely slow on Windows 10 OS\nI installed Git on my Windows 10 a couple of months ago. It worked well for some time. But now, it's running very slow.\nThe git status command takes 7 seconds to execute, and git stash takes many minutes for stashing (even if there is nothing to stash). Also, I would like to point out that git status prints the result instantaneously, but I can not enter a new command for a few seconds, as shown in the image below.\n\nI have tried solutions to similar problems like link1, link2, etc., but none of these have worked.\nP.S.: I use Windows Defender antivirus, and it is NOT making my Bash slow. Also, cmd takes more time to execute git commands while git bash takes longer to run any command.\n\nUpdate: I have switched to Ubuntu, and therefore, I don't use Windows presently. So, there is no way I can check if any of the solutions work for me. I have accepted the answer provided by @pschild since it has the most upvotes and seems to have worked for many people." }, { "role": "assistant", "content": "For me, the solution was to set the HOME variable to my user directory (per this answer) via the following steps:\n\nOpen Advanced System Settings (see instructions below)\nOpen Environment Variables\nUnder System Variables, click \"New...\"\nEnter \"HOME\" for the variable name and the path to your user\ndirectory for the value (for example \"C:\\Users\\jdoe\").\n\nPer @Alexandre Jobin's comment, Git Bash can be very slow if your HOME variable points to a shared network folder. See also the answers to this related question for more solutions.\nHow to Open Advanced System Settings\nOn Windows 7 through 10, Advanced System Settings are opened by the following steps:\n\nOpen the file explorer\nRight-click on \"Computer.\"\nOpen Advanced System Settings.\n\nOn Windows 11, the steps are slightly different:\n\nOpen the Start menu (either click the ⊞ button in the lower left corner or type the ⊞ Win key).\nType \"View Advanced System Settings\" in the Search box and hit ENTER." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git error: Encountered 7 file(s) that should have been pointers, but weren't\nHow to clean repo, if staged files marked as modified?\nAfter\ngit reset --hard\n\nI get\nEncountered 7 file(s) that should have been pointers, but weren't:\n\nRunning git clean -fdx (which deletes everything, including untracked directories and anything in .gitignore) doesn't help, either." }, { "role": "assistant", "content": "Like Travis Heeter mentioned in his answer, Try the following command sequence:\ngit lfs uninstall\ngit reset --hard\ngit lfs install\ngit lfs pull\n\nIn case if this is not working (because this was not working for me), the following hack may work:\ngit rm --cached -r .\ngit reset --hard\ngit rm .gitattributes\ngit reset .\ngit checkout .\n\nThis worked for me!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What's the best visual merge tool for Git? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 4 years ago.\n\n\nThe community reviewed whether to reopen this question 11 months ago and left it closed:\n\nNot suitable for this site We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.\n\n\n\n\n\n\n Improve this question\n \n\n\n\nWhat's the best tool for viewing and editing a merge in Git? I'd like to get a 3-way merge view, with \"mine\", \"theirs\" and \"ancestor\" in separate panels, and a fourth \"output\" panel.\nAlso, instructions for invoking said tool would be great. (I still haven't figure out how to start kdiff3 in such a way that it doesn't give me an error.)\nMy OS is Ubuntu." }, { "role": "assistant", "content": "Meld is a free, open-source, and cross-platform (UNIX/Linux, OSX, Windows) diff/merge tool.\nHere's how to install it on:\n\nUbuntu\nMac\nWindows: \"The recommended version of Meld for Windows is the most recent release, available as an MSI from https://meldmerge.org\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub Actions Invalid Workflow File Error\n\nI started using GitHub Actions and I was able to setup a CI pipeline for Elixir, the action builds and tests without any issues. I also wanted to deploy the application using the heroku actions so I went ahead and added the one that is available in GitHub but after doing that I'm getting the following error:\nInvalid Workflow File\nEvery step must define a uses or run key\nThis is how my workflow looked before adding the heroku action:\nname: Elixir CI\n\non: push\n\njobs:\n build:\n\n runs-on: ubuntu-latest\n\n container:\n image: elixir:1.9.1-slim\n\n steps:\n - uses: actions/checkout@v1\n - name: Install Dependencies\n run: |\n mix local.rebar --force\n mix local.hex --force\n mix deps.get\n\n test:\n\n runs-on: ubuntu-latest\n\n services:\n db:\n image: postgres:11\n ports: ['5432:5432']\n options: >-\n --health-cmd pg_isready\n --health-interval 10s\n --health-timeout 5s\n --health-retries 5\n\n steps:\n - uses: actions/[email protected]\n - uses: actions/[email protected]\n with:\n otp-version: 22.x\n elixir-version: 1.9.x\n - run: mix deps.get\n - run: mix test\n\n\nAnd this is how I added the heroku action\n deploy:\n\n runs-on: ubuntu-latest\n\n steps:\n - uses: actions/[email protected]\n - name: GitHub Action for Heroku \n - run: |\n heroku login\n\n env:\n CI: true\n\nHere is the error for more details." }, { "role": "assistant", "content": "You have too many - where you are defining the step. There should only be one - per step in the job.\nThe README for actions/heroku hasn't been updated yet to show an example for yaml workflows. There is an open pull request to update it though. The following is the example from that pull request which might help you.\non: push\nname: Deploy to Heroku\njobs:\n release:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@master\n - name: login\n uses: actions/heroku@master\n env:\n HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}\n with:\n args: container:login\n - name: push\n uses: actions/heroku@master\n env:\n HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}\n with:\n args: container:push -a calm-fortress-1234 web\n - name: release\n uses: actions/heroku@master\n env:\n HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}\n with:\n args: container:release -a calm-fortress-1234 web" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I undo a checkout in git?\nI just checked out an earlier commit from my local git repo. I haven't made any changes to it, I was just looking at it. Now I want to go back to my latest commit - how do I do that?\nThe exact command I used to check it out:\ngit checkout e5dff6b3c5d704f9b598de46551355d18235ac08\n\nNow when I type git log, at the top I see this checked out commit, but none of my later commits. Did I accidentally delete those?" }, { "role": "assistant", "content": "Try this first:\ngit checkout master\n\n(If you're on a different branch than master (or main), use the branch name there instead.)\nIf that doesn't work, try...\nFor a single file:\ngit checkout HEAD /path/to/file\n\nFor the entire repository working copy:\ngit reset --hard HEAD\n\nAnd if that doesn't work, then you can look in the reflog to find your old head SHA and reset to that:\ngit reflog\ngit reset --hard <sha from reflog>\n\nHEAD is a name that always points to the latest commit in your current branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "using gitignore to ignore (but not delete) files\nI have a tmp directory in my git repo I'd like to still exist, but be ignored. I added it to .gitignore, but git status still tells me about changes to files in that directory. I tried git rm -r --cached, but that removes it from the remote repo. How can I stop tracking changes to this directory, but still allow it to exist? I also need to do this for 1 file, but changes to that also show up in git status after .gitignoreing them. What should I do?" }, { "role": "assistant", "content": "Instead of .gitignore, you can update local git repository by running following command:\ngit update-index --assume-unchanged <file>\n\nIn this case a file is being tracked in the origin repo. You can modify it in your local repo and git will never mark it as changed. Read more at:\n\nhttp://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/ - was reported dead at some time (sorry, not mine)\nhttp://archive.robwilkerson.org/2010/03/02/git-tip-ignore-changes-to-tracked-files/ - another one covering the same topic" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --rewrite-root=<URL>" }, { "role": "assistant", "content": "Set the rewriteRoot option in the [svn-remote] config." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options --local" }, { "role": "assistant", "content": "For writing options: write to the repository .git/config file.\nThis is the default behavior. For reading options: read only from the repository .git/config rather than\nfrom all available files. See also FILES ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Prevent pushing to master on GitHub?\nGitHub allows you to configure your repository so that users can't force push to master, but is there a way to prevent pushing to master entirely? I'm hoping to make it so that the only way of adding to commits to master is through the GitHub pull request UI." }, { "role": "assistant", "content": "Since the original question / answer, Github has added a new option for this to the restricted branches UI which allows you to set this up.\n\nRequire pull request reviews before merging When enabled, all commits must be made to a non-protected branch and submitted via a\npull request with the required number of approving reviews and no\nchanges requested before it can be merged into a branch that matches\nthis rule.\n\nTo find it go to Settings > Branches > Branch Protection Rules\nand click 'Add Rule'.\n\nThen, enter the name of the branch you want to protect and click the checkbox to require pull request reviews before merging.\n\nBy default, this only stops people who are not moderators. There is also another checkbox later down for ensuring that even moderators cannot merge." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I find the gcloud Kubernetes api url for gitlab integration\n\nI'm using the hosted version of gitlab and gitlab-ci and following the kubernetes integration setup https://docs.gitlab.com/ce/user/project/integrations/kubernetes.html.\nI'm struggling to find what to enter as the Kubernetes API URL for my gcloud hosted kubernetes instance. I assume I'm missing something obvious :-(" }, { "role": "assistant", "content": "kubectl cluster-info\n\nor\ncat ~/.kube/config | grep server" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "upstream in git and use of -u flags in push\nwhat is use of -u flag while pushing commits to some git repo? I mean what is differnece between git push origin master and git push -u origin master ? Can anyone please describe its usage ?" }, { "role": "assistant", "content": "The git(1) manual page says:\n-u, --set-upstream\n\n\nFor every branch that is up to date or successfully pushed, add\n upstream (tracking) reference, used by argument-less git-pull(1)\n and other commands. For more information, see branch..merge\n in git-config(1).\n\nBasically, you use this flag when you want to set origin as the upstream remote for a branch. This is needed if you don't want to manually specify the remote every time you use git pull.\nSee Also\nhttp://git-scm.com/book/en/Git-Branching-Remote-Branches#Tracking-Branches" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What are git's merge strategies? [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 11 years ago.\n\n\n\n\nPossible Duplicate:\nWhen would you use the different git merge strategies? \n\nWhen git merges files I'm working on, I see:\nMerge made by the 'recursive' strategy\n\nWhat exactly is the recursive strategy? What other strategies are there (if any)? And what would be the benefit of using one over the other? Do different strategies have different performances? Or could two different strategies result in different merge results?" }, { "role": "assistant", "content": "From git help merge:\n The merge mechanism (git-merge and git-pull commands) allows the\n backend merge strategies to be chosen with -s option. Some strategies\n can also take their own options, which can be passed by giving\n -X<option> arguments to git-merge and/or git-pull.\n\n resolve\n This can only resolve two heads (i.e. the current branch and\n another branch you pulled from) using a 3-way merge algorithm. It\n tries to carefully detect criss-cross merge ambiguities and is\n considered generally safe and fast.\n\n recursive\n This can only resolve two heads using a 3-way merge algorithm. When\n there is more than one common ancestor that can be used for 3-way\n merge, it creates a merged tree of the common ancestors and uses\n that as the reference tree for the 3-way merge. This has been\n reported to result in fewer merge conflicts without causing\n mis-merges by tests done on actual merge commits taken from Linux\n 2.6 kernel development history. Additionally this can detect and\n handle merges involving renames. This is the default merge strategy\n when pulling or merging one branch.\n\n The recursive strategy can take the following options:\n\n ours\n This option forces conflicting hunks to be auto-resolved\n cleanly by favoring our version. Changes from the other tree\n that do not conflict with our side are reflected to the merge\n result.\n\n This should not be confused with the ours merge strategy, which\n does not even look at what the other tree contains at all. It\n discards everything the other tree did, declaring our history\n contains all that happened in it.\n\n theirs\n This is opposite of ours.\n\n subtree[=path]\n This option is a more advanced form of subtree strategy, where\n the strategy makes a guess on how two trees must be shifted to\n match with each other when merging. Instead, the specified path\n is prefixed (or stripped from the beginning) to make the shape\n of two trees to match.\n\n octopus\n This resolves cases with more than two heads, but refuses to do a\n complex merge that needs manual resolution. It is primarily meant\n to be used for bundling topic branch heads together. This is the\n default merge strategy when pulling or merging more than one\n branch.\n\n ours\n This resolves any number of heads, but the resulting tree of the\n merge is always that of the current branch head, effectively\n ignoring all changes from all other branches. It is meant to be\n used to supersede old development history of side branches. Note\n that this is different from the -Xours option to the recursive\n merge strategy.\n\n subtree\n This is a modified recursive strategy. When merging trees A and B,\n if B corresponds to a subtree of A, B is first adjusted to match\n the tree structure of A, instead of reading the trees at the same\n level. This adjustment is also done to the common ancestor tree." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Finding the date/time a file was first added to a Git repository\nIs there a simple Git command to determine the \"creation date\" of a file in a repository, i.e. the date it was first added?\nIt would be best if it can determine this even through file renames/moves. I'd like it to be a computer-readable one-line output; it may be that I haven't figured out the correct git log <fname> options to do this." }, { "role": "assistant", "content": "git log --follow --format=%ad --date default <FILE> | tail -1\nWith this command you can out all date about this file and extract the last\nThe option %ad shows the date in the format specified by the --date setting, one of relative, local, iso, iso-strict, rfc, short, raw, human, unix, format:<strftime-string>, default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "./deploy.sh not working on gitlab ci\n\nMy problem is the bash script I created got this error \"/bin/sh: eval: line 88: ./deploy.sh: not found\" on gitlab. Below is my sample script .gitlab-ci.yml.\nI suspect that gitlab ci is not supporting bash script.\nimage: docker:latest\n\nvariables:\n IMAGE_NAME: registry.gitlab.com/$PROJECT_OWNER/$PROJECT_NAME\n DOCKER_DRIVER: overlay\n\nservices:\n - docker:dind\n\nstages:\n - deploy\n\nbefore_script:\n - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com\n - docker pull $IMAGE_NAME:$CI_BUILD_REF_NAME || true\n\nproduction-deploy:\n stage: deploy\n only:\n - master@$PROJECT_OWNER/$PROJECT_NAME\n script:\n - echo \"$PRODUCTION_DOCKER_FILE\" > Dockerfile\n - docker build --cache-from $IMAGE_NAME:$CI_BUILD_REF_NAME -t $IMAGE_NAME:$CI_BUILD_REF_NAME .\n - docker push $IMAGE_NAME:$CI_BUILD_REF_NAME\n - echo \"$PEM_FILE\" > deploy.pem\n - echo \"$PRODUCTION_DEPLOY\" > deploy.sh\n - chmod 600 deploy.pem\n - chmod 700 deploy.sh\n - ./deploy.sh\n environment:\n name: production\n url: https://www.example.com\n\nAnd this also my deploy.sh.\n#!/bin/bash\n\nssh -o StrictHostKeyChecking=no -i deploy.pem ec2-user@targetIPAddress << 'ENDSSH'\n // command goes here\nENDSSH\n\nAll I want is to execute deploy.sh after docker push but unfortunately got this error about /bin/bash thingy.\nI really need your help guys. I will be thankful if you can solve my problem about gitlab ci bash script got error \"/bin/sh: eval: line 88: ./deploy.sh: not found\"." }, { "role": "assistant", "content": "This is probably related to the fact you are using Docker-in-Docker (docker:dind). Your deploy.sh is requesting /bin/bash as the script executor which is NOT present in that image.\nYou can test this locally on your computer with Docker:\ndocker run --rm -it docker:dind bash\n\nIt will report an error. So rewrite the first line of deploy.sh to \n#!/bin/sh\n\nAfter fixing that you will run into the problem that the previous answer is addressing: ssh is not installed either. You will need to fix that too!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --pretty[=<format>] --format=<format>" }, { "role": "assistant", "content": "Pretty-print the contents of the commit logs in a given format,\nwhere <format> can be one of oneline , short , medium , full , fuller , reference , email , raw , format:<string> and tformat:<string> . When <format> is none of the above,\nand has %placeholder in it, it acts as if --pretty=tformat:<format> were given. See the \"PRETTY FORMATS\" section for some additional details for each\nformat. When =<format> part is omitted, it defaults to medium . Note: you can specify the default pretty format in the repository\nconfiguration (see git-config )." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Reset/revert a whole branch to another branches state?\nI have a branch A and a branch B (and some other branches).\nLets say A's commit history looks like:\n\ncommit 5\ncommit 4\ncommit 3\n...\n\nAnd B's commit history:\n\nsome other commit\ncommit 4\nmerge of other stuff from branch C (into branch B)\ncommit 3\n...\n\nBasically what I want is to \"delete\" all changes made by the commits some other commit and merge of other stuff from branch C to branch B.\nI want the working tree of branch B to be exactly the same like branch A's working tree.\nHow do I achieve this?" }, { "role": "assistant", "content": "One way to achieve this is through git reset. While on branch B execute\ngit reset --hard A\n\nThereafter, branch B points to the head-commit of A. The --hard option resets the index and working tree so that all tracked files are reset to the version in branch A. The old HEAD commit-ID of A is stored in .git/ORIG_HEAD in order to allow undoing the change.\nAlternatively - while not on branch B - you can delete branch B and re-created it like this:\ngit branch -d B # delete branch B\ngit branch B A # re-create branch B and let it point to the commit of branch A\n\nOther than the first suggestion, this will leave the index and working tree untouched." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why does Git treat this text file as a binary file?\nI wonder why git tells me this?\n$ git diff MyFile.txt\ndiff --git a/MyFile.txt b/MyFile.txt\nindex d41a4f3..15dcfa2 100644\nBinary files a/MyFile.txt and b/MyFile.txt differ\n\nAren't they text files?\nI have checked the .gitattributes and it is empty. Why I am getting this message ?, I cannot get diffs as I use to anymore\nADDED :\nI've noticed there is an @ in the file permissions, what is this ?, Could this be the reason ?\n$ls -all\ndrwxr-xr-x 5 nacho4d staff 170 28 Jul 17:07 .\ndrwxr-xr-x 16 nacho4d staff 544 28 Jul 16:39 ..\n-rw-r--r--@ 1 nacho4d staff 6148 28 Jul 16:15 .DS_Store\n-rw-r--r--@ 1 nacho4d staff 746 28 Jul 17:07 MyFile.txt\n-rw-r--r-- 1 nacho4d staff 22538 5 Apr 16:18 OtherFile.txt" }, { "role": "assistant", "content": "It simply means that when git inspects the actual content of the file (it doesn't know that any given extension is not a binary file - you can use the attributes file if you want to tell it explicitly - see the man pages).\nHaving inspected the file's contents it has seen stuff that isn't in basic ascii characters. Being UTF16 I expect that it will have 'funny' characters so it thinks it's binary.\nThere are ways of telling git if you have internationalisation (i18n) or extended character formats for the file. I'm not sufficiently up on the exact method for setting that - you may need to RT[Full]M ;-) \nEdit: a quick search of SO found can-i-make-git-recognize-a-utf-16-file-as-text which should give you a few clues." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In Xcode 4 how do I add a remote GitHub repository to an existing local project?\nThe Git integration in Xcode 4 is very welcome however it seems to be a bit flaky when it comes to dealing with remote repositories.\nFor clarity I'm using OS X version 10.6.7 and Xcode 4.0.2 (4A2002a). \nIf I create a new Xcode 4 Project and accept the option to create a local Git repository, all is well. I can commit locally and that's great.\nWhen I want to push the new project to GitHub I want to add a remote repository and push my local changes up to GitHub. I can add a GitHub repository to Xcode 4 as a new Repository in the Organizer window but there's no method of setting it as a remote repository for my existing project. \nSo I switch to using git commands in Terminal.\ngit remote add origin https://<username>@github.com/<organization>/<repository>.git\n\nIf I then go back to Xcode 4 and try to use \n\nFile -> Source Control -> Push... \n\nthen the Choose the repository to which to push changes. dialog appears listing the origin remote repository. There's a yellow indicator saying that Authentication is required, which is fine as I've not been able to enter my credentials yet for HTTPS. \nHowever when I click 'Push' and it tries to push the changes it says \"The operation could not be performed because access to the repository 'origin' is denied.\"\nA dialog prompting me for my username and password then appears with my pre-filled out so it must be reading this correctly from the local repository's config.\nWhen I enter my password Xcode 4 then crashes with the following error\nASSERTION FAILURE in /SourceCache/IDEKit/IDEKit-303/Framework/Classes/SourceControl/IDESourceControlOperationInfo.m:59\nDetails: Message sent to invalidated object: <IDESourceControlPushOperationInfo, 0x200bd2a80>. Backtrace for invalidation:\n (null)\nObject: <IDESourceControlPushOperationInfo: 0x200bd2a80>\nMethod: -invalidate\nThread: <NSThread: 0x200020700>{name = (null), num = 1}\nHints: None\n\nIf I restart Xcode an origin repository has been added to the Repositories browser in Organizer and I can see the master branch on GitHub so I know the credentials are right without me changing anything.\nHas anyone found a reliable way of using Xcode 4 with GitHub starting with a local project first?\nIf I clone an existing GitHub repository with an Xcode project in it, open it with Xcode 4 then even though the first Push seems to fail, the 2nd push did then work. So maybe starting from absolute scratch with Xcode 4 creating the repository for me isn't the best pattern (until they improve the Git tooling in a later version of Xcode 4).\nEDIT WITH FURTHER DETAILS OF ONE WORKAROUND\nThis example only really applies to the first project you're adding to a GitHub repository. As such I think you're better off with the following steps, bearing in mind there still seem to be some Xcode 'gotchas' in this solution.\n\nList item\n'Connect to a repository' from Welcome to Xcode dialog.\nUse GitHub SSH URL for Location\nGive it a name (RepositoryName)and Clone to a directory\n1st attempt appears to fail even though contents are downloaded\nTry Again and it works.\nThere is now a new Repository defined in the Organizer window with its origin set to the GitHub remote SSH URL.\nCreate a New Project within the directory you just cloned into but DO NOT tick the 'Create local git repository for this project' option.\nDo initial commit to local Git repository.\nTry Source Control -> Push and Xcode 4 fails with 'The operation could not be performed because access to the repository RepositoryName was denied. Check username and password'\nTry Source Control -> Push and Xcode 4 pops up the remote Repository dialog again but this time has detected a remote Repository called origin. Next to it there's a yellow ball and 'Authentication required'.\nClicking 'Push' again caused the remote Push to work.\n\nOne thing I've spotted and not managed to work out yet is that the response messages back from GitHub with the checkin hash value and any messages seem to get reported in Xcode Log navigator as Push failures, even though the Push is successful as far as GitHub is concerned.\nAnyone else have a better solution?" }, { "role": "assistant", "content": "I think I found the Xcode way to push a existing project to GitHub or any other remote repository! \nPreconditions\n\nI assume that you have a project created by Xcode 4 with a local git repository.\nYou created an empty remote git repository (I call it RemoteRepository in in the following example)\n\nPush it to remote\n\nOpen the Organizer in Xcode an go to the Repositories tab\nAt first click on Remotes and then on \"Add Remote\" \n\nEnter a Remote Name and the Location of your remote repository and click on create \n\nThen select your project and open File -> Source Control -> Push ... \n\nSelect your remote repository and wait until it is connectable! Look for the Create in the brackets.\n\nNow your old project is published to GitHub\n\n\nI hope it will works for you also! In my case it works with every remote git repository.\nPlease contact me on twitter if something unclear or wrote in bad English!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git error: previous rebase directory .git/rebase-apply still exists but mbox given\nI'm trying to apply a patch with Git, but I'm getting this error:\n$ git am --signoff < my.patch\nprevious rebase directory /home/sashoalm/Desktop/wine-git/.git/rebase-apply still exists but mbox given.\n\nWhat does this error mean and how do I fix it?" }, { "role": "assistant", "content": "git am --abort\n\nworked for me, but git rebase --abort did not.\nWhat happened: I tried to apply a patch but it had been corrupted (likely by Gmail copy pasting in body):\ngit am bad.patch\n\nAnd Git said:\nApplying: python: fix Linetable case to LineTable in docstrings and comments\nfatal: corrupt patch at line 56\nPatch failed at 0001 python: fix Linetable case to LineTable in docstrings and comments\nThe copy of the patch that failed is found in:\n /home/ciro/git/binutils-gdb/src/.git/rebase-apply/patch\nWhen you have resolved this problem, run \"git am --continue\".\nIf you prefer to skip this patch, run \"git am --skip\" instead.\nTo restore the original branch and stop patching, run \"git am --abort\".\n\nNote how git gives out the solution: To restore the original branch and stop patching, run \"git am --abort\".\nThen I obviously ignored the message, and tried a fixed version immediately:\ngit am good.patch\n\nand got the error." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git info" }, { "role": "assistant", "content": "Shows information about a file or directory similar to what\n‘svn info’ provides. Does not currently support a -r/--revision\nargument. Use the --url option to output only the value of the URL: field." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I edit an incorrect commit message with TortoiseGit?\nHow I can edit commit message with tortoiseGIT? The question is very similar to this but I want to do this with TortoiseGit not with console, is it possible?" }, { "role": "assistant", "content": "If the commit is the head of current branch, that is easy.\n\nContext menu -> Git Commit\nTick \"Amend Last Commit\" checkbox\nCorrect your commit message\nOK\n\nIf the commit is the head of other branch, switch to that branch first.\n\nContext menu -> TortoiseGit -> Switch/Checkout\nChoose branch name\nOK\nFollow above 1-4 steps to amend commit message\n\nIf the commit is in the middle without any merge between head, you need to reset, amend and cherry-pick\n\nContext menu -> TortoiseGit -> Log\nSelect the commit -> Context menu -> Reset\nHard Reset (this will discard all work contained in commits above the selected commit as well as any un-committed changes in the working directory)\nOK\nFollow above 1-4 steps to amend commit message\nSelect from head to one commit above it -> Context menu -> Cherry-pick\nContinue" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc dimmed-zebra" }, { "role": "assistant", "content": "Similar to zebra , but additional dimming of uninteresting parts\nof moved code is performed. The bordering lines of two adjacent\nblocks are considered interesting, the rest is uninteresting. dimmed_zebra is a deprecated synonym." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-checkout-index - Copy files from the index to the working tree --stdin" }, { "role": "assistant", "content": "Instead of taking a list of paths from the command line,\nread the list of paths from the standard input. Paths are\nseparated by LF (i.e. one path per line) by default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options http.pinnedPubkey" }, { "role": "assistant", "content": "Public key of the https service. It may either be the filename of\na PEM or DER encoded public key file or a string starting with sha256// followed by the base64 encoded sha256 hash of the\npublic key. See also libcurl CURLOPT_PINNEDPUBLICKEY . git will\nexit with an error if this option is set but not supported by\ncURL." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git push Out of memory, malloc failed\n\nI am trying to push my changes remotely to GitHub, every so often git fails due to \nC:\\dev\\projects>git push -v\nPushing to https://[email protected]/mycompany/My-Project.git\nPassword for 'github.com':\nfatal: Out of memory, malloc failed (tried to allocate 524288000 bytes)\nfatal: write error: Invalid argument\n\nThis is very, very aggravating. I have run the following commands, upgraded git (which wiped out my settings and caused lots of pain, but I digress)\ngit gc --auto --prune=today --aggressive\ngit repack\n\nI have even bumped the value of\nhttp.postbuffer\n\nbut eventually it will fail again.\nThis is a typical Rails 3.1 application, total project size on disk is 9.69 MB." }, { "role": "assistant", "content": "My advice is to try several git parameters related with pack:\n[pack]\n threads = 1\n deltaCacheSize = 128m\n windowMemory = 50m\n\nWhat it got better results for me was setting git config pack.threads 1 and git config pack.windowMemory 50m (default is 10m).\nStill, my host didn't have enough RAM memory (2GB) and kept failing. I hard copied the repo and moved it to another machine with more RAM (8GB). It got better but still failed.\nFinally, I downloaded the latest version of git (https://github.com/git/git), compile it and install it. That fixed the problem just by running git repack -adf with the same parameters. After that I run git gc --aggressive --prune=now \nOnce I got the repo fixed in my local machine I pushed it to master, overwriting the remote repo, git push -f origin master. \nTo prevent similar errors in the future try not to add unnecessary large files to the repo (in my case I got a SQL dump of 3.5GB :)) and disable delta compression for large files (such as images, PDFs, videos). Add the following lines to .gitattributes:\n*.pdf -delta\n*.jpg -delta" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-pack-objects" }, { "role": "assistant", "content": "Create a packed archive of objects" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: Permission denied (publickey) fatal - Could not read from remote repository. while cloning Git repository\nI am unable to clone a Git repository, and getting this error:\nkrishna.soni@KRISHNACHANDRAS /c/Projects $ git clone http://stage.abc.com:10088/pqr\nhttp://<url>/<repository> Cloning into '<repository>'... fatal: could not read Username for 'http://<url>': No such file or directory\n\nI've read Bitbucket, Windows and “fatal: could not read Password for”, but still have the problem.\nI proceeded further but am now getting this error\nsh.exe\": chown: command not found\n\nkrishna.soni@KRISHNACHANDRAS /c\n$ git clone ssh://[email protected].\n/projects\nCloning into 'C:/projects'...\nPermission denied (publickey).\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\n> krishna.soni@KRISHNACHANDRAS /c\n> $ git clone ssh:<url>\n> ts\n> Cloning into 'C:/projects'...\n> Permission denied (publickey).\n> fatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\n\nand the repository exists." }, { "role": "assistant", "content": "For people that come here that are just trying to get the repository but don't care about the protocol (ssh / https), you might just want to use https instead of ssh (if it's supported).\nSo for example you use\ngit clone https://github.com/%REPOSITORYFOLDER%/%REPOSITORYNAME%.git\n\ninstead of\ngit clone [email protected]:%REPOSITORYFOLDER%/%REPOSITORYNAME%.git\n\nNote that GitHub deprecated password authentication (https login) for private repositories due to it not keeping up with the latest security standards, use a personal access token.\nNote also that since March 1, 2022, Bitbucket users are no longer able to use their Atlassian account password with git over https as well, but instead need to use Bitbucket app passwords." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git pushes with wrong user from terminal\nI have an issue with git and my terminal. Here's a gallery to show you my issue.\nWhen I push commits from my terminal, git says I push them with another username, that's a user from my organization (my company) with no commit at all and it seems it belongs to no one : (check gallery first pic)\nBut this doesn't happen when I use Github for mac, in the feed I see the commits pushed by myself.\nThe problem also affects my personal repositories, my terminal says that I don't have the permission to push commits on those repositories (which is obviously wrong) since it tries to push it with this user : (check gallery second pic)\nGuess what ? This doesn't happen with Github for mac too.\nI changed my computer to a brand new one few days ago, so I reset'ed all my ssh key of github and left only a new one generated by Github for Mac so I don't think that there's some ghost user/ssh key hidden somewhere, this hdd is brand new : (check gallery third pic)\nMy .gitconfig file is all clear, there's only my credentials : (check gallery fourth pic)\nI really don't get it, help, StackOverflow, you're my only hope.\n(My apologies for my poor Gimp skills and the Star Wars reference)\nEDIT : ssh-add -l only shows the good ssh key created by github for mac and I have only one github account\nEDIT2 : ssh -T [email protected] recognize me as the good user.\nEDIT3 : After a few tests it looks like my terminal does the commits with my username, but pushes them with the other one, Github for mac commits and pushes with the good username.This situation happen with every repo I have/make (even new ones).\nEDIT4 : In a personal repository git log --pretty=\"%h %an %ae\" shows my good username\nEDIT5 : No sign of environment variables that would override my credentials in my env. Even if I try to set those variables with the good credentials problem persists.\nEDIT6 : Things work back normally if I force the user in the path of /.git/config of a repository but I don't think that's the good option : http://[email protected]/USER/REPO.git\nEDIT7 : We deleted the git user that pushed the commits for me and this brings another error : remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/USER/REPO.git/'\nFINAL EDIT : I installed git with homebrew, typed git config --global push.default simple and now it takes my credentials even without forceing the user. That's strange. Thanks everybody for your help, you're great guys !" }, { "role": "assistant", "content": "I just had this problem at work. The builtin git that ships with mac or comes when you install xcode caches git credentials in keychain. The fix for me was to:\nstart keychain access (start spotlight via cmd + space, type keychain, press enter)\nUnder keychains on the upper left, select \"login\"\nUnder category on the left, select \"passwords\"\nfind the name \"github\" and delete it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "List files modified for particular git commit\nI have commit, abc, and I want to list files that were modified for the commit. \nWhat is the git command which will list modified files for that commit?" }, { "role": "assistant", "content": "For filenames only:\ngit show --name-only abc\n\nTo see a summary of what happened to them:\ngit show --name-status abc" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to search for code in all projects simultaneously?\n\nI'm dealing with a GitLab Community Edition 13.10.1.\nAt the moment there are about a hundred small projects on this.\nBy selecting a project it is possible to search for specific code within all its files, but if instead I go to the GitLab search and select \"Any\" project, the \"Code\" tab is no longer visible.\n\nIs there a way to do a code search, but within all the existing existing projects?" }, { "role": "assistant", "content": "You can use GitLab Advanced Search to search for code if you are subscribed to the premium tier.\nAnother option would be to use the opensource gitlab-search tool if you are using the community edition." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Make Git consume less disk space\nWhat is the best way for Git to consume less disk space?\nI'm using git-gc on my repositories (which does help, especially if there have been many commits since it was cloned), but I would like suggestions if there is another command to shrink the disk space used by Git." }, { "role": "assistant", "content": "There are a few suggestions I can offer:\n\nDelete no longer used branches. They can pin some commits that you don't use and would never use. Take care however to not delete branches that you would later need (perhaps for review, or for comparison of failed effort). Back up first.\n\nCheck if you didn't commit some large binary file (perhaps some generated file) by mistake. If you have, you can purge it from history using \"git filter-branch\"... well, if you didn't share the repository, or it is worth aggravating other contributors to rewrite history. Again: back up first.\n\nYou can prune more aggressively, discarding some safeties, by using git gc --prune=now, or the low-level git prune. But take care that you don't remove safeties and backups (like reflog) that you need one minute after compacting.\n\nPerhaps what enlarges your repository are some untracked files in the working directory. There \"make clean\" or \"git clean\" might help (but take care that you don't remove some important files).\n\nMost safe of all those suggestions: you can try to pack more aggressively, using --depth and --window option of low-level git-repack. See also Git Repack Parameters blog post by Pieter de Bie on his DVCS Comparison blog, from June 6, 2008. Or \"git gc --aggressive\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Remove file from Version Control in IntelliJ IDEA\nI'm using IntelliJ IDEA Community Edition 2016.1.\nI've put my project under Git, hosted it on GitHub.\nWhen I first hit that Share Project on GitHub button, every single file was selected to be put under version control.\nNow I want to exclude the module IML file from version control. Obliviously, I want to keep it on my hard disk. Unfortunately, I cannot find a way to do this. How do I achieve this?\nI tried to delete it from the web interface, but I'm getting some fatal errors while pulling/pushing." }, { "role": "assistant", "content": "There is a little trick.\n\nGo to File Menu-> Settings | Version Control | Confirmation, then check the Show options before adding to version control setting under the When files are created section.\nAlternatively, you could check Do not add. It is mandatory that you do not check Add silently.\nDelete the file you don't want to be tracked by VCS.\nPress Ctrl + Z to undo the removal of the file.\nIf IDE shows a popup window which lets you choose whether or not to add the new file to VCS, click No.\nCommit your local changes, and the files are removed from VCS." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to rename git root folder?\nI've just started using git in Vista, with my repository under /path/to/project/git repo.\nI've now found that the space in the folder name is a minor irritation when working in git bash.\nCan I just rename the folder to /path/to/project/gitrepo? Is everything within the git config relative, or is there anything that explicitly refers to the parent folder?\nI've tried just taking a windows copy of the main folder, and run git bash on that, and 'git log' shows the changes I had previously made. So I assume renaming the main folder is OK, but I'd like to be sure before I go any further." }, { "role": "assistant", "content": "Yes, it is safe to rename the folder containing a Git repository. All paths inside the Git repository are relative." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Create a git patch from the uncommitted changes in the current working directory\nSay I have uncommitted changes in my working directory. How can I make a patch from those without having to create a commit?" }, { "role": "assistant", "content": "If you haven't yet commited the changes, then:\ngit diff > mypatch.patch\n\nBut sometimes it happens that part of the stuff you're doing are new files that are untracked and won't be in your git diff output. So, one way to do a patch is to stage everything for a new commit (git add each file, or just git add .) but don't do the commit, and then:\ngit diff --cached > mypatch.patch\n\nAdd the 'binary' option if you want to add binary files to the patch (e.g. mp3 files):\ngit diff --cached --binary > mypatch.patch\n\nYou can later apply the patch:\ngit apply mypatch.patch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add Git's branch name to the commit message?\nI need some help with a Bash script that will automatically add the git's branch name as a hash in commit messages." }, { "role": "assistant", "content": "Here is my commit-msg script as an example:\n#!/bin/sh\n#\n# Automatically adds branch name and branch description to every commit message.\n#\nNAME=$(git branch | grep '*' | sed 's/* //') \nDESCRIPTION=$(git config branch.\"$NAME\".description)\n\necho \"$NAME\"': '$(cat \"$1\") > \"$1\"\nif [ -n \"$DESCRIPTION\" ] \nthen\n echo \"\" >> \"$1\"\n echo $DESCRIPTION >> \"$1\"\nfi \n\nCreates following commit message: \n[branch_name]: [original_message]\n\n[branch_description]\n\nI'm using issue number as branch_name, issue description is placed to the branch_description using git branch --edit-description [branch_name] command.\nMore about branch descriptions you can find on this Q&A.\nThe code example is stored in following Gist." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-restore - 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": "git-config - Get and set repository or global options repack.writeBitmaps" }, { "role": "assistant", "content": "When true, git will write a bitmap index when packing all\nobjects to disk (e.g., when git repack -a is run). This\nindex can speed up the \"counting objects\" phase of subsequent\npacks created for clones and fetches, at the cost of some disk\nspace and extra time spent on the initial repack. This has\nno effect if multiple packfiles are created.\nDefaults to true on bare repos, false otherwise." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fetch - Download objects and refs from another repository --porcelain" }, { "role": "assistant", "content": "Print the output to standard output in an easy-to-parse format for\nscripts. See section OUTPUT in git-fetch for details. This is incompatible with --recurse-submodules=[yes|on-demand] and takes\nprecedence over the fetch.output config option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Cannot pull, git cannot resolve reference ORIG_HEAD\nwhile pulling into my git repository from our central server, this error occured:\n$ git pull origin master\n\nFrom http://aaa/repo\n * branch master -> FETCH_HEAD\nerror: unable to resolve reference ORIG_HEAD: No such file or directory\nfatal: Cannot lock the ref 'ORIG_HEAD'.\n\nI've tried git gc (with --prune=now) and looking for a similar error, unfortunately with no luck." }, { "role": "assistant", "content": "I had this problem, and I solved it by removing the file .git/ORIG_HEAD then doing the pull again. The .git/ORIG_HEAD file was 0 bytes instead of the git reference it was supposed to contain, so I just got rid of it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-upload-pack: command not found, when cloning remote Git repo\nI have been using git to keep two copies of my project in sync, one is my local box, the other the test server.\nThis is an issue which occurs when I log onto our remote development server using ssh;\ngit clone [email protected]:/home/chris/myproject\nInitialized empty Git repository in /tmp/myproject/.git/\nPassword:\nbash: git-upload-pack: command not found\nfatal: The remote end hung up unexpectedly\nfetch-pack from '[email protected]:/home/chris/myproject' failed.\n\n(the file-names have been changed to protect the guilty... !) \nBoth boxes run Solaris 10 AMD. I have done some digging, if I add --upload-pack=$(which git-upload-pack) the command works, (and proves that $PATH contains the path to 'git-upload-pack' as per the RTFM solution) but this is really annoying, plus 'git push' doesn't work, because I don't think there is a --unpack= option. \nIncidentally, all the git commands work fine from my local box, it is the same version of the software (1.5.4.2), installed on the same NFS mount at /usr/local/bin. \nCan anybody help?" }, { "role": "assistant", "content": "Make sure git-upload-pack is on the path from a non-login shell. (On my machine it's in /usr/bin).\nTo see what your path looks like on the remote machine from a non-login shell, try this:\nssh you@remotemachine echo \\$PATH\n\n(That works in Bash, Zsh, and tcsh, and probably other shells too.)\nIf the path it gives back doesn't include the directory that has git-upload-pack, you need to fix it by setting it in .bashrc (for Bash), .zshenv (for Zsh), .cshrc (for tcsh) or equivalent for your shell.\nYou will need to make this change on the remote machine.\nIf you're not sure which path you need to add to your remote PATH, you can find it with this command (you need to run this on the remote machine):\nwhich git-upload-pack\nOn my machine that prints /usr/bin/git-upload-pack. So in this case, /usr/bin is the path you need to make sure is in your remote non-login shell PATH." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can sbt pull dependency artifacts from git?\nI've heard (and I know I've seen examples too, if only I can remember where) that sbt can obtain dependencies from a git repo.\nI am looking to obtain the dependency harrah/up from github. The repository does not provide any artifact JAR files, only a source tree which is set up to be built using sbt. The process that I am imagining is that sbt will download the source repo, build it, and then use that as the dependency artifact.\nI may be imagining that sbt can in fact do something like this. Can it? And if so, how?" }, { "role": "assistant", "content": "You can import unpackaged dependencies into your project from GitHub by treating them as project dependencies, using the dependsOn operator. (This is distinct from the way that precompiled library dependencies are included).\nNote that you can specify which branch to pull using # notation. Here's some Scala SBT code that is working well for me:\nobject V {\n val depProject = \"master\"\n // Other library versions\n}\n\nobject Projects {\n lazy val depProject = RootProject(uri(\"git://github.com/me/dep-project.git#%s\".format(V.depProject)))\n}\n\n// Library dependencies\nlazy val myProject = Project(\"my-project\", file(\".\"))\n.settings(myProjectSettings: _*)\n.dependsOn(Projects.depProject)\n.settings(\n libraryDependencies ++= Seq(...\n\nNote that if you have multiple SBT projects dependending on the same external project, it's worth setting up a central sbt.boot.directory to avoid unnecessary recompilations (see instructions here)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git - How to undo a checkout of unstaged files which discards local changes\nI accidentially discard my changes on files in my local working tree via git checkout. The files aren't staged at this time. Is it posible to \"undo\" this checkout?" }, { "role": "assistant", "content": "If you are using a \"professional\" IDE chances are good that you can restore files from a local History.\nIn Rubymine for example you can right click files and watch a history of changes independent from the git changes, saved me a few times now ^^" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Changing case of Folder via Git bash on Windows\nI need to change the case of folders and files. First thing I tried was renaming the folders, but Git didn't pick up the changes. So I tried using git mv -f controller Controller but it says :\nfatal: renaming 'application/classes/controller failed: Permission denied\nI have tried setting the global ignorecase flag:\ngit config --global core.ignorecase false\nBut it still doesn't work. Some people have suggested to move the folder out of repo, delete, then re-add but would this change get picked up when other people pull the repo? Is there anything else I could try?\nEdit: It works for files but not folders." }, { "role": "assistant", "content": "In summary of the comments, you'll have to rename the directory via a intermediate temporary name. E.g.\ngit mv controller Controller-tmp\ngit mv Controller-tmp Controller\n\nI think this has to do with the fact that the MinGW implementation of rename(2) does not support this operation. See this thread, the MSDN docs on the CRT rename implementation and those of the MoveFileEx function." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github (SSH) via public WIFI, port 22 blocked\n\nI'm currently on a public WIFI spot and I'm unable to use SSH (they probably blocked that port). However, I need that connection to do a git push.\n➜ ssh -T [email protected]\nssh: connect to host github.com port 22: Connection refused\n\nIs it possible to bypass this restriction by setting up a SSH tunnel via port 80 and tell github push to use that connection? How to do that? I'm on OSX (lion). This must be a common problem?" }, { "role": "assistant", "content": "Try this:\n$ vim ~/.ssh/config\n\nAdd\nHost github.com\n Hostname ssh.github.com\n Port 443\n\nSource: https://help.github.com/articles/using-ssh-over-the-https-port" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects --progress" }, { "role": "assistant", "content": "Progress status is reported on the standard error stream\nby default when it is attached to a terminal, unless -q\nis specified. This flag forces progress status even if the\nstandard error stream is not directed to a terminal." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects %e" }, { "role": "assistant", "content": "encoding" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I list all the deleted files in a Git repository?\nI know Git stores information of when files get deleted and I am able to check individual commits to see which files have been removed, but is there a command that would generate a list of every deleted file across a repository's lifespan?" }, { "role": "assistant", "content": "git log --diff-filter=D --summary\n\nSee Find and restore a deleted file in a Git repository\nIf you don't want all the information about which commit they were removed in, you can just add a grep delete in there.\ngit log --diff-filter=D --summary | grep delete" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs no" }, { "role": "assistant", "content": "Moved lines are not highlighted." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git fetch/pull/clone hangs on receiving objects\nWhen fetching or pulling from git repositories, or cloning a repository, I get to this point: \nremote: Counting objects: 6666, done.\nremote: Compressing objects: 100% (5941/5941), done.\nReceiving objects: 23% (1534/6460), 11.68 MiB | 23 KiB/s \n\nAnd it hangs. The 23%/number of objects isn't a given, it ranges from single digits to up to the 60s, it seems. Also the speed for download listed freezes -- it's not like it slowly crawls down towards zero.\nThe guy I sit next to has no issues, so it's not a router problem. We use beanstalk for our work repositories, but I have the issue from beanstalk and github (although occaisonally it seems a github one will finish). \nThe problem has only seemed to crop up since upgrading to Mountain Lion and updating Xcode. I've wiped git (including XCode's) and tried installing it with homebrew. That didn't work, so I removed it and tried with their provided Mac installation package which also didn't fix the issue. \nBeanstalk provides SSH urls for the git repository, but I've had no issues with connecting via SCP or SSH to servers that I've done work on. \nThis is killing my workflow so any help would be much appreciated!" }, { "role": "assistant", "content": "VMware on NAT had this problem for me. Changing it to Bridged (replicate the state) fixed the issue." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "fatal: The upstream branch of your current branch does not match the name of your current branch\nAfter doing a checkout of the remote branch releases/rel_5.4.1 using the Git GUI, I'm seeing this unexpected error message when I try to push:\nfatal: The upstream branch of your current branch does not match\nthe name of your current branch. To push to the upstream branch\non the remote, use\n\n git push origin HEAD:releases/rel_5.4.1\n\nTo push to the branch of the same name on the remote, use\n\n git push origin rel_5.4.1\n\nI don't know what Git is talking about. I probably want to push to origin releases/rel_5.4.1 since that's the branch which I checked out. So neither option seems correct to me.\ngit status says I'm on branch rel_5.4.1.\nHere is the branch as it appears in my .git/config:\n[branch \"rel_5.4.1\"]\n remote = origin\n merge = refs/heads/releases/rel_5.4.1\n\nWhat is going on?" }, { "role": "assistant", "content": "This happens if the name of the upstream branch and local branch do not match, which sometimes happens, and usually is unwanted:\n> git status\nOn branch release-1.2.3\nYour branch is up to date with 'origin/master'.\n\nTo solve this, run:\ngit branch --unset-upstream\n\nThen, once you run git push again, you will be asked to use the --set-upstream option to set the upstream branch correctly." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to tell which commit a tag points to in Git?\nI have a bunch of unannotated tags in the repository and I want to work out which commit they point to. Is there a command that that will just list the tags and their commit SHAs? Checking out the tag and looking at the HEAD seems a bit too laborious to me.\nUpdate\nI realized after I went through the responses that what I actually wanted was to simply look at the history leading up to the tag, for which git log <tagname> is sufficient. \nThe answer that is marked as answer is useful for getting a list of tags and their commits, which is what I asked. With a bit of shell hackery I'm sure it's possible to transform those into SHA+Commit message." }, { "role": "assistant", "content": "One way to do this would be with git rev-list. The following will output the commit to which a tag points:\n$ git rev-list -n 1 $TAG\n\nNOTE This works for both Annotated and Unannotated tags\nYou could add it as an alias in ~/.gitconfig if you use it a lot:\n[alias]\n tagcommit = rev-list -n 1\n\nAnd then call it with:\n$ git tagcommit $TAG\n\nPossible pitfall: if you have a local checkout or a branch of the same tag name, this solution might get you \"warning: refname 'myTag' is ambiguous\". In that case, try increasing specificity, e.g.:\n$ git rev-list -n 1 tags/$TAG" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What are some examples of commonly used practices for naming git branches? [closed]\nClosed. This question is opinion-based. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\nWant to improve this question? Update the question so it can be answered with facts and citations by editing this post.\n\n\nClosed 7 years ago.\n\n\nThe community reviewed whether to reopen this question 2 years ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI've been using a local git repository interacting with my group's CVS repository for several months, now. I've made an almost neurotic number of branches, most of which have thankfully merged back into my trunk. But naming is starting to become an issue. If I have a task easily named with a simple label, but I accomplish it in three stages which each include their own branch and merge situation, then I can repeat the branch name each time, but that makes the history a little confusing. If I get more specific in the names, with a separate description for each stage, then the branch names start to get long and unwieldy.\nI did learn looking through old threads here that I could start naming branches with a / in the name, i.e., topic/task, or something like that. I may start doing that and seeing if it helps keep things better organized.\nWhat are some best practices for naming git branches?\nEdit:\nNobody has actually suggested any naming conventions.\nI do delete branches when I'm done with them. I just happen to have several around due to management constantly adjusting my priorities. :)\nAs an example of why I might need more than one branch on a task, suppose I need to commit the first discrete milestone in the task to the group's CVS repository. At that point, due to my imperfect interaction with CVS, I would perform that commit and then kill that branch. (I've seen too much weirdness interacting with CVS if I try to continue to use the same branch at that point.)" }, { "role": "assistant", "content": "Here are some branch naming conventions that I use and the reasons for them\nBranch naming conventions\n\nUse grouping tokens (words) at the beginning of your branch names.\nDefine and use short lead tokens to differentiate branches in a way that is meaningful to your workflow.\nUse slashes to separate parts of your branch names.\nDo not use bare numbers as leading parts.\nAvoid long descriptive names for long-lived branches.\n\nGroup tokens\nUse \"grouping\" tokens in front of your branch names. \ngroup1/foo\ngroup2/foo\ngroup1/bar\ngroup2/bar\ngroup3/bar\ngroup1/baz\n\nThe groups can be named whatever you like to match your workflow. I like to use short nouns for mine. Read on for more clarity.\nShort well-defined tokens\nChoose short tokens so they do not add too much noise to every one of your branch names. I use these:\nwip Works in progress; stuff I know won't be finished soon\nfeat Feature I'm adding or expanding\nbug Bug fix or experiment\njunk Throwaway branch created to experiment\n\nEach of these tokens can be used to tell you to which part of your workflow each branch belongs.\nIt sounds like you have multiple branches for different cycles of a change. I do not know what your cycles are, but let's assume they are 'new', 'testing' and 'verified'. You can name your branches with abbreviated versions of these tags, always spelled the same way, to both group them and to remind you which stage you're in.\nnew/frabnotz\nnew/foo\nnew/bar\ntest/foo\ntest/frabnotz\nver/foo\n\nYou can quickly tell which branches have reached each different stage, and you can group them together easily using Git's pattern matching options.\n$ git branch --list \"test/*\"\ntest/foo\ntest/frabnotz\n\n$ git branch --list \"*/foo\"\nnew/foo\ntest/foo\nver/foo\n\n$ gitk --branches=\"*/foo\"\n\nUse slashes to separate parts\nYou may use most any delimiter you like in branch names, but I find slashes to be the most flexible. You might prefer to use dashes or dots. But slashes let you do some branch renaming when pushing or fetching to/from a remote.\n$ git push origin 'refs/heads/feature/*:refs/heads/phord/feat/*'\n$ git push origin 'refs/heads/bug/*:refs/heads/review/bugfix/*'\n\nFor me, slashes also work better for tab expansion (command completion) in my shell. The way I have it configured I can search for branches with different sub-parts by typing the first characters of the part and pressing the TAB key. Zsh then gives me a list of branches which match the part of the token I have typed. This works for preceding tokens as well as embedded ones.\n$ git checkout new<TAB>\nMenu: new/frabnotz new/foo new/bar\n\n\n$ git checkout foo<TAB>\nMenu: new/foo test/foo ver/foo\n\n(Zshell is very configurable about command completion and I could also configure it to handle dashes, underscores or dots the same way. But I choose not to.)\nIt also lets you search for branches in many git commands, like this:\ngit branch --list \"feature/*\"\ngit log --graph --oneline --decorate --branches=\"feature/*\" \ngitk --branches=\"feature/*\" \n\nCaveat: As Slipp points out in the comments, slashes can cause problems. Because branches are implemented as paths, you cannot have a branch named \"foo\" and another branch named \"foo/bar\". This can be confusing for new users.\nDo not use bare numbers\nDo not use use bare numbers (or hex numbers) as part of your branch naming scheme. Inside tab-expansion of a reference name, git may decide that a number is part of a sha-1 instead of a branch name. For example, my issue tracker names bugs with decimal numbers. I name my related branches CRnnnnn rather than just nnnnn to avoid confusion. \n$ git checkout CR15032<TAB>\nMenu: fix/CR15032 test/CR15032\n\nIf I tried to expand just 15032, git would be unsure whether I wanted to search SHA-1's or branch names, and my choices would be somewhat limited.\nAvoid long descriptive names\nLong branch names can be very helpful when you are looking at a list of branches. But it can get in the way when looking at decorated one-line logs as the branch names can eat up most of the single line and abbreviate the visible part of the log.\nOn the other hand long branch names can be more helpful in \"merge commits\" if you do not habitually rewrite them by hand. The default merge commit message is Merge branch 'branch-name'. You may find it more helpful to have merge messages show up as Merge branch 'fix/CR15032/crash-when-unformatted-disk-inserted' instead of just Merge branch 'fix/CR15032'." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails --no-to --no-cc --no-bcc" }, { "role": "assistant", "content": "Clears any list of \"To:\", \"Cc:\", \"Bcc:\" addresses previously\nset via config." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-commit - Record changes to the repository --amend" }, { "role": "assistant", "content": "Replace the tip of the current branch by creating a new\ncommit. The recorded tree is prepared as usual (including\nthe effect of the -i and -o options and explicit\npathspec), and the message from the original commit is used\nas the starting point, instead of an empty message, when no\nother message is specified from the command line via options\nsuch as -m , -F , -c , etc. The new commit has the same\nparents and author as the current one (the --reset-author option can countermand this). It is a rough equivalent for: $ git reset --soft HEAD^\n\t$ ... do something else to come up with the right tree ...\n\t$ git commit -c ORIG_HEAD but can be used to amend a merge commit. You should understand the implications of rewriting history if you\namend a commit that has already been published. (See the \"RECOVERING\nFROM UPSTREAM REBASE\" section in git-rebase .)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc minimal" }, { "role": "assistant", "content": "Spend extra time to make sure the smallest possible diff is\nproduced." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to pass variables between gitlab-ci jobs?\n\nI have a gitlab-ci like this:\nstages:\n- calculation\n- execution\n\ncalculation-job:\n stage: calculation\n script: ./calculate_something_and_output_results.sh\n tags:\n - my-runner\n\nexecution-job:\n stage: execution\n script: ./execute_something_with_calculation_results.sh foo\n tags:\n - my-runner\n\nThe foo argument in execution-job is base on the results of calculation-job. I want to pass the results from one job to another job via variables. How can I do that?" }, { "role": "assistant", "content": "If you're looking to get the results without storing a file anywhere you can use artifacts: reports: dotenv. This is taken entirely from DarwinJS shared-variables-across-jobs repo.\nstages:\n - calculation\n - execution\n\ncalculation-job:\n stage: calculation\n script: - |\n # stores new or updates existing env variables, ex. $OUTPUT_VAR1\n ./calculate_something_and_output_results.sh >> deploy.env\n tags:\n - my-runner\n artifacts:\n reports:\n #propagates variables into the pipeline level, but never stores the actual file\n dotenv: deploy.env\n\nexecution-job:\n stage: execution\n script: - |\n echo \"OUTPUT_VAR1: $OUTPUT_VAR1\"\n ./execute_something_with_calculation_results.sh foo\n tags:\n - my-runner" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Checkout warning: unable to unlink files, permission denied\nI am aware that there are similar issues about git relating to the 'unable to unlink' warning, but I have not been able to use them.\nThe main difference is that this happened when I have not been dealing with submodules in any way (I have never dealt with them before). I created a branch called 'upgrade', deleted my old framework files, and copied in the new ones. I used git add -A, then committed everything. When I tried to checkout the trunk branch, it responded with the following errors:\nwarning: unable to unlink requirements/views/sk/index.php: Permission denied\nwarning: unable to unlink requirements/views/sv/index.php: Permission denied\nwarning: unable to unlink requirements/views/zh/index.php: Permission denied\nwarning: unable to unlink requirements/views/zh_cn/index.php: Permission denied\nwarning: unable to unlink requirements/views/zh_tw/index.php: Permission denied\n\n...etc. There are hundreds of them.\nAt first I thought this was simply a permissions problem, and so I added group write permissions to the entire requirements directory recursively, but there was no change.\nEdit: As suggested in an answer below, I attempted to do the same thing but with everything else closed. I had no more luck than before.\nThis issue is particularly debilitating as I cannot move to trunk to get back to normal development." }, { "role": "assistant", "content": "In my first encounter with this error my user had rights to \"write\" to the file but not the containing directory. Check the permissions of the directory containing the file." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git LFS files not found on server\n\nWe have been using Git with git-lfs hosted by our own instance of Gitlab.\nSometimes when one particular user pushes files, some of them (seems to be .png files) don't make it to the LFS storage, but are added to git. I haven't been able to see the log / messages when this happens yet on their machine.\nBut what ends up happening is when other users try to download that file from LFS, it throws an error:\n\n[28bbec36fe441b7de97d566872c71cd4542384d871b369168285408c1f062cfd] Object does not exist on the server or you don't have permissions to access it\n\nI have tried manually uploading a file in its place on the Gitlab server in the git-lfs data directory with the correct SHA ID for the file name, but it doesn't seem to get picked up. So far my only solution is to touch the file so it generates a different SHA ID, and re-upload it.\nIs there any way to manually add an individual file to Gitlab's git-lfs storage?" }, { "role": "assistant", "content": "i guess that the git-lfs was not installed correctly on the clientside of the client pushing. However, if you have git-lfs 0.5.4 you should be able to fix it with following:\n# git lfs push --object-id origin [oid] [oid] [oid]\n$ git lfs push --object-id origin 28bbec36fe441b7de97d566872c71cd4542384d871b369168285408c1f062cfd" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-for-each-ref - Output information on each ref raw:size" }, { "role": "assistant", "content": "The raw data size of the object." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --glob=<glob-pattern>" }, { "role": "assistant", "content": "Pretend as if all the refs matching shell glob <glob-pattern> are listed on the command line as <commit> . Leading refs/ ,\nis automatically prepended if missing. If pattern lacks ? , * ,\nor [ , /* at the end is implied." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Docker multi platform builds extremely slow for ARM64 on Gitlab CI\n\nI have the following dockerfile for a Node.js application\n# ---> Build stage\nFROM node:18-bullseye as node-build\n\nENV NODE_ENV=production\nWORKDIR /usr/src/app\nCOPY . /usr/src/app/\nRUN yarn install --silent --production=true --frozen-lockfile\nRUN yarn build --silent\n\n# ---> Serve stage\nFROM nginx:stable-alpine\nCOPY --from=node-build /usr/src/app/dist /usr/share/nginx/html\n\nUp until now I was building exclusively for AMD64, but now I need to build also for ARM64.\nI edited my .gitlab-ci.yml to look like the following\nimage: docker:20\n\nvariables:\n PROJECT_NAME: \"project\"\n BRANCH_NAME: \"main\"\n IMAGE_NAME: \"$PROJECT_NAME:$CI_COMMIT_TAG\"\n\nservices:\n - docker:20-dind\n\nbuild_image:\n script:\n # Push to Gitlab registry\n - docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD\n - docker context create builder-context\n - docker buildx create --name builderx --driver docker-container --use builder-context\n - docker buildx build --tag $CI_REGISTRY/mygroup/$PROJECT_NAME/$IMAGE_NAME --push --platform=linux/arm64/v8,linux/amd64 .\n\nEverything works relatively fine for AMD64 but it is extremely slow for ARM64. Almost 10x slower than AMD64, giving me timeouts on the Gitlab Job.\nIs there any way to speed up the process?" }, { "role": "assistant", "content": "I'm guessing your pipeline is executing on amd64 hardware and that docker buildx is performing emulation to build the arm64 target. You will likely see a large improvement if you break build_image into two jobs (one for amd64 and one for arm64) and then send them to two different gitlab runners so that they each can execute on their native hardware.\nEven if you can't or don't want stop using emulation, you could still break the build_image job into two jobs (one per image built) in hopes that running them in parallel will allow the jobs to finish before the timeout limit.\nWith changes to your Dockerfile and the use of image caching you can make some of your subsequent builds faster, but these changes won't help you until you get an initial image built (which can be used as the cache).\nUpdated Dockerfile:\n# ---> Build stage\nFROM node:18-bullseye as node-build\n\nENV NODE_ENV=production\nWORKDIR /usr/src/app\n# only COPY yarn.lock so not to break cache if dependencies have not changed\nCOPY . /usr/src/app/yarn.lock \nRUN yarn install --silent --production=true --frozen-lockfile\n# once the dependencies are installed, then copy in the frequently changing source code files\nCOPY . /usr/src/app/\nRUN yarn build --silent\n\n# ---> Serve stage\nFROM nginx:stable-alpine\nCOPY --from=node-build /usr/src/app/dist /usr/share/nginx/html\n\nUpdated gitlab-ci.yml:\nimage: docker:20\n\nvariables:\n PROJECT_NAME: \"project\"\n BRANCH_NAME: \"main\"\n IMAGE_NAME: \"$PROJECT_NAME:$CI_COMMIT_TAG\"\n REGISTRY_IMAGE_NAME: \"$CI_REGISTRY/mygroup/$PROJECT_NAME/$IMAGE_NAME\"\n CACHE_IMAGE_NAME: \"$CI_REGISTRY/mygroup/$PROJECT_NAME/$PROJECT_NAME:cache\"\n BUILDKIT_INLINE_CACHE: \"1\"\n\nservices:\n - docker:20-dind\n\nstages:\n - build\n - push\n\nbefore_script:\n - docker login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD\n - docker context create builder-context\n - docker buildx create --name builderx --driver docker-container --use builder-context\n\nbuild_amd64:\n stage: build\n script:\n - docker buildx build --cache-from \"$CACHE_IMAGE_NAME\" --tag \"$CACHE_IMAGE_NAME\" --push --platform=linux/amd64 .\n\nbuild_arm64:\n stage: build\n script:\n - docker buildx build --cache-from \"$CACHE_IMAGE_NAME\" --tag \"$CACHE_IMAGE_NAME\" --push --platform=linux/arm64/v8 .\n\npush:\n stage: push\n script: \n - docker buildx build --cache-from \"$CACHE_IMAGE_NAME\" --tag \"$REGISTRY_IMAGE_NAME\" --push --platform=linux/arm64/v8,linux/amd64 .\n\nThe build_amd64 and build_arm64 jobs each pull in the last image (of their arch) that was built and use it as a cache for docker image layers. These two build jobs then push their result back as the new cache.\nThe push stage runs docker buildx ... again, but they won't actually build anything new as they will just pull in the cached results from the two build jobs. This allows you to break up the builds but still have a single push command that results in the two different images ending up in a single multi-platform docker manifest." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is a tracking branch?\nCan someone explain a \"tracking branch\" as it applies to git?\nHere's the definition from git-scm.com:\n\nA 'tracking branch' in Git is a local\n branch that is connected to a remote\n branch. When you push and pull on that\n branch, it automatically pushes and\n pulls to the remote branch that it is\n connected with.\nUse this if you always pull from the\n same upstream branch into the new\n branch, and if you don't want to use\n \"git pull\" explicitly.\n\nUnfortunately, being new to git and coming from SVN, that definition makes absolutely no sense to me.\nI'm reading through \"The Pragmatic Guide to Git\" (great book, by the way), and they seem to suggest that tracking branches are a good thing and that after creating your first remote (origin, in this case), you should set up your master branch to be a tracking branch, but it unfortunately doesn't cover why a tracking branch is a good thing or what benefits you get by setting up your master branch to be a tracking branch of your origin repository.\nCan someone please enlighten me (in English)?" }, { "role": "assistant", "content": "The ProGit book has a very good explanation:\nTracking Branches\nChecking out a local branch from a remote branch automatically creates what is called a tracking branch. Tracking branches are local branches that have a direct relationship to a remote branch. If you’re on a tracking branch and type git push, Git automatically knows which server and branch to push to. Also, running git pull while on one of these branches fetches all the remote references and then automatically merges in the corresponding remote branch.\nWhen you clone a repository, it generally automatically creates a master branch that tracks origin/master. That’s why git push and git pull work out of the box with no other arguments. However, you can set up other tracking branches if you wish — ones that don’t track branches on origin and don’t track the master branch. The simple case is the example you just saw, running git checkout -b [branch] [remotename]/[branch]. If you have Git version 1.6.2 or later, you can also use the --track shorthand:\n$ git checkout --track origin/serverfix\nBranch serverfix set up to track remote branch refs/remotes/origin/serverfix.\nSwitched to a new branch \"serverfix\"\n\nTo set up a local branch with a different name than the remote branch, you can easily use the first version with a different local branch name:\n$ git checkout -b sf origin/serverfix\nBranch sf set up to track remote branch refs/remotes/origin/serverfix.\nSwitched to a new branch \"sf\"\n\nNow, your local branch sf will automatically push to and pull from origin/serverfix.\nBONUS: extra git status info\nWith a tracking branch, git status will tell you how far behind your tracking branch you are - useful to remind you that you haven't pushed your changes yet! It looks like this:\n$ git status\nOn branch master\nYour branch is ahead of 'origin/master' by 1 commit.\n (use \"git push\" to publish your local commits)\n\nor\n$ git status\nOn branch dev\nYour branch and 'origin/dev' have diverged,\nand have 3 and 1 different commits each, respectively.\n (use \"git pull\" to merge the remote branch into yours)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --indent-heuristic" }, { "role": "assistant", "content": "Enable the heuristic that shifts diff hunk boundaries to make patches\neasier to read. This is the default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GPG vs SSH keys\n\nOn GitHub, I want to add a key to associate my computer with my account and I am given two options: create an SSH or a GPG key. \nWhat is the difference between the two keys? and is there a preferred one to use?\nI understand how to create both by following the guide on the site but I don't know which one is better to use." }, { "role": "assistant", "content": "I want to add a key to associate my computer with my account and I am given two options\n\nYou will need at least the SSH one, if you want to push back to your repository, using an SSH URL (since the public SSH key will authenticate you).\nStart with SSH. See \"Connecting to GitHub with SSH\".\nLater, you can use GPG to sign commits.\n\nNote: Since Aug. 2022, GitHub also supports SSH commit verification\n\n\nVishwas M.R points out in the comments to \"Why would I sign my git commits with a GPG key when I already use an SSH key to authenticate myself when I push?\"\n\nWhen you authenticate to Github with your SSH key, that authentication doesn't become part of the repository in any meaningful or lasting way.\nIt causes Github to give you access for the moment, but it doesn't prove anything to anyone who is not Github.\nWhen you GPG-sign a Git tag, that tag is part of the repository, and can be pushed to other copies of the repository.\nThus, other people who clone your repository can verify the signed tag, assuming that they have access to your public key and reason to trust it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --no-notes" }, { "role": "assistant", "content": "Do not show notes. This negates the above --notes option, by\nresetting the list of notes refs from which notes are shown.\nOptions are parsed in the order given on the command line, so e.g.\n\"--notes --notes=foo --no-notes --notes=bar\" will only show notes\nfrom \"refs/notes/bar\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Hub Clone All Branches At Once\n\nI'm trying to clone an entire repository onto my machine using linux. I used \ngit clone <url> \n\nI then went into the folder where it was downloaded and typed\ngit branch \n\nin the terminal. It's only showing me master and not other branches which were in the remote repository. How do I clone all branches?\nI know that for each branch in the remote I can separately use \ngit checkout -b <name of local branch> origin/<name of remote branch>\n\nbut is there any way other than that?" }, { "role": "assistant", "content": "(1) Inside git local repostitory, create a new sh file\ntouch getAllBranches.sh\nvi getAllBranches.sh\n\n(2) Insert the below content to getAllBranches.sh file:\nfor branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do\n git branch --track ${branch#remotes/origin/} $branch\ndone\n\n(3) Get all branches:\nchmod +x getAllBranches.sh \nsh getAllBranches.sh\n\n(4) Check result at local repository:\ngit branch\n\nFor example, I use repository: https://github.com/donhuvy/spring-boot\nAs you can see, I have fetched all branches to local machine:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I know if a branch has been already merged into master?\nI have a git repository with multiple branches. \nHow can I know which branches are already merged into the master branch?" }, { "role": "assistant", "content": "git branch --merged master lists branches merged into master\ngit branch --merged lists branches merged into HEAD (i.e. tip of current branch)\ngit branch --no-merged lists branches that have not been merged\nBy default this applies to only the local branches. The -a flag will show both local and remote branches, and the -r flag shows only the remote branches." } ]
[ { "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>] --cached [--merge-base] [<commit>] [--] [<path>…​]" }, { "role": "assistant", "content": "This form is to view the changes you staged for the next\ncommit relative to the named <commit>. Typically you\nwould want comparison with the latest commit, so if you\ndo not give <commit>, it defaults to HEAD.\nIf HEAD does not exist (e.g. unborn branches) and\n<commit> is not given, it shows all staged changes.\n--staged is a synonym of --cached. If --merge-base is given, instead of using <commit>, use the merge base\nof <commit> and HEAD. git diff --cached --merge-base A is equivalent to git diff --cached $(git merge-base A HEAD) ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In Github, is there a way to search for pull requests created by any author from a provided list?\n\nFor my team's weekly builds, I go through all pull requests from the company GitHub and pull out the PRs associated to my team. This requires an annoying sieving step that requires a walk-through of the company's previous week of code contribution.\nI looked at the official GitHub search documentation (HERE) and found the \"author\" field could be used to narrow down the search in the way I want, but when I try this at https://github.com/pulls it only works on one author at a time.\nIs there a way to search across a list of authors?\nFor a little extra context, my team operates across a large list of repos, all of which are under a blanket organization which houses all repos across the company." }, { "role": "assistant", "content": "Make sure that you are using the full search at https://github.com/search.\nThen simply add extra author: <name> fields to your query. The searching engine will OR fields. For example:\nis:pr author:username1 author:username2\n(Note that this only works on https://github.com/search. The search syntax on other pages, like https://github.com/pulls, is severely limited and does not support searching by multiple authors. If you try the same search on https://github.com/pulls, GitHub will simply ignore all but one author that you list.)\nTo limit it to repositories by a specific owner, add the user: <owner> field to the query." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git gc" }, { "role": "assistant", "content": "Compress $GIT_DIR/svn/<refname>/unhandled.log files and remove\n$GIT_DIR/svn/<refname>/index files." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is libintl.h and where can I get it?\nTrying to do a make install of git from source, and it keep kicking up the error:\n make install\n* new build flags or prefix\nCC credential-store.o\nIn file included from credential-store.c:1:\nIn file included from ./cache.h:8:\n./gettext.h:17:11: fatal error: 'libintl.h' file not found\n# include <libintl.h>\n ^\n1 error generated.\nmake: *** [credential-store.o] Error 1\n\nNo amount of Googling has turned up anything on lib.intl.h. What is this elusive library, and how can I get it so I can finally install git?" }, { "role": "assistant", "content": "FWIW on OSX with El Capitan and homebrew, I did a:\n1) I wasn't sure if the El Capitan upgrade had broken something, so first I made sure I had the latest gettext:\n$ brew reinstall gettext\n\nThen I had to re-link by doing:\n$ brew unlink gettext && brew link gettext --force\n\nAfter that, other tools were able to find it, and life went back to normal." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove subversion remote in git?\nI have a git repository that was originally created using git-svn. Now I have a git server that I push to and the svn repository has been lost. Can I remove the svn remote? How?" }, { "role": "assistant", "content": "You can edit the .git/config file and remove the section associated with the remote you want to remove.\nThe lines you want to remove probably look roughly like this:\n[svn-remote \"svn\"]\n url = url-of-svn-repository/trunk\n fetch = :refs/remotes/git-svn\n\nThis will remove the remote from Git, but you will still have the relationship between the Git commits and the SVN commits stored in .git/svn. You can remove this whole directory if you want to get rid of all your SVN remotes. If you want to get rid of just one SVN remote and keep others, you will need to look at the directory structure and only remove the ones associated with the remote you are removing." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip" }, { "role": "assistant", "content": "NAME git-rebase - Reapply commits on top of another base tip" } ]