messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitlab redirects push/fetch/clone to sign in\n\nI am trying to push a branch into a gitlab remote repository and an example of the behaviour would be:\ngit clone http://(path to branch)\nCloning into 'origin'...\nfatal: unable to update url base from redirection:\n asked for: http://(path to branch)/info/refs?service=git-upload-pack\nredirect: http://(path to root)/users/sign_in\n\nplease note the changes on the urls and also I entered my credentials in .git/config, as presented below\n[user]\n name = myname\n pwd = mypassword\n password = mypassword\n\nIt's probably relevant that when I signed up, the repository asked for a public key that I had to make exclusively for the project."
},
{
"role": "assistant",
"content": "Try cloning the repository with no path to branch first, then checkout to the branch you want.\ngit clone git@(domain and path to the repository)\nSee details here. I'd recommend just setting up SSH access only takes a few minutes and much easier once it's running.\nNext, just cd into the project you made and run\ngit branch -a\nto view all project branches. Finally\ngit checkout [branchname]\nshould switch you to the branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitattributes - Defining attributes per path Unset"
},
{
"role": "assistant",
"content": "A path to which the diff attribute is unset will\ngenerate Binary files differ (or a binary patch, if\nbinary patches are enabled)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I add an existing Solution to GitHub from Visual Studio 2013\nI have looked through many web pages on the new Git integration in VS 2013 and they do not deal with adding an existing solution to Github. In fact I can't find much on using GitHub instead of Visual Studio Online.\nCan anyone tell me how I start from an existing solution and add it to Github using the tools in VS 2013."
},
{
"role": "assistant",
"content": "OK this worked for me.\n\nOpen the solution in Visual Studio 2013\nSelect File | Add to Source Control\nSelect the Microsoft Git Provider\n\nThat creates a local GIT repository\n\nSurf to GitHub\nCreate a new repository DO NOT SELECT Initialize this repository with a README \n\nThat creates an empty repository with no Master branch\n\nOnce created open the repository and copy the URL (it's on the right of the screen in the current version)\nGo back to Visual Studio\n\n\nMake sure you have the Microsoft Git Provider selected under Tools/Options/Source Control/Plug-in Selection\n\nOpen Team Explorer\nSelect Home | Unsynced Commits\nEnter the GitHub URL into the yellow box (use HTTPS URL, not the default shown SSH one)\nClick Publish\nSelect Home | Changes\nAdd a Commit comment\nSelect Commit and Push from the drop down\n\nYour solution is now in GitHub"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options checkoutAmbiguousRemoteBranchName"
},
{
"role": "assistant",
"content": "Shown when the argument to git-checkout and git-switch ambiguously resolves to a\nremote tracking branch on more than one remote in\nsituations where an unambiguous argument would have\notherwise caused a remote-tracking branch to be\nchecked out. See the checkout.defaultRemote configuration variable for how to set a given remote\nto be used by default in some situations where this\nadvice would be printed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-send-email - Send a collection of patches as emails --no-header-cmd"
},
{
"role": "assistant",
"content": "Disable any header command in use."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the difference between git push.default=current and push.default=upstream?\nThe man page for git-config lists these options for push.default:\nnothing - do not push anything.\nmatching - push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default.\nupstream - push the current branch to its upstream branch.\ntracking - deprecated synonym for upstream.\ncurrent - push the current branch to a branch of the same name.\n\nIn most cases I would assume that pushing to a branch's upstream branch would be the same as pushing to a branch of the same name, since the upstream branch would normally have the same name, and since the branch of the same name (\"current\") would normally (or always, by definition?) be upstream. So what's the difference?\nUPDATE: The documentation for git-config has been updated (as one would expect), so the distinctions made there may be a lot clearer now."
},
{
"role": "assistant",
"content": "You've summarized the difference in your question. upstream pushes to the configured upstream branch, while current assumes the upstream branch has the same name as the current local branch, and pushes to that specific name. In reality, there's no reason to assume a local branch's upstream tracking branch has the same name as the local branch itself. \nFor example, if you work in multiple repositories or across many shared developer remotes, you often end up tracking different forks of the same branch, such as allen-master or susan-master, both of which track the master branch in Allen and Susan's repos, respectively. In this case, current would be the incorrect setting, because those branch names don't exist on their remotes. upstream, however, would work just fine.\nA more practical example might be tracking both a development and production repository. Your workflow might use a different mainline branch for each, but that might get confusing. Suppose you were a code integrator and wanted to track both repositories' master branches separately.\ngit checkout -b production --track production/master\ngit checkout -b development --track development/master\n\nNow you've got two branches that track their respective repositories, neither of which use the master naming convention at all. There's little confusion about the branch names: They explicitly describe what they track. Nevertheless, push.default = current wouldn't make any sense as neither remote contains a development or production branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I make git diff ignore permission changes\nI inadvertedly change the permissions of my entire tree and commit that change along with other content changes.\nI use something like : tar -czf deploy.tar git diff --name-only v1 v2\nto generate a tar with the modified files between two tags, the problem is that now because of the permissions change almost all my tree is listed as modified.\nIs there a way that I could tell git diff to ignore those files which only has the permissions changed?"
},
{
"role": "assistant",
"content": "This will tell git to ignore permissions:\ngit config core.filemode false"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-revert - Revert some existing commits <commit>…"
},
{
"role": "assistant",
"content": "Commits to revert.\nFor a more complete list of ways to spell commit names, see gitrevisions .\nSets of commits can also be given but no traversal is done by\ndefault, see git-rev-list and its --no-walk option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can GitHub automatically merge branches?\nWe want to automatically merge out from master to another long-lived branch whenever any changes are committed to master (at the moment, this is a manual process and people forget)\nI appreciate that it may not always be possible, owing to merge conflicts, but if it is possible, we'd like it to happen automatically.\nIs this possible?"
},
{
"role": "assistant",
"content": "You can use GitHub Actions since Aug 13, 2019\nThis method will merge your branch with the master without the requirement to create pull requests manually.\nJust create .github/workflows/automerge.yml file in your repo with this content:\nname: Automerge\n\non:\n workflow_dispatch:\n schedule:\n # You can setup schedule here\n - cron: '0 0 * * *'\n\nenv:\n # replace \"github_username\" with your GitHub username\n # replace \"github.com/username/repo.git\" with your GitHub repo path\n # do NOT replace ${{secrets.GITHUB_TOKEN}}, GitHub will take care of it\n MY_REPO: https://github_username:${{secrets.GITHUB_TOKEN}}@github.com/username/repo.git\n\n # replace \"long-lived_branch_name\" with your branch name\n MY_BRANCH: long-lived_branch_name\n\n # replace it with the path to master repo\n MASTER_REPO: https://github.com/username/master_repo.git\n\n # replace \"master\" with your master branch name\n MASTER_BRANCH: master\n\njobs:\n merge:\n runs-on: ubuntu-latest\n\n steps:\n - name: Merge with master\n run: |\n git clone ${{env.MY_REPO}} -b ${{env.MY_BRANCH}} tmp\n cd tmp\n git config user.name \"Automerge Bot\"\n git config user.email \"[email protected]\"\n git config pull.rebase false\n git pull ${{env.MASTER_REPO}} ${{env.MASTER_BRANCH}}\n git push\n\n\n\nreplace \"github_username\" with your GitHub username\nreplace \"github.com/username/repo.git\" with your GitHub repo path\nreplace \"long-lived_branch_name\" with your branch name\nreplace \"master\" with your master branch name\nedit \"cron\" line to adjust the schedule\n\nAlso, don't forget to enable this workflow on the \"Actions\" page of your repo. You can run it manually too. You'll receive an e-mail from GitHub if merge was failed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": ".gitignore file in Sourcetree not working\nI am working on a maven project and I want to ignore the files generated and stored in the /target folder of my project (Evaluation) root folder.In the root of my git repository I have a .gitignore file with the following entries (backend is just a folder which contains the eclipse project Evaluation)\nbackend/Evaluation/logs/\nbackend/Evaluation/target/\n\nFor some reason SourceTree does not ignore the files stored in these two folders and when I compile my project there are some uncommitted changes which are some .class files inside the /target folder.\nWhy is this happening ? I also tried to change the .gitignore entries to \n\n/backend/Evaluation/logs/**\n\nbut it did not work too. \nAny ideas ?"
},
{
"role": "assistant",
"content": "Because there is the Sourcetree tag in the question I will answer you how to do this with Sourcetree, it's really simple.\nAs said before you first have to remove the file from tracking and then make Sourcetree to ignore the file.\n\nChange something in the file so that it is shown to you or select it from the \"file status\" tab at the bottom of the open repository.\nRight click on the file and you see \"Ignore...\", but it is grayed out because as said above its already in track.\nRight click on the file and chose \"Stop Tracking\"\nThe file will be shown with a red button which indicates it will be removed (from tracking)\nA new entry of the same file will be shown in \"file status\" with a blue question mark indicates a new file (new because you said remove from tracking in 4)\nRight click on the file from 5 and now you see the \"Ignore...\" is able to choose. Click on it and Sourcetree will put a new entry for the file in the .gitignore file\nYou can see the .gitignore file if you click on \"Setting\" on the top right, choose \"advanced\" and then the first entry is about the ignore file, click on \"edit\" and it will be open."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "how do I add /usr/local/git/bin/ to the PATH on mac osx? [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 13 years ago.\n\n\n\n\nPossible Duplicate:\ngit: command not found \n\nhow do I add /usr/local/git/bin/ to the PATH on mac osx? I just installed git but it is not recognizing commands. It only responds with \"command git not found\", and I believe this may be the solution but I do not know how to add it to the path to be used in terminal."
},
{
"role": "assistant",
"content": "You can add the following to ~/.bash_profile:\nexport PATH=/usr/local/git/bin:$PATH\n\nThe change will get applied with the next terminal window you open."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "\"Git Log\" command in Powershell - unable to terminate process\nWhen I type git log in PowerShell it prints what looks like a normal response. \nBut at the bottom it doesn't show the normal working directory that prompts me for a new command, it just shows : (a colon) and no command works; not quit, not ctrl z, not ctrl c, it just prints another colon."
},
{
"role": "assistant",
"content": "It puts you in a pager (most probably less if you installed MSysGit or Github for Windows), because the output you requested is longer than one screen page.\nYou can scroll up/down/left/right with your arrow keys, the Page Up/Page Down keys and the J/K/H/L keys.\nTo show inline help, press ? and to quit, press Q.\nYou can use a different pager or turn it off if you want to. As man git config points out, you can use the core.pager setting to set it to a different pager, or set its value to cat to disable pagination for all Git commands."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree -m --modified"
},
{
"role": "assistant",
"content": "Show files with an unstaged modification (note that an unstaged\ndeletion also counts as an unstaged modification)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can you disable Git integration in Visual Studio 2013 permanently?\nI know that you can disable git integration by using the Tools / Options dialog, but what I've noticed is that this setting doesn't seem to persist across sessions; i.e., as soon as close and reopen the solution, Git integration is enabled again. I'm guessing Visual Studio is seeing the .git folder in my solution file system tree.\nThere are a variety of Visual Studio 2013 plugins that behave incorrectly when the Git plug-in is enabled, I prefer to manage my source control at the command line, and I work on a few very large projects for which the Git integration introduces noticeable slowdowns in opening and working with the solution. I'd like to turn it off for good, as I simply don't use it or need it. Is this possible?"
},
{
"role": "assistant",
"content": "As you said you can disable the source control plugin going to: \n\nTools / Options \nCheck \"Show all settings\"\nSource Control / Plug-in Selection \nSet \"Current source control plug-in\" to \"None\"\n\nThen, as Ade Miller says: Restart Visual Studio.\nMy Visual Studio was working really slow since the git plugging was enabled and I managed to disable it \"persistently across sessions\" following this steps.\nHope it helps."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to skip the commit message step in \"git commit --amend\"? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to amend a commit without changing commit message (reusing the previous one)?\n\n (8 answers)\n \n\nClosed 4 years ago.\n\n\n\nI'm running a very rapid code-compile-test loop where I am amending changes to my commits far more often than not.\nFor example:\n# Make some changes\n$ git commit -m \"Added feature X\"\n# Compile, test\n# Fix bugs\n$ git commit -a --amend\n\nI usually want the same commit message after I fix my bugs. Is there a way to make git skip firing up my EDITOR and just use the original commit message?"
},
{
"role": "assistant",
"content": "You can just add --no-edit to use the last message. This option existed since 2005 but only recently has been enabled for the --amend option.\nThe other way is to add -C HEAD to the commit command with amend option. This allows you to not just use the current commit's message but you can specify any other reference you like, so it's worth remembering it.\nThis is particularly useful when constructing a commit from various places in history and using one of those commit's messages. For example:\ngit checkout feature1^^ -- database/table1.sql\ngit checkout feature1^^^^ -- logger.py\ngit add -A && git commit -C feature1\n\nwhich would just use 2 commits from a feature1 and use the commit message from the last commit to feature1 - if that was a good description."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc"
},
{
"role": "assistant",
"content": "Combined diff format Any diff-generating command can take the -c or --cc option to\nproduce a combined diff when showing a merge. This is the default\nformat when showing merges with git-diff or git-show . Note also that you can give suitable --diff-merges option to any of these commands to force generation of\ndiffs in a specific format. A \"combined diff\" format looks like this: diff --combined describe.c\nindex fabadb8,cc95eb0..4866510\n--- a/describe.c\n+++ b/describe.c\n@@@ -98,20 -98,12 +98,20 @@@\n\treturn (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;\n }\n\n- static void describe(char *arg)\n -static void describe(struct commit *cmit, int last_one)\n++static void describe(char *arg, int last_one)\n {\n +\tunsigned char sha1[20];\n +\tstruct commit *cmit;\n\tstruct commit_list *list;\n\tstatic int initialized = 0;\n\tstruct commit_name *n;\n\n +\tif (get_sha1(arg, sha1) < 0)\n +\t\tusage(describe_usage);\n +\tcmit = lookup_commit_reference(sha1);\n +\tif (!cmit)\n +\t\tusage(describe_usage);\n +\n\tif (!initialized) {\n\t\tinitialized = 1;\n\t\tfor_each_ref(get_name); It is preceded by a \"git diff\" header, that looks like\nthis (when the -c option is used): diff --combined file or like this (when the --cc option is used): diff --cc file It is followed by one or more extended header lines\n(this example shows a merge with two parents): index <hash>,<hash>..<hash>\nmode <mode>,<mode>..<mode>\nnew file mode <mode>\ndeleted file mode <mode>,<mode> The mode <mode>,<mode>..<mode> line appears only if at least one of\nthe <mode> is different from the rest. Extended headers with\ninformation about detected content movement (renames and\ncopying detection) are designed to work with the diff of two\n<tree-ish> and are not used by combined diff format. It is followed by a two-line from-file/to-file header: --- a/file\n+++ b/file Similar to the two-line header for the traditional unified diff\nformat, /dev/null is used to signal created or deleted\nfiles. However, if the --combined-all-paths option is provided, instead of a\ntwo-line from-file/to-file, you get an N+1 line from-file/to-file header,\nwhere N is the number of parents in the merge commit: --- a/file\n--- a/file\n--- a/file\n+++ b/file This extended format can be useful if rename or copy detection is\nactive, to allow you to see the original name of the file in different\nparents. Chunk header format is modified to prevent people from\naccidentally feeding it to patch -p1 . Combined diff format\nwas created for review of merge commit changes, and was not\nmeant to be applied. The change is similar to the change in the\nextended index header: @@@ <from-file-range> <from-file-range> <to-file-range> @@@ There are (number of parents + 1) @ characters in the chunk\nheader for combined diff format. Unlike the traditional unified diff format, which shows two\nfiles A and B with a single column that has - (minus — appears in A but removed in B), + (plus — missing in A but\nadded to B), or \" \" (space — unchanged) prefix, this format\ncompares two or more files file1, file2,… with one file X, and\nshows how X differs from each of fileN. One column for each of\nfileN is prepended to the output line to note how X’s line is\ndifferent from it. A - character in the column N means that the line appears in\nfileN but it does not appear in the result. A + character\nin the column N means that the line appears in the result,\nand fileN does not have that line (in other words, the line was\nadded, from the point of view of that parent). In the above example output, the function signature was changed\nfrom both files (hence two - removals from both file1 and\nfile2, plus ++ to mean one line that was added does not appear\nin either file1 or file2). Also, eight other lines are the same\nfrom file1 but do not appear in file2 (hence prefixed with + ). When shown by git diff-tree -c , it compares the parents of a\nmerge commit with the merge result (i.e. file1..fileN are the\nparents). When shown by git diff-files -c , it compares the\ntwo unresolved merge parents with the working tree file\n(i.e. file1 is stage 2 aka \"our version\", file2 is stage 3 aka\n\"their version\")."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Setting up a git remote origin\nI have the following repos.\n\nDEV REPO: in a directory on my development machine where i make changes\nMAIN REPO: bare repository on my development machine to which i push changes from dev repo\nPRODUCTION REPO: repository on host machine to pull updates from the main repo\n\nI used git remote add origin /Users/me/sites/main_repo to set the MAIN repo as origin for the DEV repo. The PRODUCTION repo is on a remote host. Can i use a variation of the same command to set the MAIN repo as origin for the PRODUCTION repo also? If \"yes\", then i suppose the syntax would include an ip address. What would that look like?"
},
{
"role": "assistant",
"content": "Using SSH\ngit remote add origin ssh://login@IP/path/to/repository\n\nUsing HTTP\ngit remote add origin http://IP/path/to/repository\n\nHowever having a simple git pull as a deployment process is usually a bad idea and should be avoided in favor of a real deployment script."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree C"
},
{
"role": "assistant",
"content": "tracked file with unstaged modification/change"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout-index - Copy files from the index to the working tree --ignore-skip-worktree-bits"
},
{
"role": "assistant",
"content": "Check out all files, including those with the skip-worktree bit\nset."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-am - Apply a series of patches from a mailbox"
},
{
"role": "assistant",
"content": "SYNOPSIS git am [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--no-verify]\n\t [--[no-]3way] [--interactive] [--committer-date-is-author-date]\n\t [--ignore-date] [--ignore-space-change | --ignore-whitespace]\n\t [--whitespace=<action>] [-C<n>] [-p<n>] [--directory=<dir>]\n\t [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]\n\t [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]\n\t [--quoted-cr=<action>]\n\t [--empty=(stop|drop|keep)]\n\t [(<mbox> | <Maildir>)…] git am (--continue | --skip | --abort | --quit | --show-current-patch[=(diff|raw)] | --allow-empty)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree --exclude-standard"
},
{
"role": "assistant",
"content": "Add the standard Git exclusions: .git/info/exclude, .gitignore\nin each directory, and the user’s global exclusion file."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Tagging docker image with tag from git repository\n\nI am using Gitlab for repository and ci/cd.\nCurrently trying to set up pipeline that creates a docker image from a build stage.\nAll examples I have seen have a simple naming of image where e.g. the branch is used(master)\nMy question is if I want to tag the image based on the current tag in the repository how do I do this?\nI am presuming I can use a Gitlab runner variable but do not see one to us"
},
{
"role": "assistant",
"content": "There are a lot of predefined variables in Gitlab CI. I think you are looking for CI_COMMIT_TAG.\nSo you could use it this way:\ndocker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG\n\nSo the image would look like registry.example.com/group/project:tag"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I 'git diff' on a certain directory?\ngit diff actually runs a diff on all source code. How do I do this on a certain directory, so that I can view modifications on files underneath it?"
},
{
"role": "assistant",
"content": "Provide a path (myfolder in this case) and just run:\ngit diff myfolder/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - pulling from specific branch\nI have cloned a git repository to my dev server and then switched to the dev branch but now I can't do a git pull to update the branch.\nHow do I update the code on the server ?"
},
{
"role": "assistant",
"content": "See the git-pull man page:\n\ngit pull [options] [<repository> [<refspec>...]]\n\nand in the examples section:\n\nMerge into the current branch the remote branch next:\n$ git pull origin next\n\nSo I imagine you want to do something like:\ngit pull origin dev\n\nTo set it up so that it does this by default while you're on the dev branch:\ngit branch --set-upstream-to=origin/dev dev"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Undo git mv (rename)\nWhat is the right way to undo a rename in git, like:\ngit mv file1 file2"
},
{
"role": "assistant",
"content": "Non-cheeky answer:\ngit mv file2 file1\n\n\nUpdates the index for both old and new paths automatically.\n\nCheck documentation of git mv"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout-index - Copy files from the index to the working tree -f --force"
},
{
"role": "assistant",
"content": "forces overwrite of existing files"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip"
},
{
"role": "assistant",
"content": "SYNOPSIS git rebase [-i | --interactive] [<options>] [--exec <cmd>]\n\t[--onto <newbase> | --keep-base] [<upstream> [<branch>]] git rebase [-i | --interactive] [<options>] [--exec <cmd>] [--onto <newbase>]\n\t--root [<branch>] git rebase (--continue|--skip|--abort|--quit|--edit-todo|--show-current-patch)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Automatic versioning of Android build using git describe with Gradle\nI have searched extensively, but likely due to the newness of Android Studio and Gradle. I haven't found any description of how to do this. I want to do basically exactly what is described in this post, but with Android Studio, Gradle and Windows rather than Eclipse and Linux."
},
{
"role": "assistant",
"content": "Put the following in your build.gradle file for the project. There's no need to modify the manifest directly: Google provided the necessary hooks into their configuration.\ndef getVersionCode = { ->\n try {\n def code = new ByteArrayOutputStream()\n exec {\n commandLine 'git', 'tag', '--list'\n standardOutput = code\n }\n return code.toString().split(\"\\n\").size()\n }\n catch (ignored) {\n return -1;\n }\n}\n\ndef getVersionName = { ->\n try {\n def stdout = new ByteArrayOutputStream()\n exec {\n commandLine 'git', 'describe', '--tags', '--dirty'\n standardOutput = stdout\n }\n return stdout.toString().trim()\n }\n catch (ignored) {\n return null;\n }\n}\nandroid {\n defaultConfig {\n versionCode getVersionCode()\n versionName getVersionName()\n }\n}\n\nNote that if git is not installed on the machine, or there is some other error getting the version name/code, it will default to what is in your android manifest."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree --"
},
{
"role": "assistant",
"content": "Do not interpret any more arguments as options."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I push to more than one repository in a single command in git?\nBasically I wanted to do something like git push mybranch to repo1, repo2, repo3\nright now I'm just typing push many times, and if I'm in a hurry to the the pushing done, I just send them all to the background git push repo1 & git push repo2 &\nI'm just wondering if git natively supports what I want to do, or if maybe there's a clever script out there, or maybe a way to edit the local repo config file to say a branch should be pushed to multiple remotes."
},
{
"role": "assistant",
"content": "You can have several URLs per remote in git, even though the git remote command did not appear to expose this last I checked. In .git/config, put something like this:\n[remote \"public\"]\n url = [email protected]:kch/inheritable_templates.git\n url = kch@homeserver:projects/inheritable_templates.git\n\nNow you can say “git push public” to push to both repos at once."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why can I not open my folder in GitHub?\nThe \"src\" folder in one of my repository is grayed out (and is not clickable):\n\nI took the following steps before pushing to the GitHub:\n\nI created a new repository on GitHub. \nI initialize dthe git on my project.\ngit add .\ngit commit -m \"comment\"\ngit remote add origin url\ngit push -u origin master\nusername\npassword\n\nThe \"src\" folder is showing up on GitHub but cannot be opened. What can I do?"
},
{
"role": "assistant",
"content": "I solved the problem by deleting .git folder inside subfolders (Hidden files and folders). You should have only one .git in the root folder.\nGit recognized that folder as modified but untracked content. There are other solutions for this problem, look this thread: Git - how to track untracked content?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Setting different config for different repositories [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nCan I specify multiple users for myself in .gitconfig?\n\n (25 answers)\n \n\nClosed 10 years ago.\n\n\n\nI was wondering how am I going to change the contents of the command git config --list? I am going to pull/fork a repository from GitHub. I am going to configure such repositories on both of my Windows, Linux and Mac workstations."
},
{
"role": "assistant",
"content": "If you want to set up configurations that are specific for a particular repository, you have two options, to configure it from the command line, or edit the repo's config file in an editor.\nOption 1: Configure via command line\nSimply use the command line, cd into the root of your Git repo, and run git config, without the --system and the --global flags, which are for configuring your machine and user Git settings, respectively:\ncd <your-repo>\ngit config <setting-name> <setting-value>\ngit config <setting-name>=<setting-value> # alternate syntax\n\nOption 2: Edit config file directly\nYour other option is to edit the repo config file directly. With a default Git clone, it's usually the .git/config file in your repo's root folder. Just open that file in an editor and starting adding your settings, or invoke an editor for it at the command line using git config --edit.\nResources\nYou can learn more about configuring Git at the official Linux Kernel Git documentation for git config. In particular, you may be interested in seeing an example Git config:\n# Core variables\n[core]\n ; Don't trust file modes\n filemode = false\n# Our diff algorithm\n[diff]\n external = /usr/local/bin/diff-wrapper\n renames = true\n[branch \"devel\"]\n remote = origin\n merge = refs/heads/devel\n# Proxy settings\n[core]\n gitProxy=\"ssh\" for \"kernel.org\"\n gitProxy=default-proxy ; for the rest\n[include]\n path = /path/to/foo.inc ; include by absolute path\n path = foo ; expand \"foo\" relative to the current file\n path = ~/foo ; expand \"foo\" in your $HOME directory\n\nEdit\nAddressing the original poster's question about how to change user.name and user.email per repository, here is how to do it via the command line. Switch to each repository, and run the following:\ngit config user.name \"<name>\"\ngit config user.email \"<email>\"\n\nSince you're not using the --system or the --global flags, the above commands will apply to whichever repo you have in your terminal working directory only."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to reuse job in .gitlab-ci.yml\n\nI currently have two jobs in my CI file which are nearly identical. \nThe first is for manually compiling a release build from any git branch. \ndeploy_internal:\n stage: deploy\n script: ....<deploy code>\n when: manual\n\nThe second is to be used by the scheduler to release a daily build from develop branch. \nscheduled_deploy_internal:\n stage: deploy\n script: ....<deploy code from deploy_internal copy/pasted>\n only: \n variables:\n - $MY_DEPLOY_INTERNAL != null\n\nThis feels wrong to have all that deploy code repeated in two places. It gets worse. There are also deploy_external, deploy_release, and scheduled variants.\nMy question:\nIs there a way that I can combine deploy_internal and scheduled_deploy_internal such that the manual/scheduled behaviour is retained (DRY basically)? \nAlternatively: Is there is a better way that I should structure my jobs?\nEdit:\nOriginal title: Deploy job. Execute manually except when scheduled"
},
{
"role": "assistant",
"content": "You can use YAML anchors and aliases to reuse the script. \ndeploy_internal:\n stage: deploy\n script:\n - &deployment_scripts |\n echo \"Deployment Started\"\n bash command 1\n bash command 2\n when: manual\n\nscheduled_deploy_internal:\n stage: deploy\n script:\n - *deployment_scripts\n only:\n variables:\n - $MY_DEPLOY_INTERNAL != null\n\nOr you can use extends keyword.\n.deployment_script:\n script:\n - echo \"Deployment started\"\n - bash command 1\n - bash command 2\n\ndeploy_internal:\n extends: .deployment_script\n stage: deploy\n when: manual\n\nscheduled_deploy_internal:\n extends: .deployment_script\n stage: deploy\n only:\n variables:\n - $MY_DEPLOY_INTERNAL != null"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch --atomic"
},
{
"role": "assistant",
"content": "Use an atomic transaction to update local refs. Either all refs are\nupdated, or on error, no refs are updated."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options rebase.instructionFormat"
},
{
"role": "assistant",
"content": "A format string, as specified in git-log , to be used for the\ntodo list during an interactive rebase. The format will\nautomatically have the commit hash prepended to the format."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Add another user to project owners in Github\nHow can I add another user to project such that the project shows under his name in his Github account too? I don't want a fork. Two users should host same project in their accounts and this should allow both users to collaborate in the project."
},
{
"role": "assistant",
"content": "You can only add collaborators to your repository. It cannot be \"co-owned\".\nBut when someone is added as collaborator to a repo, that repo will be listed in the Your Repositories section ( but the username will be the owner username only)\nThe only way for doing what you want is to fork the repo and collaborate through pull requests.\nNote that you can create an organization ( https://github.com/account/organizations/new ) and achieve a bit of what you want."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Difference between HEAD and master (or main)\nWhat is the difference between the HEAD and master in Git?\nI did a clone of a project on GitHub and want to push my changes to the remote. But to which one should I push?"
},
{
"role": "assistant",
"content": "master is a reference to the end of a branch. By convention this is usually the main integration branch, but it doesn't have to be. (As of git v2.28.0, released in July 2020, the default name changed from master to main)\nHEAD is actually a special type of reference that points to another reference. It may point to master/main or it may not (it will point to whichever branch is currently checked out). If you know you want to be committing to the master/main branch then push to this.\nHere is a visual example:\n\nOn your own repository you can check where the HEAD is pointing to by running this:\n$ git symbolic-ref HEAD\nrefs/heads/master\n\nHowever, finding out where the remotes/origin/HEAD is pointing to is more tricky because it is on the remote machine.\nThere is a great little tutorial on git references here"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc color"
},
{
"role": "assistant",
"content": "Highlight changed words using only colors. Implies --color ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "how to find crlf line separators with git?\nas I want to commit to git using intellij, I get a message \nYou are about to commit CRLF line separators to the Git repository\nand I am given 2 options: \n\nfix and commit (runs git config --global core.autocrlf) \ncommit as is\n\nI would like to see where those line separators are before I do anything else. \nHow can I do that with git or intellij? (solutions using only git are preferred)."
},
{
"role": "assistant",
"content": "You could use git grep via the command line to search for files containing the windows style newline characters.\nUsing the git bash you can find all files which contain a \\r character via the following command (bash only!):\ngit grep -Il $'\\r'\n\nOr alternativly (which should work for all shell types - except windows ones):\ngit grep -Il '<CTRL + M>'\n\nThis will actually display as a newline in your shell, but as long as you wrap it into quotes it will work.\nAnd finally for the windows CLI (tested with CMD and PowerShell):\ngit grep -Il \"\\r\"\n\n\nUsed options\n\n-I excludes binary files from the match\n-l shows only the file names with matches, rather than all matches\n\nAlso, if you want to restrict your search on a number of files you can use the --cached option, which will only search in files you have on your index.\nYou can read the documentation for more information."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: See changes to a specific file by a commit\nI want to see the what changes were made to this file's at line 147. So i enquired the file line by line for commits by:\ngit blame include/svl/itemset.hxx\n\nHere is the trimmed output of git blame:\n4b3a535ae3 include/svl/itemset.hxx (Michael Stahl 2015-04-08 15:02:47 +0200 145) SfxItemPool* GetPool() const { return m_pPool; }\n4b3a535ae3 include/svl/itemset.hxx (Michael Stahl 2015-04-08 15:02:47 +0200 146) const sal_uInt16* GetRanges() const { return m_pWhichRanges;\n }\nd210c6ccc3 svl/inc/svl/itemset.hxx (Xiaofei Zhang 2010-07-29 10:56:19 +0800 147) void SetRanges( const sal_uInt16 *pRanges );\nd210c6ccc3 svl/inc/svl/itemset.hxx (Xiaofei Zhang 2010-07-29 10:56:19 +0800 148) void MergeRange( sal_uInt16 nFrom, sal_uInt16 nTo );\n4b3a535ae3 include/svl/itemset.hxx (Michael Stahl 2015-04-08 15:02:47 +0200 149) const SfxItemSet* GetParent() const { return m_pParent; }\n\nNow i want to to see what changes did that commit with SHA d210c6ccc3 to those lines. Basically i want to see the changes made by this commit to the file. So i did :\ngit show d210c6ccc3 include/svl/itemset.hxx\n\nBut this does not seem to give me right output, in fact it outputs nothing. Could anyone please suggest what could i be missing? Or maybe there is some other better way to know what changes were made to a file by a selected commit?"
},
{
"role": "assistant",
"content": "eftshift0's answer is correct (and I've upvoted it). Here's why, though—along with the one other thing that can go wrong here.\nIn most cases, git show commit -- path would be correct and would show you:\n\nthe log message for the specified commit, and\na patch for that particular file, as produced by comparing that commit with its parent.\n\nThe patch would be the same as that produced by git diff commit^1 commit -- path. (Note that the ^1 suffix here is literal text while the commit part is a hash ID that you replace. The suffix syntax means \"find the first parent\". You can add this suffix to most commit selectors, although not to selectors that use certain search patterns. See the gitrevisions documentation.)\nThere are two important exceptions. Only one of these applies here, because git blame normally does not blame a merge, it tries to trace the source of the change that fed into the merge. Still, I want to mention it, because git show's behavior on merges is ... interesting. :-)\nIf you look at a merge commit with git show, you will see, by default, a combined diff (\"all parents\" vs the merge commit's content). In this case you may wish to fall back directly on git diff, so that you can specify the parent you want to compare (^1, ^2, and even more if this is an octopus merge). The reason is that combined diffs deliberately omit any file that matches the version in one of the parent commits: this means that whatever is in the repository from that point forward, it came from one of the two (or N if N > 2) \"sides\" of the merge.\nWith git blame, you are looking for \"who changed what\". The person who did the merge is often not the person who made the change—so you should keep going \"behind the merge\" to find who really changed it.\nThe second exception is the one that caused a problem for you here, and it's really more a case of the way git blame works when files get renamed during development.\nWhen git blame is analyzing changes to a file, such as include/svl/itemset.hxx, it steps back one commit at at time, starting from whichever commit you specify. If you don't select your own starting point, it starts from from HEAD, i.e., the current commit. It then looks at the parent commit(s) (as if via git show for instance). For instance, if the current commit 922e935c8812 is an ordinary commit and its parent is 22c6554c98e2, it compares commit 922e935c8812 to 22c6554c98e2. If 22c6554c98e2 has a file of the same name, that's probably the same file ... but if not, Git tries to figure out which file in 22c6554c98e2 is the same file as include/svl/itemset.hxx.\nIn this case, that exact thing happens at commit b9337e22ce1d. There is a file named include/svl/itemset.hxx in commit b9337e22ce1d, but in commit b9337e22ce1d^ or f4e1642a1761, the file is named svl/inc/svl/itemset.hxx. Git detects this rename when stepping back from commit b9337e22ce1d to commit f4e1642a1761, and git blame then carries the new name back with it from commit f4e1642a1761 to commit d210c6ccc3.\nWhen you run git show d210c6ccc3, however, Git jumps directly to d210c6ccc3 (and its parent 7f0993d43019). It no longer knows that the file named include/svl/itemset.hxx in HEAD is named svl/inc/svl/itemset.hxx in d210c6ccc3. So you must discover this, and pass the earlier name to Git.\nYou might wonder how you can find this. The answer is to use git log --follow. The --follow code for git log is not great,1 but it's the same code that git blame uses, so it produces the same answers, at least. Here is what I did:\n$ git log --oneline --follow --name-status include/svl/itemset.hxx\n00aa9f622c29 Revert \"used std::map in SfxItemSet\"\nM include/svl/itemset.hxx\nafaa10da2572 make SfxItemSet with SAL_WARN_UNUSED\nM include/svl/itemset.hxx\n[snip]\na7724966ab4f Bin comments that claim to say why some header is included\nM include/svl/itemset.hxx\nb9337e22ce1d execute move of global headers\nR100 svl/inc/svl/itemset.hxx include/svl/itemset.hxx\n\nThere's a second rename even earlier. Here's another, shorter way to find only the renames:\n$ git log --oneline --follow --diff-filter=R --name-status include/svl/itemset.hxx\nb9337e22ce1d execute move of global headers\nR100 svl/inc/svl/itemset.hxx include/svl/itemset.hxx\ne6b4345c7f40 #i103496#: split svtools in two libs, depending on whether the code needs vcl or not\nR100 svtools/inc/svtools/itemset.hxx svl/inc/svl/itemset.hxx\n\nIf d210c6ccc3 came \"before\" e6b4345c7f40, you would have to use the even-earlier path name—but commit d210c6ccc3 is a descendant of (comes after) e6b4345c7f40, not an ancestor.\n\n1When changes occur at merges, this really, in a fundamental sense, requires following both (or all) input commits simultaneously. However, Git is not (currently?) capable of doing this: both git log --follow and git blame really only traverse whichever parent the final version of the file \"came from\". That is, if we look at a typical merge commit M containing merged file F, there are two inputs M^1:F and M^2:F, and one output, M:F. If M:F is the same as M^1:F, we should ignore M^2:F entirely: all the contents of M:F are those from whoever provided M^1:F. If M:F is the same as M^2:F, we should ignore M^1:F entirely: all the contents of M:F are those from whoever provided M^2:F.\nNote that this only works for one file at a time, and even then, it only works if the file exactly matches one of the two inputs. Otherwise, we should look at the combined diff to see how the file got modified from both inputs. This is the logic behind both combined diffs and History Simplification. But it's over-simplified in some rare cases, and hence sometimes gets things wrong."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I move a commit between branches in Git?\nI'm sure this is a simple thing that has been asked and answered, but I don't know what terms to search for. I have this:\n /--master--X--Y\nA--B\n \\--C--D--E\n\nWhere I commited C, D, and E (locally only) on a branch, but then I realized that D and E are really independent of C. I want to move C to its own branch, and keep D and E for later. That is, I want this:\n /--C\n /--master--X--Y\nA--B\n \\--D--E\n\nHow do I yank C out from under D and E?"
},
{
"role": "assistant",
"content": "You can use git cherry-pick to grab C, and put it on Y. Assuming Y exists as the tip of a branch called branch-Y, you can run the following commands:\ngit checkout branch-Y\ngit cherry-pick C\n\nSo now C is on top of Y. But D and E also still contain C (cherry-picking doesn't move a commit, it just makes a copy of it). You'll have to rebase D and E on top of B. Assuming E is the tip of branch-E and B is branch-B, you can run the following commands:\ngit checkout branch-E\ngit rebase --interactive branch-B\n\nThis will open up an interactive rebase session. Just remove commit C entirely, and leave D and E intact. You'll then have D and E rebased on top of B without C."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.dstPrefix"
},
{
"role": "assistant",
"content": "If set, git diff uses this destination prefix. Defaults to \"b/\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to rollback the two previous commits?\nConsider this scenario:\n\nDeveloper A does a commit: #n\nDev. B does commit #n+1\nDev. A does commit #n+2\nand commit #n+3\n\nand then discovers that in his commit #n+2 he introduced a defect.\nHow can dev. A rollback his last 2 commits and continue developing on commit #n+1?\nTried git reset --hard HEAD~2*, but it's coming back to dev A's commit #n."
},
{
"role": "assistant",
"content": "It should come back to the n+1 commit. You probably have a merge commit in there as well. You can also do a git reset --hard <sha1_of_where_you_want_to_be>\n\nWARNING!! --hard means that any uncommitted changes you currently have\n will be thrown away permanently."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-add - Add file contents to the index removed content"
},
{
"role": "assistant",
"content": "Removed content is represented by lines beginning with \"-\". You can\nprevent staging their removal by converting the \"-\" to a \" \" (space)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to improve git's diff highlighting?\nThe output of git diff is optimized for code which tends to be one statement per line whereas text can (if authors like me are too lazy to use line breaks) cause diff output which is very hard to read and more of a \"Where's Wally?\" search than reading diff output\n\nwhereas highlighting as done on GitLab's or GitHub's web frontend shows the difference immediately\n\nI'm aware that I'm comparing HTML and plain text (apples and oranges), however it should be possible to improve the git diff output by using different colors or adding marker characters around a change (JUnit uses [] around insertions which isn't great to read, but an example for what I mean) and it would be the first time that there's something I expect to be somewhere available in git that actually was not."
},
{
"role": "assistant",
"content": "The word-diff suggested in the other answer isn't exactly what gitlab/github do. To get same effect, you can use diff-highlight script that is distributed with git.\n\nFirst find path to diff-highlight script. It varies between systems, and is not usually in $PATH. You can find it with your package manager, for example:\n\nFedora: rpm -ql git | grep diff-highlight\nDebian/Ubuntu/Mint: dpkg -L git | grep diff-highlight\nArchlinux: pacman -Ql git | grep diff-highlight\n\n\nNow, execute the following two commands, which will add to your ~/.gitconfig the necessary settings:\n$ git config --global core.pager 'perl /usr/share/git/diff-highlight/diff-highlight | less'\n$ git config --global interactive.difffilter 'perl /usr/share/git/diff-highlight/diff-highlight'\n\nI'm using perl here instead of calling the script directly because some distros, it seems, do not set executable bit on the script. IMO this is a package bug which should be reported. Anyway, this answer should work regardless.\n\n\nNow log, diff, show commands should show difference word-by-word. Screenshot:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Using gitattributes for linguist examples\n\nAre there any concrete examples, in order to detect wrong languages in GitHub via Linguist attributes? \nSource: https://github.com/github/linguist\n\nlinguist-documentation\nlinguist-language \nlinguist-vendored"
},
{
"role": "assistant",
"content": "Examples can be found in Linguist's documentation.\nDetecting wrong languages (which's what OP asks) can be achieved by setting linguist-language attributes in the .gitattributes file.\nlinguist-language\nWith the following attribute, Linguist detects all .rb files as being Java files.\n*.rb linguist-language=Java\n\nlinguist-vendored\nWith the following attribute, Linguist detects files in the special-vendored-path directory (notice the mandatory trailing *) as vendored and excludes them from statistics.\nspecial-vendored-path/* linguist-vendored\n\nA double * will also apply the override to all subdirectories:\n special-vendored-path/** linguist-vendored\n\nlinguist-documentation\nWithout the following attribute, Linguist would detect the file docs/formatter.rb as documentation and exclude it from statistics.\ndocs/formatter.rb linguist-documentation=false\n\nlinguist-detectable\nWith the following attribute, Linguist counts SQL files in statistics. Without this attribute, only programming and markup languages are counted in statistics.\n*.sql linguist-detectable=true"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to use private Github repo as npm dependency\nHow do I list a private Github repo as a \"dependency\" in package.json? I tried npm's Github URLs syntaxes like ryanve/example, but doing npm install in the package folder gives \"could not install\" errors for the private dependencies. Is there a special syntax (or some other mechanism) for depending on private repos?"
},
{
"role": "assistant",
"content": "It can be done via https and oauth or ssh.\nhttps and oauth: create an access token that has \"repo\" scope and then use this syntax:\n\"package-name\": \"git+https://<github_token>:[email protected]/<user>/<repo>.git\"\n\nor\nssh: setup ssh and then use this syntax:\n\"package-name\": \"git+ssh://[email protected]:<user>/<repo>.git\"\n\n(note the use of colon instead of slash before user)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I work with a git repository within another repository?\nI have a Git media repository where I'm keeping all of my JavaScript and CSS master files and scripts that I'll use on various projects. \nIf I create a new project that's in its own Git repository, how do I use JavaScript files from my media repository in my new project in a way that makes it so I don't have to update both copies of the script when I make changes?"
},
{
"role": "assistant",
"content": "The key is git submodules. \nStart reading the Submodules chapter of the Git Community Book or of the Users Manual\nSay you have repository PROJECT1, PROJECT2, and MEDIA...\ncd /path/to/PROJECT1\ngit submodule add ssh://path.to.repo/MEDIA\ngit commit -m \"Added Media submodule\"\n\nRepeat on the other repo...\nNow, the cool thing is, that any time you commit changes to MEDIA, you can do this:\ncd /path/to/PROJECT2/MEDIA\ngit pull\ncd ..\ngit add MEDIA\ngit commit -m \"Upgraded media to version XYZ\"\n\nThis just recorded the fact that the MEDIA submodule WITHIN PROJECT2 is now at version XYZ.\nIt gives you 100% control over what version of MEDIA each project uses. git submodules are great, but you need to experiment and learn about them. \n\nWith great power comes the great chance to get bitten in the rump."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to find a deleted file in the project commit history?\n\nOnce upon a time, there was a file in my project that I would now like to be able to get.\nThe problem is: I have no idea of when have I deleted it and on which path it was.\nHow can I locate the commits of this file when it existed?"
},
{
"role": "assistant",
"content": "If you do not know the exact path you may use\ngit log --all --full-history -- \"**/thefile.*\"\n\nIf you know the path the file was at, you can do this:\ngit log --all --full-history -- <path-to-file>\n\nThis should show a list of commits in all branches which touched that file. Then, you can find the version of the file you want, and display it with...\ngit show <SHA> -- <path-to-file>\n\nOr restore it into your working copy with:\ngit checkout <SHA>^ -- <path-to-file>\nNote the caret symbol (^), which gets the checkout prior to the one identified, because at the moment of <SHA> commit the file is deleted, we need to look at the previous commit to get the deleted file's contents"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to delete gitlab CI jobs pipelines logs/builds and history\n\nHow can we configure gitlab to keep only the last 10 CI jobs/builds and keep deleting the rest? \nFor example , in Jenkins , we can configure the job to keep only last X builds."
},
{
"role": "assistant",
"content": "UPDATE\nAs of Gitlab Release 12.6, deleting a pipeline is now an option in the GUI for users in role Owner:\n\nClick the pipeline you want to remove in the pipelines list\nHit the red Delete button in the upper right of the pipeline details page.\n\nAs of Gitlab Release 11.6, deleting a pipeline is now an option, for users in Owner role only, via the API.\nYou need:\n\nAn API token\nThe id of the project\nThe pipeline_id of the pipeline you wish to remove.\n\nExample using curl from the docs for project id: 1 and pipeline_id: 4:\ncurl --header \"PRIVATE-TOKEN: <your_access_token>\" --request \"DELETE\" \"https://gitlab.example.com/api/v4/projects/1/pipelines/46\"\n\nDocumentation is here"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options fetch.prune"
},
{
"role": "assistant",
"content": "If true, fetch will automatically behave as if the --prune option was given on the command line. See also remote.<name>.prune and the PRUNING section of git-fetch ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why does my GitHub page not update its content?\n\nI've been following the official guide @ pages.github.com\nSo far I've created the local repo and pushed it to GitHub, but, whatever change I do, I can see it in my repo at GitHub but not in my GitHub page. How is that possible?"
},
{
"role": "assistant",
"content": "A bit late to the party but I just had this issue and my solution isn't covered by any of the above.\nSpecifically my issue was the following:\n\nI had created a github.pages site with a custom domain.\nI was pushing commits to the correct GitHub branch but not seeing the updates on the github.pages site.\n\nSolution:\nThe issue turned out to be my browser caching the page (despite my having page caching disabled). To fix it I just cleared my cached data from the past hour and that worked instantly.\nTo clear the cache data in Chrome go to the Chrome menu then More Tools > Clear Browsing Data.\nI don't know what caused the caching, this github.pages/custom domain combo is the only thing that has ever caused it for me."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gerrit: combine multiple commits into one \"change\"\nAs a git best practice, one should commit frequently, but to review the code you may need to review a patch consisting of multiple commits at once. Is there a way multiple commits can be reviewed and either merged or rejected at once?"
},
{
"role": "assistant",
"content": "One thing you can do a squash merge to a temporary branch and then post that change for review.\ngit checkout -b feature\ngit commit -m \"start feature\"\n...\ngit commit -m \"finish feature\"\ngit checkout -b feature-review master\ngit merge --squash feature\ngit commit\n\nNow your feature-review branch will contain the same diff relative to master as feature did but with only a single commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker"
},
{
"role": "assistant",
"content": "FURTHER DOCUMENTATION See the references in the \"description\" section to get started\nusing Git. The following is probably more detail than necessary\nfor a first-time user. The Git concepts chapter of the\nuser-manual and gitcore-tutorial both provide\nintroductions to the underlying Git architecture. See gitworkflows for an overview of recommended workflows. See also the howto documents for some useful\nexamples. The internals are documented in the Git API documentation . Users migrating from CVS may also want to\nread gitcvs-migration ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Split large Git repository into many smaller ones\nAfter successfully converting an SVN repository to Git, I now have a very large Git repository that I want to break down into multiple smaller repositories and maintain history.\nSo, can someone help with breaking up a repo that might look like this:\nMyHugeRepo/\n .git/\n DIR_A/\n DIR_B/\n DIR_1/\n DIR_2/\n\nInto two repositories that look like this:\nMyABRepo/\n .git\n DIR_A/\n DIR_B/\n\nMy12Repo/\n .git\n DIR_1/\n DIR_2/\n\nI've tried following directions in this previous question but it doesn't really fit when trying to put multiple directories into a separate repo (Detach (move) subdirectory into separate Git repository)."
},
{
"role": "assistant",
"content": "This will setup MyABRepo; you can do My12Repo similarly of course.\ngit clone MyHugeRepo/ MyABRepo.tmp/\ncd MyABRepo.tmp\ngit filter-branch --prune-empty --index-filter 'git rm --cached --ignore-unmatch DIR_1/* DIR_2/*' HEAD \n\nA reference to .git/refs/original/refs/heads/master remains. You can remove that up with:\ncd ..\ngit clone MyABRepo.tmp MyABRepo\n\nIf all went well you can then remove MyABRepo.tmp.\n\nIf for some reason you get an error regarding .git-rewrite, you can try this:\ngit clone MyHugeRepo/ MyABRepo.tmp/\ncd MyABRepo.tmp\ngit filter-branch -d /tmp/git-rewrite.tmp --prune-empty --index-filter 'git rm --cached --ignore-unmatch DIR_1/* DIR_2/*' HEAD \ncd ..\ngit clone MyABRepo.tmp MyABRepo\n\nThis will create and use /tmp/git-rewrite.tmp as a temporary directory, instead of .git-rewrite.\nNaturally, you can substitute any path you wish instead of /tmp/git-rewrite.tmp, so long as you have write permission, and the directory does not already exist."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --quiet"
},
{
"role": "assistant",
"content": "Don’t print anything to standard output. This form\nis primarily meant to allow the caller to\ntest the exit status to see if a range of objects is fully\nconnected (or not). It is faster than redirecting stdout\nto /dev/null as the output does not have to be formatted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together --continue"
},
{
"role": "assistant",
"content": "After a git merge stops due to conflicts you can conclude the\nmerge by running git merge --continue (see \"HOW TO RESOLVE\nCONFLICTS\" section below)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to delete the last n commits on Github and locally?\n\nI'm trying to delete the last 2 commits from one of my GitHub repositories. I've tried as suggested here : git push -f origin HEAD^^:master. It seems that it works, as the last two commits are removed.\nThen I deleted them from my local repository with git rebase -i HEAD~2. I remove the lines that are related to those commits, and check with git log that they are correctly removed.\nAfter that, I make some changes in my local repository, make a new commit, and push to GitHub. The problem is that, in my GitHub account, I have the previous two commits that I've tried to delete.\nI think the problem is in my local repository, because if I clone my Github repository to my local and make some changes here, when I push a new commit those old commits aren't pushed to GitHub."
},
{
"role": "assistant",
"content": "To remove the last two commits locally I'd suggest using:\ngit reset --hard HEAD^^\n\nRebase is a completely different operation that won't help you here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index -p -u --patch"
},
{
"role": "assistant",
"content": "Generate patch (see Generating patch text with -p )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --find-copies-harder"
},
{
"role": "assistant",
"content": "For performance reasons, by default, -C option finds copies only\nif the original file of the copy was modified in the same\nchangeset. This flag makes the command\ninspect unmodified files as candidates for the source of\ncopy. This is a very expensive operation for large\nprojects, so use it with caution. Giving more than one -C option has the same effect."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Checkout Latest Tag\nI'm writing a shell script and I'm looking to checkout the latest version of repo. Specifically I want to break this process apart into multiple steps.\n\nI want to save the repositories latest tag into a variable \nPrint out Checking out version: XX\nCheckout the latest tag\n\nI've seen similar questions but I don't see how to save the name of the tag into a variable (probably because I'm a noob with shell scripts)."
},
{
"role": "assistant",
"content": "# Get new tags from remote\ngit fetch --tags\n\n# Get latest tag name\nlatestTag=$(git describe --tags \"$(git rev-list --tags --max-count=1)\")\n\n# Checkout latest tag\ngit checkout $latestTag"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Error \"fatal: invalid branch name: init.defaultBranch =\"\nI getting this error when ever I do git clone\nError :-\nfatal: invalid branch name: init.defaultBranch =\nTried to reinstall git (latest)\nStill same error\nOS :- Windows"
},
{
"role": "assistant",
"content": "It would appear that you have experimented with the new (2.28) init.defaultBranch configuration value.\nAssign it a proper value:\ngit config --global init.defaultBranch main"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_TRACE2_EVENT"
},
{
"role": "assistant",
"content": "This setting writes a JSON-based format that is suited for machine\ninterpretation.\nSee GIT_TRACE2 for available trace output options and Trace2 documentation for full details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab API - How to get private_token using GET with session parameter?\n\nI am using GitLab API v3 to do some operations on my private installation. Using private_token in GET URL is working fine. e.g.\nGET http://git.example.com/api/v3/projects?=private_token=xyz123\n\nBut in order to make this possible, you need a private_token. There is one sure way to get it - from your account settings. But I want my users to use their email id/ login id and password to retrieve the private key and use it from there for rest of the operations.\nI used following GET url and it is doing nothing for me:\nGET http://git.example.com/api/v3/session?login=xyzuser&password=xyzpassword\n\nIdeally as per GitLab documentation, I should get a JSON as follows -\n{\n \"id\": 1,\n \"username\": \"john_smith\",\n \"email\": \"[email protected]\",\n \"name\": \"John Smith\",\n \"private_token\": \"dd34asd13as\",\n \"blocked\": false,\n \"created_at\": \"2012-05-23T08:00:58Z\",\n \"bio\": null,\n \"skype\": \"\",\n \"linkedin\": \"\",\n \"twitter\": \"\",\n \"dark_scheme\": false,\n \"theme_id\": 1,\n \"is_admin\": false,\n \"can_create_group\" : true,\n \"can_create_team\" : true,\n \"can_create_project\" : true\n}\n\nIf I get this, I can get private_token and work from there.\nWhat am I doing wrong?"
},
{
"role": "assistant",
"content": "You need to POST the data as stated in the api (http://api.gitlab.org/session.html).\nBe aware that if you do this action on a http port (instead of using https) that the password is send in plain text to the server."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab-Ci: How could I share data between jobs\n\nI want to share a file between two jobs and modify it if there are changed files. The python script compare the cache.json file with changes and modify the cahce file sometimes.\n.gitlab-ci.yaml:\nimage: ubuntu\n\nstages:\n - test\n\ncache:\n key: one-cache\n paths:\n - cache.json\n\n job1:\n stage: test\n\nscript:\n # - touch cache.json\n - cat cache.json\n - python3 modify_json_file.py\n - cat cache.json\n\nThe problem is that it the cache.json file not exist at the next job run. I get the error message: cat: cache.json: No such file or directory. I did also insert once the touch command, but this doesn't change anything for the next run without the touch command.\nDo I something wrong or don't I understand the cache at gitlab wrong."
},
{
"role": "assistant",
"content": "I think you need artifacts and not cache.\nFrom cache vs artifact:\n\ncache - Use for temporary storage for project dependencies. Not useful for keeping intermediate build results, like jar or apk files. Cache was designed to be used to speed up invocations of subsequent runs of a given job, by keeping things like dependencies (e.g., npm packages, Go vendor packages, etc.) so they don't have to be re-fetched from the public internet. While the cache can be abused to pass intermediate build results between stages, there may be cases where artifacts are a better fit.\nartifacts - Use for stage results that will be passed between stages. Artifacts were designed to upload some compiled/generated bits of the build, and they can be fetched by any number of concurrent Runners. They are guaranteed to be available and are there to pass data between jobs. They are also exposed to be downloaded from the UI."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Docker error: Unable to locate package git\nI'm using an image nginx which is based on dockerfile/ubuntu. On attaching to the docker container's shell\ndocker exec -it <container_id> /bin/bash\n\nI want to do a git pull so I tried installing git but apt is unable to find the package:\nroot@a71e45d5cd40:/# apt-get install git\nReading package lists... Done\nBuilding dependency tree \nReading state information... Done\nE: Unable to locate package git\n\nHow can we install git from that image and why is it missing?\n\ncat /etc/apt/sources.list\ndeb http://httpredir.debian.org/debian wheezy main\ndeb http://httpredir.debian.org/debian wheezy-updates main\ndeb http://security.debian.org wheezy/updates main\ndeb http://nginx.org/packages/mainline/debian/ wheezy nginx\n\ncat /etc/apt/sources.list.d/*\ncat: /etc/apt/sources.list.d/*: No such file or directory\n\napt-cache madison git\nN: Unable to locate package git"
},
{
"role": "assistant",
"content": "This is happening because the apt repository is not yet updated, it is common practice to clean your apt repositories and tmp files after creating an image, which your base image is probably doing.\nTo fix this, you are going to want to run apt-get update prior to installing git, it is good practice to combine the update and install command at the same time to bust cache on the update if the install line changes:\nRUN apt-get update && apt-get install -y git\n\nUsing -y is convenient to automatically answer yes to all the questions."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "alembic revision - multiple heads (due branching) error\nI've got an application and I wanted to create a new migration for it today. When I run \n$ alembic revision -m \"__name__\"\n\nI got a message\nOnly a single head is supported. The script directory has multiple heads (due branching), which must be resolved by manually editing the revision files to form a linear sequence. \nRun `alembic branches` to see the divergence(s).\n\nRunning \nalembic branches\n\ngives nothing \nI'm new to alembic. There are 2 developers working on this app and we have 2 git branches - master & develop (I'm not sure if this have anything to do with it).\nAny clue on what is this about?"
},
{
"role": "assistant",
"content": "Perhaps the most conventional (and robust) solution is to use alembic merge heads. In the same way that when you have two branches in Git you can bring them back together with a merge commit, in Alembic when you have two branches you can bring them back together with a merge revision.\nFor instance, suppose we have a revision 1a6b1a4a0574 that adds table A, and a revision 2e49118db057 that adds table B. We can see these revisions (both marked as (head)) in alembic history:\n$ alembic history\n<base> -> 2e49118db057 (head), Add table B\n<base> -> 1a6b1a4a0574 (head), Add table A\n\nThen we can merge them by running alembic merge heads:\n$ alembic merge heads\n Generating /Users/markamery/alembictest/alembic/versions/409782f4c459_.py ... done\n$ alembic history\n2e49118db057, 1a6b1a4a0574 -> 409782f4c459 (head) (mergepoint), empty message\n<base> -> 2e49118db057, Add table B\n<base> -> 1a6b1a4a0574, Add table A\n\nIf one of your revisions may have already been run somewhere (including on the development machine of one of your coworkers), then you probably want to use alembic merge instead of tinkering with the down_revision of one of the revisions, as the other answers here suggest. The danger of tinkering with the down revision is that it may result in a revision never getting applied. For instance, suppose that your colleague Bob has already pulled down your branch with revision 2e49118db057 and run alembic upgrade head, creating table B. Then you decide to modify the down_revision of 2e49118db057 to point to 1a6b1a4a0574, which Bob has never seen or run before. Bob pulls down your change, runs alembic upgrade head, and... nothing happens, because as far as Alembic is concerned he's already at the head and doesn't need to run 1a6b1a4a0574. And so Bob ends up never getting table A and probably never figures out why his database is in a broken state.\nDon't break Bob's database - make a merge revision instead."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to specify project language in GitLab?\n\nOne can manually select project language at Bitbucket or use .gitattributes at GitHub.\nIs there a way to make GitLab assign a specific language to a project?"
},
{
"role": "assistant",
"content": "GitLab will adhere to the overrides specified in your .gitattributes file. Currently, GitLab uses the Linguist Gem. Without these overrides Linguist will deduce the main language used for a project by analysing the code within files in the project.\nYou can find out how the magic happens by referring to the Repository#main_language method within the gitlab-ce project."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options gui.fastCopyBlame"
},
{
"role": "assistant",
"content": "If true, git gui blame uses -C instead of -C -C for original\nlocation detection. It makes blame significantly faster on huge\nrepositories at the expense of less thorough copy detection."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -c"
},
{
"role": "assistant",
"content": "Produce combined diff output for merge commits.\nShortcut for --diff-merges=combined -p ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Find out the admin(s) for a git repo\n\nI am a contributor for a git repo in github for a company.\nI want to find out who among the contributors are the admins.\nHow do I find out who is the admin besides going around and asking everyone in the company?"
},
{
"role": "assistant",
"content": "If you have push access to this repository, you can use Github API to find collaborators\nYou will need an access token, the endpoint https://api.github.com/repos/ORG/REPO/collaborators gives you a list of all collaborators with the list of permission type for each of them :\n\"permissions\": {\n \"admin\": true,\n \"push\": true,\n \"pull\": true\n }\n\nYou can use curl and jq (to parse JSON response) like this : \ncurl https://api.github.com/repos/ORG/REPO/collaborators \\\n -H \"Authorization: Token ACCESS_TOKEN\" | \\\n jq '[ .[] | select(.permissions.admin == true) | .login ]'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git diff HEAD:file1 file2"
},
{
"role": "assistant",
"content": "compares an (o)bject and a (w)ork tree entity;"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Applying a git post-commit hook to all current and future repositories\nI've written a Git post-commit hook and it works correctly. However, I want to add this hook to apply to all current (and future) Git repositories I am working on. I tried adding the hook to my ~/.git/hooks/ directory instead of in the hooks directory in the project directory, however, this did not seem to work.\nIs there a way to create global Git hooks that will apply to all repositories on my system (without having to copy them into each project directory)? If not, what would be the best solution going forward -- perhaps a git-init template?"
},
{
"role": "assistant",
"content": "As of Git 1.7.1, you can set init.templatedir in your gitconfig to tell Git where to look for templates.\nSet it like this:\ngit config --global init.templatedir '~/.git_template'\n\nAfterward, new repositories you create or clone will use this directory for templates. Place the hooks you want in ~/.git_template/hooks. Existing repositories can be reinitialized with the proper templates by running git init in the same directory .git is in.\nFor Git versions older than 1.7.1, running git init --template ~/.git_template will work if you're like me and still want to manage your .git_template directory along with the rest of your dot files. You can also use the $GIT_TEMPLATE_DIR environment to tell git init where your template directory is."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --pickaxe-regex"
},
{
"role": "assistant",
"content": "Treat the <string> given to -S as an extended POSIX regular\nexpression to match."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git pre-commit hook is not running on Windows\nI'm just starting to look into Git hooks, but I can't seem to get them to run.\nI set up a local repository, so there is now a '.git' directory in my project folder. I have added a '.cmd' file into the C:/path/to/my/project/.git/hooks directory named 'pre-commit.cmd'. Here is the contents of this file:\necho \"HOOK RUNNING\"\necho. 2>C:/path/to/my/project/.git/hooks/EmptyFile.txt\n\nThis should echo the text \"HOOK RUNNING\" and create an empty text file in that directory. However, if I commit changes through my IDE (NetBeans) or use Git Bash to commit, neither of them seem to run my pre-commit hook, as no file is created.\nMy understanding is that all you have to do to get a hook to run is add an executable with the name of the hook (as I have done). Am I doing something wrong?\nNote: This is on a Windows 7 PC."
},
{
"role": "assistant",
"content": "Name your hook pre-commit (without any file extension).\nAnd add #!/bin/sh on the first line or #!/bin/bash."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database missingTag"
},
{
"role": "assistant",
"content": "(ERROR) Unexpected end after type line in a tag object."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-rev-parse"
},
{
"role": "assistant",
"content": "Pick out and massage parameters"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Ignore files that have already been committed to a Git repository [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I make Git forget about a file that was tracked, but is now in .gitignore?\n\n (35 answers)\n \n\nClosed 6 years ago.\n\n\n\nI have an already initialized Git repository that I added a .gitignore file to. How can I refresh the file index so the files I want ignored get ignored?"
},
{
"role": "assistant",
"content": "To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use: git rm --cached filename\nTo untrack every file that is now in your .gitignore:\nFirst commit any outstanding code changes, and then, run this command:\ngit rm -r --cached .\n\nThis removes any changed files from the index(staging area), then just run:\ngit add .\n\nCommit it:\ngit commit -m \".gitignore is now working\"\n\n\nTo undo git rm --cached filename, use git add filename.\n\nMake sure to commit all your important changes before running git add .\nOtherwise, you will lose any changes to other files.\n\n\nPlease be careful, when you push this to a repository and pull from somewhere else into a state where those files are still tracked, the files will be DELETED"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I intentionally detach HEAD in git?\nIf I do git checkout HEAD^, I get this:\n$ git checkout HEAD^\nNote: checking out 'HEAD^'.\n\nYou are in 'detached HEAD' state. You can look around, make experimental\nchanges and commit them, and you can discard any commits you make in this\nstate without impacting any branches by performing another checkout.\n\nIf you want to create a new branch to retain commits you create, you may\ndo so (now or later) by using -b with the checkout command again. Example:\n\n git checkout -b new_branch_name\n\nHEAD is now at...\n$\n\nVeteran git users are probably very familiar with this. But if I do git checkout HEAD, nothing happens:\n$ git checkout HEAD\n$\n\nI'd like to create the \"detached HEAD\" state for the commit at the head of my current branch. How do I do that?"
},
{
"role": "assistant",
"content": "Since git 1.7.5 (April 2011), you can use the git checkout --detach command.\n(Since Git 2.23 (Q3 2019), you would use git switch --detach)\nSee commit 326696\ncheckout: introduce --detach synonym for \"git checkout foo^{commit}\"\n\nFor example, one might use this when making a temporary merge to test that two topics work well together.\n\n\nCommit 8ced1aa (git 1.7.11.3, July 2012) disallows --detach on unborn branch, so this won't fail on a null HEAD:\ngit checkout --orphan foo\ngit checkout --detach\ngit symbolic-ref HEAD\n\n\nOnly the upcoming git 1.8.4.2 or 1.8.5 (Q4 2013) clarifies the syntax.\nSee commit 26776c9:\n\nSeparate this case into two syntactical forms, mimicking the way how the DESCRIPTION section shows this usage.\nAlso update the text that explains the syntax to name the commit to detach HEAD at to clarify.\n\n'git checkout' [--detach] <commit>::\n\n\nPrepare to work on top of <commit>, by detaching HEAD at it (see \"DETACHED HEAD\" section), and updating the index and the tree will be the state recorded in the commit plus the local modifications.\n\nWhen the <commit> argument is a branch name, the --detach option can be used to detach HEAD at the tip of the branch (git checkout <branch> would check out that branch without detaching HEAD).\n\nOmitting <branch> detaches HEAD at the tip of the current branch.\n\n\n\nThat last point is precisely what you want to do for your current branch:\ngit checkout --detach"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to change git account in Git bash? [duplicate]\n\nThis question already has answers here:\n \n \n\n\n\n\nConfiguring user and password with Git Bash\n\n (14 answers)\n \n\nClosed 5 months ago.\n\n\n\nI have weird problem with Git bash. I have two Github accounts, let's say A and B. I set my name and email, like in account A: \ngit config --global user.name \ngit config --global user.email \n\nI initialized new repo, did a commit, then push and git bash asked me about login and password to github. By mistake I put login and password for account B! I logged in successfully, but there is no repository I just initialized.\nHow can I logout and login to different github account? It's not user.name nor user.email"
},
{
"role": "assistant",
"content": "Much simpler, as I explained in \"How to sign out in Git Bash console in Windows?\":\ngit credential-manager erase <url>\n\nHere\ngit credential-manager erase https://github.com\n\nNo need to remove the credential helper which is practical for caching user's password.\nOr (replace xxx wit the output of git config --global credential.helper):\nprintf \"protocol=https\\nhost=github.com\" | git-credential-xxx erase\n\n# Windows (2020-2021)\nprintf \"protocol=https\\nhost=github.com\" | git-credential-manager-core erase\n\n# Linux\nprintf \"protocol=https\\nhost=github.com\" | git-credential-libsecret erase\n\n# MacOs\nprintf \"protocol=https\\nhost=github.com\" | git-credential-osxkeychain erase"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch --cleanup=<mode>"
},
{
"role": "assistant",
"content": "This option determines how the merge message will be cleaned up before\ncommitting. See git-commit for more details. In addition, if\nthe <mode> is given a value of scissors , scissors will be appended\nto MERGE_MSG before being passed on to the commit machinery in the\ncase of a merge conflict."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to discard all changes made to a branch?\nI'm working in a branch (i.e. design) and I've made a number of changes, but I need to discard them all and reset it to match the repository version. I thought git checkout design would do it, but it just tells me I'm already in branch design and that I have 3 modified files.\nHow would I discard those changes and get the branch as it stands now on the remote server?"
},
{
"role": "assistant",
"content": "Note: You CANNOT UNDO this.\nTry git checkout -f this will discard any local changes which are not committed in ALL branches and master."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Comparing the pros and cons of Bitbucket to Github [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 10 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nDisclaimer: This is a subjective question. Please follow relevant guidelines.\nI am considering the migration of source code from a traditional VCS to a DVCS. Since having a decent GUI web-based frontend and workflow tools are a must, the two obvious candidates are Bitbucket and Github.\nUnfortunately I have no in-depth experience with either of them, so I'd really like to have a few second opinions before taking the dive. Especially welcome would be observations from a team/business perspective regarding day-to-day usage and features that have an impact on productivity.\nWhat is Your experience with either of them? Any particular highlights or annoyances?"
},
{
"role": "assistant",
"content": "if you are new to them both then it depends on what you need. a free github account doesn't include any private repositories whereas bitbucket free account gives you unlimited private repositories. \nthis was the selling thing for me - I didnt want to initially pay for github as i was trialing it but i didnt want me code to be free for all as it was commercial. This lead me to choose bitbucket\nI now use both (github for my OSS products and bitbucket for more locked down code) but I am moving my entire team away from SVN to mercurial as it was a simplier step to go to that git. From personal experience, it was easier to get to grips with Hg initially before git when I was using a DVCS for the first time. It didnt require the complex git install and could be used from within the windows cmd or powershell windows"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_AUTHOR_EMAIL"
},
{
"role": "assistant",
"content": "The email address used in the author identity when creating commit or\ntag objects, or when writing reflogs. Overrides the user.email and author.email configuration settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to list ALL git objects in the database?\nIs there a better way of getting a raw list of SHA1s for ALL objects in a repository than:\nls .git/objects/??/\\*\nand\ncat .git/objects/pack/*.idx | git show-index\nI know about git rev-list --all but that only lists commit objects that are referenced by .git/refs, and I'm looking for everything, including unreferenced objects that are created by git-hash-object, git-mktree etc."
},
{
"role": "assistant",
"content": "I don’t know since when this option exists but you can\ngit cat-file --batch-check --batch-all-objects\n\nThis gives you, according to the man page,\n\nall objects in the repository and any alternate object stores (not just reachable objects)\n\n(emphasis mine).\nSample output:\n$ git cat-file --batch-check --batch-all-objects\n64a77169fe44d06b082cbe52478b3539cb333d45 tree 34\n6692c9c6e231b1dfd5594dd59b32001b70060f19 commit 237\n740481b1d3ce7de99ed26f7db6687f83ee221d67 blob 50\n0e5814c4da88c647652df8b1bd91578f7538c65f tag 200\n\nAs can be seen above, this yields the object type and it’s size together with each hash but you can easily remove this information, e.g. with\ngit cat-file --batch-check --batch-all-objects | cut -d' ' -f1\n\nor by giving a custom format to --batch-check.\nEdit: If you don't care about the order you can (since Git 2.19) add the flag --unordered to speed things up. See VonC's answer for more details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I embed source files from GitHub on my web page other than Gists?\n\nContext\nYou can create a Gist on GitHub and embed it on your web page: embedding Gists.\nThis is an example of a randomly chosen Gist: tap.groovy.\nQuestion\nIs embedding also possible with other code files from GitHub, for example with this randomly chosen C# file ICommand.cs which is not a Gist?"
},
{
"role": "assistant",
"content": "You can try https://emgithub.com, which does exactly what you want.\nTo embed the example file ICommand.cs in your question, you can just add \"em\" before \"github.com\" in the address bar, then press Enter.\nThen you can get a script tag like this:\n\n\n<script src=\"https://emgithub.com/embed-v2.js?target=https%3A%2F%2Fgithub.com%2Fdotnet%2Fcorefx%2Fblob%2Fmaster%2Fsrc%2FSystem.ObjectModel%2Fsrc%2FSystem%2FWindows%2FInput%2FICommand.cs&style=default&type=code&showBorder=on&showLineNumbers=on&showFileMeta=on&showCopy=on\"></script>\n\n\n\nNote if you simply click Run code snippet in StackOverflow, the copying button at top right corner may not work. Running it outside SO would work fine.\nUnlike other websites that do similar work, EmGithub.com is a static site hosted on Github Pages. Fetching target files and highlighting are done on your browser.\n\nDisclosure: I'm the developer of it :)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GIT -- Exclude / Ignore Files from commit [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nUntrack files from git temporarily\n\n (10 answers)\n \n\n\nCan I 'git commit' a file and ignore its content changes?\n\n (5 answers)\n \n\nClosed 10 years ago.\n\n\n\nI need to ignore files in git! I don't think ignore is the right word actually; I want the files to be in git, but I don't want to be able to commit changes to them. This may seem like a weird thing to some, but there are many, many instances that I need this functionality. The one instance I need it for now is when using git with a CMS; the CMS won't work without files that it is constantly changing, but I don't want those files to ever be committed after the initial commit. (This is very easy to do with SVN and Tortoise).\nWorkFlow:\n\nGet All Files needed to run the app.\nIgnore specified directories / files when committing.\n\nHere is what I've tried:\n\n.gitignore -- the files never enter git. If the file is already in\ncache the .gitignore file doesn't do anything.\n/.git/info/exclude -- same problem as .gitignore, but only for\nthe local repo.\nBranching -- master => LocalIgnores => WorkingBranch. When the\nWorking branch is merged with master, the changes made from\nLocalIgnores end up in master. Also, when you checkout one of the\nnew branches, the deleted files get deleted instead of ignored.\nThirdparty File Structure -- Thirdparty directory on the root\nnode that holds a copy of all important thirdparty files so they can\nbe copied into the working directory that utilizes the .gitignore\nfile. (This one works, but there has to be an easier / better\nsolurtion)."
},
{
"role": "assistant",
"content": "Here is my answer from a similar question.\n\ngit update-index should do what you want\nThis will tell git you want to start ignoring the changes to the file\ngit update-index --assume-unchanged path/to/file\nWhen you want to start keeping track again\ngit update-index --no-assume-unchanged path/to/file"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.relative"
},
{
"role": "assistant",
"content": "If set to true , git diff does not show changes outside of the directory\nand show pathnames relative to the current directory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Reference GitHub file in jsFiddle\n\nIs there a possibility to misuse grab files from a github repo as external resources in jsFiddle?"
},
{
"role": "assistant",
"content": "TLDR; Visit rawgit.com which will pop your files on a CDN straight from GitHub so you can use them.\nUnfortunately none of the answers here worked for me. The rawgithub URL didn't seem to work as the connection gets refused. So here's a full solution that did work. Firstly in GitHub you need to click the Raw button to get the original JavaScript.\n\nThen copy the URL from the page it takes you too. You'll notice if you try and use this directly you'll get a warning from JSFiddle.\n\nMore to the point is the browser will give you an error, e.g.:\nRefused to execute script from https://raw.githubusercontent.com/nnnick/Chart.js/master/Chart.min.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.\nTake that URL and visit rawgit.com. This will give you a URL of the format https://rawgit.com/nnnick/Chart.js/master/Chart.min.js which you can then use.\nI've tried and tested this and it seems to work fine without issue"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-revert - Revert some existing commits --skip"
},
{
"role": "assistant",
"content": "Skip the current commit and continue with the rest of the\nsequence."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects %cs"
},
{
"role": "assistant",
"content": "committer date, short format ( YYYY-MM-DD )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %aI"
},
{
"role": "assistant",
"content": "author date, strict ISO 8601 format"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I embed a YouTube video on GitHub wiki pages?\n\nI am fairly new to markup (though it's extremely easy to pickup). I am working on a package and am trying to get the wiki pages looking nice as a help manual. I can insert a YouTube video link into the wiki page pretty easily but how do I embed a YouTube video. I know this may not be possible.\nI have read you can use HTML tags so I tried embedding with HTML per this link as follows:\n<object width=\"425\" height=\"350\">\n <param name=\"movie\" value=\"http://www.youtube.com/user/wwwLoveWatercom?v=BTRN1YETpyg\" />\n <param name=\"wmode\" value=\"transparent\" />\n <embed src=\"http://www.youtube.com/user/wwwLoveWatercom?v=BTRN1YETpyg\"\n type=\"application/x-shockwave-flash\"\n wmode=\"transparent\" width=\"425\" height=\"350\" />\n</object>\n\nAnd saved the page but nothing happened.\n\nIs it possible to embed a YouTube video on GitHub wiki pages?\nIf so how?"
},
{
"role": "assistant",
"content": "It's not possible to embed videos directly, but you can put an image which links to a YouTube video:\n[](https://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)\n\n\nFor more information about Markdown look at this Markdown cheatsheet on GitHub.\nFor more information about Youtube image links look this question."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab-Runner \"listen_address not defined\" error\n\nI'm running a Laravel api on my server, and I wanted to use Gitlab-runner for CD. The first two runs were good, but then I started to see this problem listen_address not defined, session endpoints disabled builds=0\nI'm running a linux server on a web shared hosting, so I can access a terminal and get some priviliges but I can't do some sudo stuff like installing a service. That's why I've been running gitlab-runner in user-mode\nError info\nConfiguration loaded builds=0\nlisten_address not defined, metrics & debug endpoints disabled builds=0\n[session_server].listen_address not defined, session endpoints disabled builds=0\n\n.gitlab-runner/config.toml\nconcurrent = 1\ncheck_interval = 0\n\n[session_server]\n session_timeout = 1800\n\n[[runners]]\n name = \"CD API REST Sistema SIGO\"\n url = \"https://gitlab.com/\"\n token = \"blablabla\"\n executor = \"shell\"\n listen_address=\"my.server.ip.address:8043\"\n [runners.custom_build_dir]\n [runners.cache]\n [runners.cache.s3]\n [runners.cache.gcs]"
},
{
"role": "assistant",
"content": "I have literally wasted 2 days on this subject. I have followed the below steps to get the runners configured and execute jobs successfully.\nI am using Mac OS X 10.13 and Git Lab 12. However, people with other OS also can check this out.\nI have stopped the runners and uninstalled them. Now deleted all references and files to gitlab runner, including the gitlab executable also.\nI got to know GitLab Runner executable paths from https://docs.gitlab.com/runner/configuration/advanced-configuration.html\nI have installed them again using the gitlab official documentation.\nThen the runners shows online in the gitlab portal. However, the jobs are not getting executed. It shows simply stuck. It tried to get information from logs using \n\ngitlab-runner -debug run\n\nThen I got to know that listen_address not defined. After a long try I got to know that simply enabling Run Untagged jobs did the trick. The jobs started and completed successfully. Still the I see the listen_address not defined from debug. So that misled me.\n\nThough it seems that last one task has solved my problem, but doing all the tasks in a batch did the trick."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --no-color-moved-ws"
},
{
"role": "assistant",
"content": "Do not ignore whitespace when performing move detection. This can be\nused to override configuration settings. It is the same as --color-moved-ws=no ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Reuse portion of github action across jobs\n\nI have a workflow for CI in a monorepo, for this workflow two projects end up being built. The jobs run fine, however, I'm wondering if there is a way to remove the duplication in this workflow.yml file with the setting up of the runner for the job. I have them split so they run in parallel as they do not rely on one another and to be faster to complete. It's a big time difference in 5 minutes vs. 10+ when waiting for the CI to finish.\njobs:\n job1:\n name: PT.W Build\n runs-on: macos-latest\n steps:\n - name: Checkout Repo\n uses: actions/checkout@v1\n\n - name: Setup SSH-Agent\n uses: webfactory/[email protected]\n with:\n ssh-private-key: |\n ${{ secrets.SSH_PRIVATE_KEY }}\n\n - name: Setup JDK 1.8\n uses: actions/setup-java@v1\n with:\n java-version: 1.8\n\n - name: Setup Permobil-Client\n run: |\n echo no | npm i -g nativescript\n tns usage-reporting disable\n tns error-reporting disable\n npm run setup.all\n\n - name: Build PT.W Android\n run: |\n cd apps/wear/pushtracker\n tns build android --env.uglify\n\n job2:\n name: SD.W Build\n runs-on: macos-latest\n steps:\n - name: Checkout Repo\n uses: actions/checkout@v1\n\n - name: Setup SSH-Agent\n uses: webfactory/[email protected]\n with:\n ssh-private-key: |\n ${{ secrets.SSH_PRIVATE_KEY }}\n\n - name: Setup JDK 1.8\n uses: actions/setup-java@v1\n with:\n java-version: 1.8\n\n - name: Setup Permobil-Client\n run: |\n echo no | npm i -g nativescript\n tns usage-reporting disable\n tns error-reporting disable\n npm run setup.all\n\n - name: Build SD.W Android\n run: |\n cd apps/wear/smartdrive\n tns build android --env.uglify\n\nYou can see here the jobs have almost an identical process, it's just the building of the different apps themselves. I'm wondering if there is a way to take the duplicate blocks in the jobs and create a way to only write that once and reuse it in both jobs."
},
{
"role": "assistant",
"content": "There are 3 main approaches for code reusing in GitHub Actions:\n\nReusable Workflows\nDispatched workflows\nComposite Actions <-- it's the best one in your case\n\nThe following details are from my article describing their pros and cons:\n🔸 Reusing workflows\nThe obvious option is using the \"Reusable workflows\" feature that allows you to extract some steps into a separate \"reusable\" workflow and call this workflow as a job in other workflows.\n🥡 Takeaways:\n\nNested reusable workflow calls are allowed (up to 4 levels) while loops are not permitted.\nEnv variables are not inherited. Secrets can be inherited by using special secrets: inherit job param.\nIt's not convenient if you need to extract and reuse several steps inside one job.\nSince it runs as a separate job, you have to use build artifacts to share files between a reusable workflow and your main workflow.\nYou can call a reusable workflow in synchronous or asynchronous manner (managing it by jobs ordering using needs keys).\nA reusable workflow can define outputs that extract outputs/outcomes from executed steps. They can be easily used to pass data to the \"main\" workflow.\n\n🔸 Dispatched workflows\nAnother possibility that GitHub gives us is workflow_dispatch event that can trigger a workflow run. Simply put, you can trigger a workflow manually or through GitHub API and provide its inputs.\nThere are actions available on the Marketplace which allow you to trigger a \"dispatched\" workflow as a step of \"main\" workflow.\nSome of them also allow doing it in a synchronous manner (wait until dispatched workflow is finished). It is worth to say that this feature is implemented by polling statuses of repo workflows which is not very reliable, especially in a concurrent environment. Also, it is bounded by GitHub API usage limits and therefore has a delay in finding out a status of dispatched workflow.\n🥡 Takeaways\n\nYou can have multiple nested calls, triggering a workflow from another triggered workflow. If done careless, can lead to an infinite loop.\nYou need a special token with \"workflows\" permission; your usual secrets.GITHUB_TOKEN doesn't allow you to dispatch a workflow.\nYou can trigger multiple dispatched workflows inside one job.\nThere is no easy way to get some data back from dispatched workflows to the main one.\nWorks better in \"fire and forget\" scenario. Waiting for a finish of dispatched workflow has some limitations.\nYou can observe dispatched workflows runs and cancel them manually.\n\n🔸 Composite Actions\nIn this approach we extract steps to a distinct composite action, that can be located in the same or separate repository.\nFrom your \"main\" workflow it looks like a usual action (a single step), but internally it consists of multiple steps each of which can call own actions.\n🥡 Takeaways:\n\nSupports nesting: each step of a composite action can use another composite action.\nBad visualisation of internal steps run: in the \"main\" workflow it's displayed as a usual step run. In raw logs you can find details of internal steps execution, but it doesn't look very friendly.\nShares environment variables with a parent job, but doesn't share secrets, which should be passed explicitly via inputs.\nSupports inputs and outputs. Outputs are prepared from outputs/outcomes of internal steps and can be easily used to pass data from composite action to the \"main\" workflow.\nA composite action runs inside the job of the \"main\" workflow. Since they share a common file system, there is no need to use build artifacts to transfer files from the composite action to the \"main\" workflow.\nYou can't use continue-on-error option inside a composite action."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git submodule add: \"a git directory is found locally\" issue\nI'm actually trying to learn how to use git, including the git submodule subcommands.\nI already set up a server on which I can host, push and pull git repositories by using SSH.\nI created a main git repository \"Travail\" on this server in which I would like to put all my projects as submodules.\nIn my Travail repository, I already added a project of mine as a submodule at tools/libft:\nI'm able to develop this submodule, to push and to pull it.\nBut when I try to add another submodule (named fdf, from fdf.git on my server), I get the following issue :\ngit submodule add ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git projets/fdf\n\n\nA git directory for 'projets/fdf' is found locally with remote(s):\n origin ssh://[email protected]:XXXXX/opt/git/fdf.git\n If you want to reuse this local git directory instead of cloning again from\n ssh://XXX.XXX.XXX.XXX:XXXXX/opt/git/fdf.git\n use the '--force' option. If the local git directory is not the correct repo \n or you are unsure what this means choose another name with the '--name' option.\n\nThere is actually no subdirectory in projets/\nI read on another thread that I should use git submodule sync or edit the .gitmodules file in which the URL to my submodule's origin repository could have changed.\nBut my .gitmodules file only contains the information about my first submodule (tools/libft), not about projets/fdf :\n[submodule \"tools/libft\"]\n path = tools/libft\n url = ssh://[email protected]:XXXXX/opt/git/libft.git\n\nAs a French student I could have missed something in the English documentation I have, but I searched and I really don't understand why I get this issue.\nI would be glad if I would get a solution but just an explanation would be helpful too."
},
{
"role": "assistant",
"content": "I came to this SO post trying to add a submodule with the same path as a submodule that I recently deleted.\nThis is what ultimately worked for me (this article helped out a lot):\nIf you haven't already run\ngit rm --cached path_to_submodule (no trailing slash) as well as\nrm -rf path_to_submodule\nThen:\n\nDelete the relevant lines from the .gitmodules file. e.g. delete these:\n\n[submodule \"path_to_submodule\"]\n path = path_to_submodule\n url = https://github.com/path_to_submodule\n\n\nDelete the relevant section from .git/config. e.g. delete these:\n\n[submodule \"path_to_submodule\"]\n url = https://github.com/path_to_submodule\n\n\nrm -rf .git/modules/path_to_submodule\n\nThen, you can finally:\ngit submodule add https://github.com/path_to_submodule"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Setup git in Intellij terminal\nI want to use git in Intellij Terminal but it does not recognize the command. In Command Prompt and Windows power shell the command in recognized (I added the git path in System Environment Variables). I am also aware that Intellij has an GUI integration with Git.\nSo, can anyone tell me how can I use the git command in the Intellij terminal."
},
{
"role": "assistant",
"content": "Setup JetBrains(InteliJ, WebStorm, PHPStorm) IDE terminal to use GIT bash\n\nFile\nSettings\n(Enter 'Terminal' in search)\nChange Shell path to:\n\n\"C:\\Program Files\\Git\\bin\\sh.exe\" --login -i\n\nor\n\"C:\\Program Files\\Git\\bin\\bash.exe\"\n\nIf you have another directory for installed git change it respectively."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit-tree - Create a new commit object <tree>"
},
{
"role": "assistant",
"content": "An existing tree object."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary blob object"
},
{
"role": "assistant",
"content": "Untyped object , e.g. the contents of a file."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.