messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to reset git authentication?\nI typed wrong ID (my mistake) and I think my computer's IP is permanently banned. I'd like to un-ban my IP so that I can git clone to my desired git repository. But when I tried to git clone my git repository, it says\nremote: HTTP Basic: Access denied\nfatal: Authentication failed for \"~~my repository\"\nHow can I access my git repository again? Or how can I reset my banned state? I think typing a wrong ID only once and be permanently banned is somewhat harsh." }, { "role": "assistant", "content": "It seems that your credential manager stored wrong authentication and reuses it. Reset it.\ngit config --system --unset credential.helper\n\nMore information:\nRemove credentials from Git\nGitLab remote: HTTP Basic: Access denied and fatal Authentication" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Jenkins giving error while cloning from gitHub\n\nI am new to Jenkins, I am getting following error while cloning repository from GitHub.\nI tried to search all relevant issues here but could find exact stacktstrace with answers.\nI am trying to clone repository which requires username and password, I am providing SSH:// repository-path in job configuration settings for my job. I have not done any .ssh related settings yet as this seems to be different problem than security issue with GIT repository. \nI couldn't figure out what comment Jenkins is trying to execute, which file/directory it is not finding clueless.\nHere is my exact stack trace from Jenkins job:\n\nCaused by: java.io.IOException: Cannot run program: Error trying to\n determine the git version: Error performing command: --version\n Assuming 1.6\n ERROR: Error cloning remote repo 'myRE' : Could not clone [email protected]:myORG/RVL.myProj.git\n hudson.plugins.git.GitException: Could not clone [email protected]:myORG/RVL.myProj.git\n at hudson.plugins.git.GitAPI.clone(GitAPI.java:268)\n at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1122)\n at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064)\n at hudson.FilePath.act(FilePath.java:842)\n at hudson.FilePath.act(FilePath.java:824)\n at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1064)\n at hudson.model.AbstractProject.checkout(AbstractProject.java:1256)\n at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589)\n at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)\n at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494)\n at hudson.model.Run.execute(Run.java:1502)\n at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)\n at hudson.model.ResourceController.execute(ResourceController.java:88)\n at hudson.model.Executor.run(Executor.java:236)\n Caused by: hudson.plugins.git.GitException: Error performing command: clone -o RVL.myProj [email protected]:myORG/RVL.myProj.git\n /var/lib/jenkins/jobs/myProj/workspace\n at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:862)\n at hudson.plugins.git.GitAPI.access$000(GitAPI.java:40)\n at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:264)\n at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:244)\n at hudson.FilePath.act(FilePath.java:842)\n at hudson.FilePath.act(FilePath.java:824)\n at hudson.plugins.git.GitAPI.clone(GitAPI.java:244)\n ... 13 more\n Caused by: java.io.IOException: Cannot run program \"\": error=2, No such file or directory\n at java.lang.ProcessBuilder.start(Unknown Source)\n at hudson.Proc$LocalProc.(Proc.java:244)\n at hudson.Proc$LocalProc.(Proc.java:216)\n at hudson.Launcher$LocalLauncher.launch(Launcher.java:709)\n at hudson.Launcher$ProcStarter.start(Launcher.java:338)\n at hudson.Launcher$ProcStarter.join(Launcher.java:345)\n at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:843)\n ... 19 more\n Caused by: java.io.IOException: error=2, No such file or directory\n at java.lang.UNIXProcess.forkAndExec(Native Method)\n at java.lang.UNIXProcess.(Unknown Source)\n at java.lang.Pro" }, { "role": "assistant", "content": "I encountered and fixed the same problem :)\nThere are two way to configure the path of git:\n\nOn Jenkins Master\na. Enter Jenkins System Configure (Jenkins -> Manage Jenkins -> Configure System )\nb. Find the Git item and Configure the git installation (specify the git path on Jenkins Master)\nOn Jenkins Slave\na. Enter Jenkins Slave's Configure\nb. Check the \"Tool Locations\" Checkbox and specify the path of git on the Jenkins Slave.\n\nIn my situation, I don't have the privilege to access the Jenkins Master. So I install the git on the Jenkins Slave and add it to Jenkins Slave's Configure." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-list - Lists commit objects in reverse chronological order --date=<format>" }, { "role": "assistant", "content": "Only takes effect for dates shown in human-readable format, such\nas when using --pretty . log.date config variable sets a default\nvalue for the log command’s --date option. By default, dates\nare shown in the original time zone (either committer’s or\nauthor’s). If -local is appended to the format (e.g., iso-local ), the user’s local time zone is used instead. --date=relative shows dates relative to the current time,\ne.g. “2 hours ago”. The -local option has no effect for --date=relative . --date=local is an alias for --date=default-local . --date=iso (or --date=iso8601 ) shows timestamps in a ISO 8601-like format.\nThe differences to the strict ISO 8601 format are: a space instead of the T date/time delimiter a space between time and time zone no colon between hours and minutes of the time zone --date=iso-strict (or --date=iso8601-strict ) shows timestamps in strict\nISO 8601 format. --date=rfc (or --date=rfc2822 ) shows timestamps in RFC 2822\nformat, often found in email messages. --date=short shows only the date, but not the time, in YYYY-MM-DD format. --date=raw shows the date as seconds since the epoch (1970-01-01\n00:00:00 UTC), followed by a space, and then the timezone as an offset\nfrom UTC (a + or - with four digits; the first two are hours, and\nthe second two are minutes). I.e., as if the timestamp were formatted\nwith strftime(\"%s %z\") ).\nNote that the -local option does not affect the seconds-since-epoch\nvalue (which is always measured in UTC), but does switch the accompanying\ntimezone value. --date=human shows the timezone if the timezone does not match the\ncurrent time-zone, and doesn’t print the whole date if that matches\n(ie skip printing year for dates that are \"this year\", but also skip\nthe whole date itself if it’s in the last few days and we can just say\nwhat weekday it was). For older dates the hour and minute is also\nomitted. --date=unix shows the date as a Unix epoch timestamp (seconds since\n1970). As with --raw , this is always in UTC and therefore -local has no effect. --date=format:... feeds the format ... to your system strftime ,\nexcept for %s, %z, and %Z, which are handled internally.\nUse --date=format:%c to show the date in your system locale’s\npreferred format. See the strftime manual for a complete list of\nformat placeholders. When using -local , the correct syntax is --date=format-local:... . --date=default is the default format, and is based on ctime(3)\noutput. It shows a single line with three-letter day of the week,\nthree-letter month, day-of-month, hour-minute-seconds in \"HH:MM:SS\"\nformat, followed by 4-digit year, plus timezone information, unless\nthe local time zone is used, e.g. Thu Jan 1 00:00:00 1970 +0000 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-remote - Manage set of tracked repositories set-url" }, { "role": "assistant", "content": "Changes URLs for the remote. Sets first URL for remote <name> that matches\nregex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If\n<oldurl> doesn’t match any URL, an error occurs and nothing is changed. With --push , push URLs are manipulated instead of fetch URLs. With --add , instead of changing existing URLs, new URL is added. With --delete , instead of changing existing URLs, all URLs matching\nregex <URL> are deleted for remote <name>. Trying to delete all\nnon-push URLs is an error. Note that the push URL and the fetch URL, even though they can\nbe set differently, must still refer to the same place. What you\npushed to the push URL should be what you would see if you\nimmediately fetched from the fetch URL. If you are trying to\nfetch from one place (e.g. your upstream) and push to another (e.g.\nyour publishing repository), use two separate remotes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does GitHub for Windows' \"sync\" do?\nWith GitHub for Windows, you can \"publish\" a branch, and then \"sync\" that branch to GitHub.\n\nIs the sync basically a git pull and git push? Or is there more to it? If I wanted to do the exact same steps as \"sync\" from the command line, what should I do?\n(It's not Open Source, or I'd just read that.)" }, { "role": "assistant", "content": "Sync does git pull --rebase and then if there are local changes, it does git push.\nFrom here: http://haacked.com/archive/2012/05/21/introducing-github-for-windows.aspx#87318" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-mailsplit" }, { "role": "assistant", "content": "Simple UNIX mbox splitter program" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Delete all branches that are more than X days/weeks old\nI found the below script that lists the branches by date. How do I filter this to exclude newer branches and feed the results into the Git delete command?\nfor k in $(git branch | sed /\\*/d); do \n echo \"$(git log -1 --pretty=format:\"%ct\" $k) $k\"\ndone | sort -r | awk '{print $2}'" }, { "role": "assistant", "content": "How about using --since and --before?\nFor example, this will delete all branches that have not received any commits for a week:\nfor k in $(git branch | sed /\\*/d); do \n if [ -z \"$(git log -1 --since='1 week ago' -s $k)\" ]; then\n git branch -D $k\n fi\ndone\n\nIf you want to delete all branches that are more than a week old, use --before:\nfor k in $(git branch | sed /\\*/d); do \n if [ -z \"$(git log -1 --before='1 week ago' -s $k)\" ]; then\n git branch -D $k\n fi\ndone\n\nBe warned though that this will also delete branches that where not merged into master or whatever the checked out branch is." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Use GitLab API from a GitLabCI build script\n\nI have a GitLab CI build script like this:\ncreate release:\n stage: deploy\n tags:\n - basic\n only:\n - tags\n script:\n - GITLOG=$(echo \"# Changes Log\"; git log `git tag | tail -2 | head -1`..${CI_BUILD_TAG} --pretty=format:\" - %s\")\n - curl -X POST -d \"private_token=$CI_BUILD_TOKEN&description=$GITLOG\" \"http://git.example.com/api/v3/projects/${CI_PROJECT_ID}/repository/tags/${CI_BUILD_TAG}/release\"\n\nThe purpose of this step is to automatically add a Changes Log from Git in the GitLab Releases section.\nThat works if I manually run this on the command line and put in the variables... \nThe problem is that the value of CI_BUILD_TOKEN in the build runner isn't a valid GitLab Private Token - it's only a token to connect to the Docker Registry - as per the documentation.\nIs there a way to get a valid GitLab API token that the build runner can use to access the API for the project it's running a build for? Seems like this should be possible.\nGitLab Runner:\ngitlab-runner -v\nVersion: 1.2.0\nGit revision: 3a4fcd4\nGit branch: HEAD\nGO version: go1.6.2\nBuilt: Sun, 22 May 2016 20:05:30 +0000\nOS/Arch: linux/amd64" }, { "role": "assistant", "content": "You can have read-only access with the API from the runner, but only if you add a header with the CI_JOB_TOKEN.\ne.g.\ncurl -H \"JOB_TOKEN: $CI_JOB_TOKEN\" \"https://gitlab.com/api/v4/projects/2828837/repository/tags\n\nAnd only when the project is public with everyone has access from the same project.\nIf you want access to private projects as well and/or write access, please up-vote GitLab issue #29566 and/or #41084.\nAs an alternative for the time being, you can create an access token on gitlab, and add it to the secret variables, under project settings/ci_cd although not really advised to do as your personal access token will be used by everyone who trigger the job." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I fix a corrupted Git repository?\nI tried cloning my repository which I keep in my Ubuntu One folder to a new machine, and I got this:\ncd ~/source/personal\ngit clone ~/Ubuntu\\ One\\ Side\\ Work/projects.git/\n\nCloning into 'projects'...\ndone.\nfatal: unable to read tree 29a422c19251aeaeb907175e9b3219a9bed6c616\n\nSo I tried looking at the many other questions like this that have been asked here and most of them say to run git fsck --full and then I get this when I try that.\ncd ~/Ubuntu\\ One\\ Side\\ Work/projects.git\ngit fsck --full\n\nChecking object directories: 100% (256/256), done.\nChecking objects: 100% (447/447), done.\nbroken link from commit 235ae1f48701d577d71ebd430344a159e5ba4881\n to commit 984c11abfc9c2839b386f29c574d9e03383fa589\nbroken link from tree 632a9cf0ef9fccea08438b574e2f1c954f4ff08b\n to blob 25a742dff0a403b2b3884f2ffddf63eb45721fac\nbroken link from tree 632a9cf0ef9fccea08438b574e2f1c954f4ff08b\n to blob dd4e97e22e159a585b20e21028f964827d5afa4e\nbroken link from tree 632a9cf0ef9fccea08438b574e2f1c954f4ff08b\n to tree 29a422c19251aeaeb907175e9b3219a9bed6c616\nbroken link from tree 632a9cf0ef9fccea08438b574e2f1c954f4ff08b\n to tree 8084e8e04d510cc28321f30a9646477cc50c235c\nbroken link from tree 774b5b4157b4caae1c6cad96c8eaf5d4eba2c628\n to blob a0daa0c1567b55d8de2b4d7a3bc010f58c047eab\nbroken link from tree 774b5b4157b4caae1c6cad96c8eaf5d4eba2c628\n to blob e9052d35bfb6d30065b206fc43f4200a04d5281b\nbroken link from tree 774b5b4157b4caae1c6cad96c8eaf5d4eba2c628\n to blob 1a3a5e4dd2502ac121c22f743c4250e254a94eeb\nbroken link from tree 4aa336dc1a5838e8918e03b85580069d83f4ad09\n to tree 8cc55ec952dc192a233e062201d1e7e873ac3db0\nbroken link from tree e5674a91a53e15575a1f3bf5786bc5cc719fb483\n to blob 4a994e1e7bb7ce28dcec98bad48b9a891d7dec51\nbroken link from tree e5674a91a53e15575a1f3bf5786bc5cc719fb483\n to blob ac033bf9dc846101320c96a5ce8aceb8c96ec098\nbroken link from tree 252ab84542264e1589576b6ee51e7a31e580a0e2\n to tree 2069041cd5950e529e2991d37b7290ec021d90d4\nbroken link from tree 2d4964aa4d4f5d8c7228518ce72ef6a63f820c6d\n to blob d83690e1b9a6bdd8a08754b38231799acefcb2ab\nbroken link from tree c7192e82fc581bd6448bda1a25e8729bdac5f4ff\n to blob 30d54d47ae82add1917ca173d42e58b396df580b\nbroken link from tree 7c66306901fc71389623286936cef172d4ffe408\n to blob bc7e05d705401273b1df4e939de0f540597c0931\nbroken link from tree 0940f5fd227d4c84d6e6749d872db50a4522ae3a\n to tree 923767594ac22023e824948d65622fe5b407d1a1\nbroken link from tree 8eadcd2a971e8357d24f0d80f993d2963452209f\n to blob 2598bde3dc8cb80ee49510b8159344004b88645f\nbroken link from tree ffa302dd0d969172ef23caeefe856ab2f57a4e4d\n to blob d6925fa431be1ac585bf9a481e98f75107a6e6fb\nbroken link from tree 7045b8870a49ce30a2027537a96d73d162bda773\n to blob 25688652dea26f61f576ca1b52b9d1a18fbfd01d\nbroken link from tree 37e4705d34bd440ce681ae32ae9a180a13256d72\n to tree 246f564d4cee53339b8a4244f3173b61caa518eb\nmissing blob d6925fa431be1ac585bf9a481e98f75107a6e6fb\nmissing blob ac033bf9dc846101320c96a5ce8aceb8c96ec098\nmissing tree 29a422c19251aeaeb907175e9b3219a9bed6c616\nmissing tree 8084e8e04d510cc28321f30a9646477cc50c235c\nmissing blob 30d54d47ae82add1917ca173d42e58b396df580b\nmissing tree 8cc55ec952dc192a233e062201d1e7e873ac3db0\nmissing blob e9052d35bfb6d30065b206fc43f4200a04d5281b\ndangling tree 4b26e95db542c72ac4a22ec25abe38fb2de79752\nmissing blob d83690e1b9a6bdd8a08754b38231799acefcb2ab\nmissing blob 25a742dff0a403b2b3884f2ffddf63eb45721fac\nmissing tree 923767594ac22023e824948d65622fe5b407d1a1\nmissing blob 25688652dea26f61f576ca1b52b9d1a18fbfd01d\nmissing blob 2598bde3dc8cb80ee49510b8159344004b88645f\ndangling tree 3a683869f1bb0c1634de75700c316b3b36570dbd\ndangling blob 4098d30843380d798a811f1aa9a02994f0dbbb27\nmissing tree 2069041cd5950e529e2991d37b7290ec021d90d4\nmissing blob 4a994e1e7bb7ce28dcec98bad48b9a891d7dec51\nmissing blob 1a3a5e4dd2502ac121c22f743c4250e254a94eeb\nmissing blob a0daa0c1567b55d8de2b4d7a3bc010f58c047eab\ndangling tree 6c7b5162aa7a303fa3fe8dc393c5da564e309521\nmissing commit 984c11abfc9c2839b386f29c574d9e03383fa589\nmissing blob bc7e05d705401273b1df4e939de0f540597c0931\nmissing blob dd4e97e22e159a585b20e21028f964827d5afa4e\nmissing tree 246f564d4cee53339b8a4244f3173b61caa518eb\ndangling commit a01f5c1e5315dc837203d6dee00d3493be9c5db9\n\nThat looks really bad. When I do a git log | head I get this\ngit log | head\n\nerror: Could not read 984c11abfc9c2839b386f29c574d9e03383fa589\nfatal: Failed to traverse parents of commit 235ae1f48701d577d71ebd430344a159e5ba4881\ncommit 2fb0d2d0643b445440f01b164f11ee9ee71fca48\nAuthor: christopher <[email protected]>\nDate: Wed Aug 7 15:51:42 2013 -0400\n\n finishing chapter 7\n\nOther questions here have said to look at ./git/refs/heads/master. It's a bare repo and refs/heads/ exists but refs/heads/master does not. HEAD in the bare repository says ref: refs/heads/master though.\npacked-refs does say this though\n# pack-refs with: peeled\n2fb0d2d0643b445440f01b164f11ee9ee71fca48 refs/heads/master\n\nStill other questions have suggested running git reflog and no output shows up when I run that.\nSo I really have no idea what to do here. What strategy should be taken? Is it possible to reset head to this last commit on Aug 7?\nDoing a git log and going to the bottom of the screen output shows this:\ncommit 996e03b949aea176238e3c7a8452700bbb987ac9\nAuthor: christopher <christopher@christopher>\nDate: Wed Jul 3 23:00:44 2013 -0400\n\n many many changes\nerror: Could not read 984c11abfc9c2839b386f29c574d9e03383fa589\nfatal: Failed to traverse parents of commit 235ae1f48701d577d71ebd430344a159e5ba4881\n\nThat seems to be preventing the Git prune from working." }, { "role": "assistant", "content": "As an alternative to Todd's last option (Full Restores and Re-Initialization), if only the local repository is corrupted, and you know the URL to the remote, you can use this to reset your .git to match the remote (replacing ${url} with the remote URL):\nmv -v .git .git_old && # Remove old Git files\ngit init && # Initialise new repository\ngit remote add origin \"${url}\" && # Link to old repository\ngit fetch && # Get old history\n# Note that some repositories use 'master' in place of 'main'. Change the following line if your remote uses 'master'.\ngit reset origin/main --mixed # Force update to old history.\n\nThis leaves your working tree intact, and only affects Git's bookkeeping.\nI also recently made a Bash script for this very purpose (Appendix A), which wraps a bit of safety around this operation.\nNote:\n\nIf your repository has submodules, this process will mess them up somehow, and the only solution I've found so far is deleting them and then using git submodule update --init (or recloning the repository, but that seems too drastic).\nThis tries to determine the correct choice between 'main' and 'master' depending on local configuration settings, however there may be some issues if used on a repository that uses 'master', on a machine that has 'main' as the default branch.\nThis uses wget to check that the url is reachable before doing anything. This is not necessarily the best operation to determine that a site is reachable, and if you haven't got wget available, this can likely be replaced with ping -c 1 \"${url_base}\" (linux), ping -n 1 \"${url_base}\" (windows), or curl -Is \"${url_base}\"\n\nAppendix A - Full script\nAlso published as a gist, though it is now out of date.\n#!/bin/bash\n\n# Usage: fix-git [REMOTE-URL]\n# Must be run from the root directory of the repository.\n# If a remote is not supplied, it will be read from .git/config\n#\n# For when you have a corrupted local repo, but a trusted remote.\n# This script replaces all your history with that of the remote.\n# If there is a .git, it is backed up as .git_old, removing the last backup.\n# This does not affect your working tree.\n#\n# This does not currently work with submodules!\n# This will abort if a suspected submodule is found.\n# You will have to delete them first\n# and re-clone them after (with `git submodule update --init`)\n#\n# Error codes:\n# 1: If a URL is not supplied, and one cannot be read from .git/config\n# 4: If the URL cannot be reached\n# 5: If a Git submodule is detected\n\n\nif [[ \"$(find -name .git -not -path ./.git | wc -l)\" -gt 0 ]] ;\nthen\n echo \"It looks like this repo uses submodules\" >&2\n echo \"You will need to remove them before this script can safely execute\" >&2\n echo \"Then use \\`git submodule update --init\\` to re-clone them\" >&2\n exit 5\nfi\n\nif [[ $# -ge 1 ]] ;\nthen\n url=\"$1\"\nelse\n if ! url=\"$(git config --local --get remote.origin.url)\" ;\n then\n echo \"Unable to find remote 'origin': missing in '.git/config'\" >&2\n exit 1\n fi\nfi\n\nif ! branch_default=\"$(git config --get init.defaultBranch)\" ;\nthen\n # if the defaultBranch config option isn't present, then it's likely an old version of git that uses \"master\" by default\n branch_default=\"master\"\nfi\n\nurl_base=\"$(echo \"${url}\" | sed -E 's;^([^/]*://)?([^/]*)(/.*)?$;\\2;')\"\necho \"Attempting to access ${url_base} before continuing\"\nif ! wget -p \"${url_base}\" -O /dev/null -q --dns-timeout=5 --connect-timeout=5 ;\nthen\n echo \"Unable to reach ${url_base}: Aborting before any damage is done\" >&2\n exit 4\nfi\n\necho\necho \"This operation will replace the local repo with the remote at:\"\necho \"${url}\"\necho\necho \"This will completely rewrite history,\"\necho \"but will leave your working tree intact\"\necho -n \"Are you sure? (y/N): \"\n\nread confirm\nif ! [ -t 0 ] ; # i'm open in a pipe\nthen\n # print the piped input\n echo \"${confirm}\"\nfi\nif echo \"${confirm}\"|grep -Eq \"[Yy]+[EeSs]*\" ; # it looks like a yes\nthen\n if [[ -e .git ]] ;\n then\n # remove old backup\n rm -vrf .git_old | tail -n 1 &&\n # backup .git iff it exists\n mv -v .git .git_old\n fi &&\n git init &&\n git remote add origin \"${url}\" &&\n git config --local --get remote.origin.url | sed 's/^/Added remote origin at /' &&\n git fetch &&\n git reset \"origin/${branch_default}\" --mixed\nelse\n echo \"Aborting without doing anything\"\nfi" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to change the default target branch for merges in Gitlab\nwe are using Gitlab 8.10.1 with many groups and projects. Many of the projects happen to be forks of other projects.\nOur problem is that whenever somebody opens a merge request for a project the default target branch is NOT the default branch of the project but from one very specific other project. Is there a way to override this setting somehow?\nJust to make it clear, I know how to set the default branch of a project and those settings appear to be correct, however gitlab doesn't seem to use them when creating merge requests.\nThis issue is very annoying and has led to weird situations when people didn't pay attention and made merge requests with a completely different \"master\" as target." }, { "role": "assistant", "content": "The default MR target depends on whether or not the repository is a GitLab fork.\nForks\nIf the repository is a GitLab fork, then the default MR target will be the default branch of the upstream repository. This relationship can be removed via the \"Remove fork relationship\" option on the Project settings page, after which the default MR target will be determined as normal for a non-fork repository (described below).\nAt time of writing, it is not possible to override the default MR target without removing the fork relationship, but that functionality has been requested in gitlab issue #14522.\nNon-Forks\nIf the repository has no fork relationship, then the Default Branch setting on the Project settings page sets both (1) the default MR target, and (2) the HEAD reference of the repo on the GitLab server (which determines the branch that's checked out when the repo is cloned). Note that, due to a bug/quirk in git, problems can occur if a branch that was once the Default Branch is later deleted from GitLab.\nAt time of writing, it is not possible to change the default MR target independently of the Default Branch, but this functionality has been requested in gitlab issue #17909." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options log.initialDecorationSet" }, { "role": "assistant", "content": "By default, git log only shows decorations for certain known ref\nnamespaces. If all is specified, then show all refs as\ndecorations." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab: remote: Your SSH key has expired\n\nI was trying to push changes to the branch but i got this error:\nremote: Your SSH key has expired.\nremote: \nremote: ========================================================================\nremote: \nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\ni generated new access token in gitlab settings but i'm not sure how can i add to my project so i can push again" }, { "role": "assistant", "content": "This is a hack but if you're using that ssh key elsewhere to and don't want to update it everywhere AND you don't have security concerns, you can scroll all the way down on the page where gitlab displays your expired ssh key and hit Remove. Then you can add the same key again and have 1 more year validity on it" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Trying to pull files from my Github repository: \"refusing to merge unrelated histories\"\n\nI'm learning git, and I'm following the Git community book. \nPreviously (long time ago) I made a public repository on Github, with some files. Now I set up a local Git repository on my current computer, and committed some files. Then I added a remote pointing to my Github page:\n[root@osboxes c]# git remote add learnc https://github.com/michaelklachko/Learning-C\n\nThat seemed to be successful: \n[root@osboxes c]# git remote show learnc\n* remote learnc\n Fetch URL: https://github.com/michaelklachko/Learning-C\n Push URL: https://github.com/michaelklachko/Learning-C\n HEAD branch: master\n Remote branch:\n master tracked\n Local ref configured for 'git push':\n master pushes to master (local out of date)\n\nNow I want to download the files from my Github repo to my computer. I did this:\n[root@osboxes c]# git fetch learnc\n[root@osboxes c]# git merge learnc/master\nwarning: refname 'learnc/master' is ambiguous.\nAlready up-to-date.\n\nHowever, I don't see any new files in my local directory. How can I get them? \nI also tried to do this:\n[root@osboxes c]# git pull learnc master\nFrom https://github.com/michaelklachko/Learning-C\n * branch master -> FETCH_HEAD\nfatal: refusing to merge unrelated histories\n\nBTW, locally I'm on master branch (there are no other branches):\n[root@osboxes c]# git status\nOn branch master\nnothing to commit, working directory clean" }, { "role": "assistant", "content": "Try --allow-unrelated-histories\nLike max630 commented, or as explained here Git refusing to merge unrelated histories" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How secure would github hosting be for private repositories? [closed]\n\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\nI have read this thread but I'm wondering how secure such a solution would be? I know that github offers ssh/ssl support and am familiar but could someone give me a breakdown of what sort of internal security they would use to make sure my committed conf/credential files don't get hacked?\nEDIT: I've read http://help.github.com/security/ but I would like an answer from someone who has worked with multiple repository hosts and has real-world experience with this." }, { "role": "assistant", "content": "We tried out github recently.\nCompared with our previous git hosting (which was on our own linux virtual server), I'm not overly impressed with the security. We did decide to use it, but only for projects where keeping the code private wasn't a huge concern.\nNamely:\n\nThere's no company control at all over the user accounts. We control which users have access to our repository, but there's no password policies, the users pick their own email addresses, etc.\nThere's no way to limit access by IP address\nPasswords can only be reset by the user\nCompromising the users email account (which we're unable to see what account they've set it to) also results in a compromise of their github account, as they use an email challenge to reset forgotten passwords.\nThere's no access logs (there is an audit trail for most or possibly all changes, but no logging at all for access)\nAccess to the web front end is only password protected, so is vulnerable to password reuse from other sites and to some extent to brute forcing (github's statement about what they do for failed logins is pretty unclear).\n\nOne or two of these we could live, but in combination they basically make github completely unsuitable.\nThey have added 2 factor authentication recently, and there is an API so that organisations can at least check if users with access to their repositories have two factor authentication enabled. Whilst I don't feel this is really the best solution, it probably just about moves github into being secure enough that it can be considered for private repos.\nAs mt3 notes, you can run an enterprise install instead, which presumably significantly improves security - but the cost difference between that and a standard github company account is staggering, and it would probably mean you miss out on all the third party tools that integrate with github.\nOn a non-security note, they do at least now support annual billing properly, which helps reduce the paperwork overhead.\nGitHub have recently announced new business plans with extra features - this could solve '1'/'4'/'5'. (Though the 'uptime guarantee' that's part of it is pretty laughable - not even \"four 9s\", and excludes scheduled maintenance and anything they deem 'outside their reasonable control' - and it's not an actual guarantee, it's just a small credit against your next bill which is capped to be no more than a third of your bill. Basically very carefully worded marketing weasel words instead of any kind of commitment from them.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "See \"real\" commit date / time in github (hour/day)\nIs there a way to see the date of a commit in github, with day/hour precision? Older commits appear in a \"human readable\" format, such as \"2 years ago\" instead of showing the actual date.\n\nIf it's not possible to see the actual date on github, is there a easier workaround than git clone?" }, { "role": "assistant", "content": "Hover your mouse over the 2 years ago and you'll get the timestamp." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "denied: requested access to the resource is denied when pushing image to gitlab registry\n\nI'm trying to push an image to gitlab registry.\nI've done it many times, so I wonder why I get this error.\nI build the image with latest tag: \nSuccessfully tagged registry.gitlab.com/mycompany/rgpd_api:latest\n\nThen I login and I push:\ndocker login registry.gitlab.com -u gitlab+deploy-token-91931 \ndocker push registry.gitlab.com/mycompany/rgpd_api:latest\n\nBut I get:\nThe push refers to repository [registry.gitlab.com/mycompany/rgpd_api]\nbe679cc302b9: Preparing \ndenied: requested access to the resource is denied\n\nI gave gitlab+deploy-token-91931 token both read_repository and read_registry rights.\nMy repo is: \nhttps://gitlab.com/mycompany/rgpd_api\n\nI checked with docs page: https://docs.gitlab.com/ee/user/project/container_registry.html\nBut when I do it through Gitlab CI, with gitlab-ci-token\nI can push it normally.\nI also tried to regenerate a new token, but still same issue.\nHow can I fix it ?" }, { "role": "assistant", "content": "I've stumbled upon this question as well and it turns out that\n\nGroup level Deploy tokens can be used to push images to group level container registry similarly to a PAT token with API access or other applicable scopes.\nThe image must to be tagged with the tag that matches an existing project within the group.\nAny image tagged differently will be rejected with the denied: requested access to the resource is denied error message.\n\nSo, with the setup below:\n\nGitLab group called mytest\nProject within that group called hello-world\nDocker image tagged as registry.gitlab.com/mytest/hello-world\nDeploy token created for an entire group\nDocker daemon authorized to push to that registry by cat \"<deploy_token>\" | docker login -u \"<token_username>\" --password-stdin registry.gitlab.com\n\nYou will get the following results:\n\nSuccessful push for docker push registry.gitlab.com/mytest/hello-world because such project exists within the group\ndenied: requested access to the resource is denied if you try to push an image tagged with the name of the project that does not exist in the group like docker push registry.gitlab.com/mytest/no-project\n\nSo, again, image must be tagged to match an existing path within te group, like an existing project within the group or a subgroup." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index --include=<path-pattern>" }, { "role": "assistant", "content": "Apply changes to files matching the given path pattern. This can\nbe useful when importing patchsets, where you want to include certain\nfiles or directories. When --exclude and --include patterns are used, they are examined in the\norder they appear on the command line, and the first match determines if a\npatch to each path is used. A patch to a path that does not match any\ninclude/exclude pattern is used by default if there is no include pattern\non the command line, and ignored if there is any include pattern." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-unpack-file" }, { "role": "assistant", "content": "Creates a temporary file with a blob’s contents" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why is git-cherrypick saying nothing to commit?\nI searched a lot for the below issue but couldn't get any substantial info.\nI created a temporary branch 202116 and am trying to do a cherrypick of gerrit 202116 and I get the below message. Why am I not able to cherry-pick this commit and why am I getting this error?\n<>git fetch ssh://[email protected]:29418/platform/vendor/company-proprietary/radio refs/changes/25/202116/1 && git cherry-pick FETCH_HEAD\nFrom ssh://company.com:29418/platform/vendor/company-proprietary/radio\n * branch refs/changes/25/206025/1 -> FETCH_HEAD\n# On branch 202116\n# You are currently cherry-picking.\n# (all conflicts fixed: run \"git commit\")\n#\nnothing to commit, working directory clean\nThe previous cherry-pick is now empty, possibly due to conflict resolution.\nIf you wish to commit it anyway, use:\n\n git commit --allow-empty" }, { "role": "assistant", "content": "It's exactly what it says: the changes you're trying to cherry-pick are already wholly contained in the branch you're on. I.e. the result of the cherry-pick is no changes. You can create an empty commit with the --allow-empty flag to indicate that you attempted to cherry-pick, but there were no changes to pull in." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission cumulative" }, { "role": "assistant", "content": "Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Does git have anything like `svn propset svn:keywords` or pre-/post-commit hooks?\nBrowsing through the git documentation, I can't see anything analogous to SVN's commit hooks or the \"propset\" features that can, say, update a version number or copyright notice within a file whenever it is committed to the repository.\nAre git users expected to write external scripts for this sort of functionality (which doesn't seem out of the question) or have I just missed something obvious?\nEdit : Just to be clear, I'm more interested in, e.g.,\nsvn propset svn:keywords \"Author Date Id Revision\" expl3.dtx\n\nwhere a string like this:\n$Id: expl3.dtx 780 2008-08-30 12:32:34Z morten $\n\nis kept up-to-date with the relevant info whenever a commit occurs." }, { "role": "assistant", "content": "I wrote up a fairly complete answer to this elsewhere, with code showing how to do it. A summary:\n\nYou probably don't want to do this. Using git describe is a reasonable alternative.\nIf you do need to do this, $Id$ and $Format$ are fairly easy.\nAnything more advanced will require using gitattributes and a custom filter. I provide an example implementation of $Date$.\n\nSolutions based on hook functions are generally not helpful, because they make your working copy dirty." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %x00" }, { "role": "assistant", "content": "%x followed by two hexadecimal digits is replaced with a\nbyte with the hexadecimal digits' value (we will call this\n\"literal formatting code\" in the rest of this document)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Escape char in Gitlab Secret Variables\n\nI have a secret var :\n\nBut when I do - echo %MySecretVar%, runner displays foo only\nHow can i escape special chars like ! in Gitlab Secret Vars ?" }, { "role": "assistant", "content": "I had the same problems with Gitlab, job running on windows, but I assume it will reproduce on Linux as well, because it seems Gitlab parsing issue or relay weird escaping.\nSo I have set environment variable\nAPPPOOL_PWD: 'blabla!foo$bar'\n\nand output of echo %APPPOOL_PWD% or echo $APPPOOL_PWD was 'blabla'\nThe Gitlab seems to be was eating out the exclamation mark sign ! and dollar sign $. To avoid it as proposed in comment for exclamation mark I have used ^^ and for dollar sign I have used $$ as proposed in the Gitlab variables documentation.\nSo following variable works well:\nAPPPOOL_PWD: 'blabla^^!foo$$bar'\nand output of the echo command in this case would be 'blabla!foo$bar'." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to iterate through all git branches using bash script\nHow can I iterate through all the local branches in my repository using bash script.\nI need to iterate and check is there any difference between the branch and some remote branches.\nEx\nfor branch in $(git branch); \ndo\n git log --oneline $branch ^remotes/origin/master;\ndone\n\nI need to do something like given above, but the issue I'm facing is $(git branch) gives me the folders inside the repository folder along with the branches present in the repository.\nIs this the correct way to solve this issue? Or is there another way to do it?\nThank you" }, { "role": "assistant", "content": "You should not use git branch when writing scripts. Git provides a “plumbing” interface that is explicitly designed for use in scripting (many current and historical implementations of normal Git commands (add, checkout, merge, etc.) use this same interface).\nThe plumbing command you want is git for-each-ref:\ngit for-each-ref --shell \\\n --format='git log --oneline %(refname) ^origin/master' \\\n refs/heads/\n\n\nNote: You do not need the remotes/ prefix on the remote ref unless you have other refs that cause origin/master to match multiple places in the ref name search path (see “A symbolic ref name. …” in the Specifying Revisions section of git-rev-parse(1)). If you are trying to explictly avoid ambiguity, then go with the full ref name: refs/remotes/origin/master.\n\nYou will get output like this:\ngit log --oneline 'refs/heads/master' ^origin/master\ngit log --oneline 'refs/heads/other' ^origin/master\ngit log --oneline 'refs/heads/pu' ^origin/master\n\nYou can pipe this output into sh.\nIf you do not like the idea of generating the shell code, you could give up a bit of robustness* and do this:\nfor branch in $(git for-each-ref --format='%(refname)' refs/heads/); do\n git log --oneline \"$branch\" ^origin/master\ndone\n\n*\nRef names should be safe from the shell’s word splitting (see git-check-ref-format(1)). Personally I would stick with the former version (generated shell code); I am more confident that nothing inappropriate can happen with it.\n\nSince you specified bash and it supports arrays, you could maintain safety and still avoid generating the guts of your loop:\nbranches=()\neval \"$(git for-each-ref --shell --format='branches+=(%(refname))' refs/heads/)\"\nfor branch in \"${branches[@]}\"; do\n # …\ndone\n\nYou could do something similar with $@ if you are not using a shell that supports arrays (set -- to initialize and set -- \"$@\" %(refname) to add elements)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options $GIT_DIR/config.worktree" }, { "role": "assistant", "content": "This is optional and is only searched when extensions.worktreeConfig is present in $GIT_DIR/config." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I create some kind of table of content in GitHub wiki?\n\nIf you look here: http://en.wikipedia.org/wiki/Stack_Overflow\nYou'll notice there's a little \"Content\" section, if you click on one of the links, it will send you to a specific section on the page.\nHow do I do this in GitHub wiki? With Markdown or whatever they use?" }, { "role": "assistant", "content": "It is nicely demonstrated in the Table of Contents of the Markdown Cheatsheet.\n##### Table of Contents \n[Headers](#headers) \n[Emphasis](#emphasis) \n...snip... \n<a name=\"headers\"/>\n## Headers\n\nIf you hover over a Header in a GitHub Markdown file, you'll see a little link sample to the left of it, you can also use that link. The format for that link is <project URL#<header name>. The <header name> must be all lower case." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitignore not working\nMy .gitignore file isn't working for some reason, and no amount of Googling has been able to fix it. Here is what I have:\n*.apk\n*.ap_\n*.dex\n*.class\n**/bin/\n**/gen/\n.gradle/\nbuild/\nlocal.properties\n**/proguard/\n*.log\n\nIt's in the directory master, which is my git repo. I'm running Git 1.8.4.2 because I'm on a MacBook running OSX 10.8.6." }, { "role": "assistant", "content": "The files/folder in your version control will not just delete themselves just because you added them to the .gitignore. They are already in the repository and you have to remove them. You can just do that with this:\nRemember to commit everything you've changed before you do this!\ngit rm -rf --cached .\ngit add .\n\nThis removes all files from the repository and adds them back (this time respecting the rules in your .gitignore)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the correct usage of cache/artifacts in Gitlab CI?\n\nI am facing an issue when cached files are not used in project builds. In my case, I want to download composer dependencies in build stage and then add them into final project folder after all other stages succeeds. I thought that if you set cache attribute into .gitlab-ci.yml file, it will be shared and used in other stages as well. But this sometime works and sometimes not.\nGitlab version is 9.5.4\nHere is my .gitlab-ci.yml file:\nimage: ponk/debian:jessie-ssh\n\nvariables:\n WEBSERVER: \"[email protected]\"\n WEBSERVER_DEPLOY_DIR: \"/domains/example.com/web-presentation/deploy/\"\n WEBSERVER_CDN_DIR: \"/domains/example.com/web-presentation/cdn/\"\n TEST_VENDOR: '[ \"$(ls -A ${WEBSERVER_DEPLOY_DIR}${CI_COMMIT_REF_NAME}/${CI_COMMIT_SHA}/vendor)\" ]'\n\ncache:\n key: $CI_PIPELINE_ID\n untracked: true\n paths:\n - vendor/\n\nbefore_script:\n\n\nstages:\n - build\n - tests\n - deploy\n - post-deploy\n\nBuild sources:\n image: ponk/php5.6\n stage: build\n script:\n # Install composer dependencies\n - composer -n install --no-progress\n only:\n - tags\n - staging\n\n\nDeploy to Webserver:\n stage: deploy\n script:\n - echo \"DEPLOYING TO ... ${WEBSERVER_DEPLOY_DIR}${CI_COMMIT_REF_NAME}/${CI_COMMIT_SHA}\"\n - ssh $WEBSERVER mkdir -p ${WEBSERVER_DEPLOY_DIR}${CI_COMMIT_REF_NAME}/${CI_COMMIT_SHA}\n - rsync -rzha app bin vendor www .htaccess ${WEBSERVER}:${WEBSERVER_DEPLOY_DIR}${CI_COMMIT_REF_NAME}/${CI_COMMIT_SHA}\n - ssh $WEBSERVER '${TEST_VENDOR} && echo \"vendor is not empty, build seems ok\" || exit 1'\n - ssh $WEBSERVER [ -f ${WEBSERVER_DEPLOY_DIR}${CI_COMMIT_REF_NAME}/${CI_COMMIT_SHA}/vendor/autoload.php ] && echo \"vendor/autoload.php exists, build seems ok\" || exit 1\n - echo \"DEPLOYED\"\n only:\n - tags\n - staging\n\nPost Deploy Link PRODUCTION to Webserver:\n stage: post-deploy\n script:\n - echo \"BINDING PRODUCTION\"\n - ssh $WEBSERVER unlink ${WEBSERVER_DEPLOY_DIR}production-latest || true\n - ssh $WEBSERVER ln -s ${WEBSERVER_DEPLOY_DIR}${CI_COMMIT_REF_NAME}/${CI_COMMIT_SHA} ${WEBSERVER_DEPLOY_DIR}production-latest\n - echo \"BOUNDED $CI_COMMIT_SHA -> production-latest\"\n - ssh $WEBSERVER sudo service php5.6-fpm reload\n environment:\n name: production\n url: http://www.example.com\n only:\n - tags\n\nPost Deploy Link STAGING to Webserver:\n stage: post-deploy\n script:\n - echo \"BINDING STAGING\"\n - ssh $WEBSERVER unlink ${WEBSERVER_DEPLOY_DIR}staging-latest || true\n - ssh $WEBSERVER ln -s ${WEBSERVER_DEPLOY_DIR}${CI_COMMIT_REF_NAME}/${CI_COMMIT_SHA} ${WEBSERVER_DEPLOY_DIR}staging-latest\n - echo \"BOUNDED ${CI_COMMIT_SHA} -> staging-latest\"\n - ssh $WEBSERVER sudo service php5.6-fpm reload\n environment:\n name: staging\n url: http://staging.example.com\n only:\n - staging\n\nIn Gitlab documentation it says: cache is used to specify a list of files and directories which should be cached between jobs.\nFrom what I understand I've set up cache correctly - I have untracked set to true, path includes vendor folder and key is set to Pipeline ID, which should be the same in other stages as well.\nI've seen some set ups which contained Artifacts, but unless you use it with Dependencies, it shouldn't have any effect.\nI don't know what I'm doing wrong. I need to download composer dependencies first, so I can copy them via rsync in next stage. Do you have any ideas/solutions? Thanks" }, { "role": "assistant", "content": "Artifacts should be used to permanently make available any files you may need at the end of a pipeline, for example generated binaries, required files for the next stage of the pipeline, coverage reports or maybe even a disk image. But cache should be used to speed up the build process, for example if you compiling a C/C++ binary it usually takes a long time for the first build but subsequent builds are usually faster because it doesn't start from scratch, so if you were to store the temporary files made by the compiler by using cache, it would speed up the compilation across different pipelines. \nSo to answer you, you should use artifacts because you seem to need to run composer every pipeline but want to pass on the files to the next job. You do not need to explicitly define dependencies in your gitlab-ci.yml because if not defined each job pulls all the artifacts from all previous jobs. Cache should work but it is unreliable and is better for a config where it makes it better but is not a necessity." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "bitbucket can't pull/push from repository\nSo basically I have a server where I have bitbucket git repository set up. I've been using it for months and now out of the blue sky when I try to pull I get the following error:\nssh: Could not resolve hostname bitbucket.org: Name or service not known\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nI'm 100% sure I have correctly setup my ssh-keys.\ngit remote -v\norigin [email protected]:marel/tshirtmafia.git (fetch)\norigin [email protected]:marel/tshirtmafia.git (push)\n\nAny suggestions how to fix this ? Please let me know if you need anything else." }, { "role": "assistant", "content": "This issue is caused by incorrect git configuration. \nOpen .git folder in root folder of your project and in config file please find the line that starts with \nurl = [email protected]\nMost probably you have specified protocol there and defined url like \nurl = ssh://[email protected]\nremove ssh:// and it should do the trick for you." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options nestedTag" }, { "role": "assistant", "content": "Shown when a user attempts to recursively tag a tag object." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to do a GitHub pull request\n\nHow do I create and/or send a pull request to another repository hosted on GitHub?" }, { "role": "assistant", "content": "(In addition to the official \"GitHub Help 'Using pull requests' page\",\nsee also \"Forking vs. Branching in GitHub\", \"What is the difference between origin and upstream in GitHub\")\nCouple tips on pull-requests:\nAssuming that you have first forked a repo, here is what you should do in that fork that you own:\n\ncreate a branch: isolate your modifications in a branch. Don't create a pull request from master, where you could be tempted to accumulate and mix several modifications at once.\nrebase that branch: even if you already did a pull request from that branch, rebasing it on top of origin/master (making sure your patch is still working) will update the pull request automagically (no need to click on anything)\nupdate that branch: if your pull request is rejected, you simply can add new commits, and/or redo your history completely: it will activate your existing pull request again.\n\"focus\" that branch: i.e., make its topic \"tight\", don't modify thousands of class and the all app, only add or fix a well-defined feature, keeping the changes small.\ndelete that branch: once accepted, you can safely delete that branch on your fork (and git remote prune origin). The GitHub GUI will propose for you to delete your branch in your pull-request page.\n\nNote: to write the Pull-Request itself, see \"How to write the perfect pull request\" (January 2015, GitHub)\n\nMarch 2016: New PR merge button option: see \"Github squash commits from web interface on pull request after review comments?\".\n\nThe maintainer of the repo can choose to merge --squash those PR commits.\n\nAfter a Pull Request\nRegarding the last point, since April, 10th 2013, \"Redesigned merge button\", the branch is deleted for you:\n\n\nDeleting branches after you merge has also been simplified.\nInstead of confirming the delete with an extra step, we immediately remove the branch when you delete it and provide a convenient link to restore the branch in the event you need it again.\n\nThat confirms the best practice of deleting the branch after merging a pull request.\n\npull-request vs. request-pull\n\npull request isn't an official \"git\" term.\nGit uses the request-pull(!) command to build a request for merging:\nIt \"summarizes the changes between two commits to the standard output, and includes the given URL in the generated summary.\"\nGithub launches its own version on day one (February 2008), but redesigned that feature in May 2010, stating that:\n Pull Request = Compare View + Issues + Commit comments\n\n\n\n\ne-notes for \"reposotory\" (sic)\n<humour>\nThat (pull request) isn't even defined properly by GitHub!\nFortunately, a true business news organization would know, and there is an e-note in order to replace pull-replace by 'e-note':\n\nSo if your reposotory needs a e-note... ask Fox Business. They are in the know.\n</humour>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc -C[<n>] --find-copies[=<n>]" }, { "role": "assistant", "content": "Detect copies as well as renames. See also --find-copies-harder .\nIf n is specified, it has the same meaning as for -M<n> ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Project vs Repository in GitHub\nIn GitHub, what is the conceptual difference between a project (that can be created inside a repository) and a repository? \nI've seen several similar questions (here, here and here) in SO, but none of them explains what is a GitHub project, what is a GitHub repository and when to use each one of them. \nI would appreciate if someone can explain each term, and provide an example of when to use/create each one. For instance, if I have several prototype applications, all independent of each other, what do I create in order to manage in an organized way the source code for all of them?" }, { "role": "assistant", "content": "Fact 1: Projects and Repositories were always synonyms on GitHub.Fact 2: This is no longer the case.\nThere is a lot of confusion about Repositories and Projects. In the past both terms were used pretty much interchangeably by the users and the GitHub's very own documentation. This is reflected by some of the answers and comments here that explain the subtle differences between those terms and when the one was preferred over the other. The difference were always subtle, e.g. like the issue tracker being part of the project but not part of the repository which might be thought of as a strictly git thing etc.\nNot any more.\nCurrently repos and projects refer to a different kinds of entities that have separate APIs:\n\nhttps://developer.github.com/v3/repos/\nhttps://developer.github.com/v3/projects/\n\nSince then it is no longer correct to call the repo a project or vice versa.\nNote that it is often confused in the official documentation and it is unfortunate that a term that was already widely used has been chosen as the name of the new entity but this is the case and we have to live with that.\nThe consequence is that repos and projects are usually confused and every time you read about GitHub projects you have to wonder if it's really about the projects or about repos. Had they chosen some other name or an abbreviation like \"proj\" then we could know that what is discussed is the new type of entity, a precise object with concrete properties, or a general speaking repo-like projectish kind of thingy.\nThe term that is usually unambiguous is \"project board\".\nWhat can we learn from the API\nThe first endpoint in the documentation of the Projects API:\n\nhttps://developer.github.com/v3/projects/#list-repository-projects\n\nis described as: List repository projects. It means that a repository can have many projects. So those two cannot mean the same thing. It includes Response if projects are disabled:\n{\n \"message\": \"Projects are disabled for this repo\",\n \"documentation_url\": \"https://developer.github.com/v3\"\n}\n\nwhich means that some repos can have projects disabled. Again, those cannot be the same thing when a repo can have projects disabled.\nThere are some other interesting endpoints:\n\nCreate a repository project - POST /repos/:owner/:repo/projects\nCreate an organization project - POST /orgs/:org/projects\n\nbut there is no:\n\nCreate a user's project - POST /users/:user/projects\n\nWhich leads us to another difference:\n1. Repositories can belong to users or organizations2. Projects can belong to repositories or organizations\nor, more importantly:\n1. Projects can belong to repositories but not the other way around2. Projects can belong to organizations but not to users3. Repositories can belong to organizations and to users\nSee also:\n\nhttps://help.github.com/articles/about-project-boards/\n\nI know it's confusing. I tried to explain it as precisely as I could." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pushing a local branch up to GitHub\n\nI have Git configured so that when I run git push, it pushes changes to my GitHub repo. Until now I have only had a master branch.\nHowever, I have now created a local branch and committed to it using: \ngit checkout -b my_new_branch\ngit commit\n\nWhat I would like to do now is push my changes on this branch to GitHub. Do I just do a git push?\nWhen I first set it up I did run:\ngit config push.default current" }, { "role": "assistant", "content": "I believe you're looking for git push origin my_new_branch, assuming your origin remote is configured to hit your github repository." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Start ssh-agent on login [closed]\nClosed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n This question does not appear to be about programming within the scope defined in the help center.\n\n\nClosed 3 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI have a site as a remote Git repo pulling from Bitbucket.com using an SSH alias. I can manually start the ssh-agent on my server but I have to do this every time I login via SSH.\nI manually start the ssh-agent:\neval ssh-agent $SHELL\n\nThen I add the agent:\nssh-add ~/.ssh/bitbucket_id\n\nThen it shows up when I do:\nssh-add -l\n\nAnd I'm good to go. Is there any way to automate this process so I don't have to do it every time I login? The server is running RedHat 6.2 (Santiago)." }, { "role": "assistant", "content": "Please go through this article. You may find this very useful:\nhttps://web.archive.org/web/20210506080335/https://mah.everybody.org/docs/ssh\nJust in case the above link vanishes some day, I am capturing the main piece of the solution below:\n\nThis solution from Joseph M. Reagle by way of Daniel Starin:\nAdd this following to your .bash_profile\nSSH_ENV=\"$HOME/.ssh/agent-environment\"\n\nfunction start_agent {\n echo \"Initialising new SSH agent...\"\n /usr/bin/ssh-agent | sed 's/^echo/#echo/' > \"${SSH_ENV}\"\n echo succeeded\n chmod 600 \"${SSH_ENV}\"\n . \"${SSH_ENV}\" > /dev/null\n /usr/bin/ssh-add;\n}\n\n# Source SSH settings, if applicable\n\nif [ -f \"${SSH_ENV}\" ]; then\n . \"${SSH_ENV}\" > /dev/null\n #ps ${SSH_AGENT_PID} doesn't work under cywgin\n ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {\n start_agent;\n }\nelse\n start_agent;\nfi\n\nThis version is especially nice since it will see if you've already started ssh-agent and, if it can't find it, will start it up and store the settings so that they'll be usable the next time you start up a shell." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Delete local Git branches after deleting them on the remote repo\n\nI want to have my local and remote repositories always in sync in terms of branches.\nAfter a Pull Request review on GitHub, I merge and remove my branch there (remote).\nHow could I fetch this information in my local repository and get Git to remove my local version of the branch as well?" }, { "role": "assistant", "content": "The quick way\ngit branch --merged | grep -v \"\\*\" | xargs -n 1 git branch -d\n\nNB: if you're not on master, this has the potential to delete the branch. Keep reading for the \"better way\".\nMake sure we keep master\nYou can ensure that master, or any other branch for that matter, doesn't get removed by greping for more. In that case you would go:\ngit branch --merged | grep -v \"\\*\" | grep -v \"YOUR_BRANCH_TO_KEEP\" | xargs -n 1 git branch -d\n\nSo if we wanted to keep master, develop and staging for instance, we would go:\ngit branch --merged | grep -v \"\\*\" | grep -Ev \"(\\*|master|develop|staging)\" | xargs -n 1 git branch -d\n\nMake this an alias\nSince it's a bit long, you might want to add an alias to your .zshrc or .bashrc. Mine is called gbpurge (for git branches purge):\nalias gbpurge='git branch --merged | grep -Ev \"(\\*|master|develop|staging)\" | xargs -n 1 git branch -d'\n\nThen reload your .bashrc or .zshrc:\n. ~/.bashrc\n\nor\n. ~/.zshrc" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Should I ignore the launchSettings.json file from being committed in Git?\n\nI find this relatively known GitHub repository, where they considered launchSettings.json file (which is used by Visual Studio 2017 for .Net Core projects) is to be ignored.\nhttps://github.com/github/gitignore/blob/master/VisualStudio.gitignore\nWhy should it be ignored? I used always in the company I work in to commit it, I am curious to know if there is any reason to ignore it." }, { "role": "assistant", "content": "launchSettings.json should not be ignored. That repository has since been updated to not ignore it: https://github.com/github/gitignore/pull/2705\n\nReasons for making this change:\nIgnoring launchSettings.json does not make much sense. Now .NET CLI even considers this file when running with dotnet run, as you can read here.\nThis settings will be useful if shared among project members, so it should be commited to the repo.\nLinks to documentation supporting these rule changes:\nhttps://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run?tabs=netcore2x" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "github/git Checkout Returns 'error: invalid path' on Windows\n\nWhen I attempt to checkout a repository from github I get the error:\nerror: invalid path 'configs/perl-modules/DIST.64/perl-HTML-Tree-1:5.03-1.el6.noarch.rpm'\n\nI suspect the issue is that the path contains a : which is illegal on Windows.\nAfter researching the error, I've found 2 possible answers:\n1) Change the path on the repository file. Unfortunately, this is is a team resource and can not be fixed in the foreseeable future. \n2) Use sparse-checkout. I've tried this with no effect as evidenced in the following:\n\n$ git clone -n [email protected]:XXXXXX/deploy.git \nCloning into 'deploy'... \nremote: Enumerating objects: 57, done. \nremote: Counting objects: 100% (57/57), done. \nremote: Compressing objects: 100% (49/49), done. \nremote: Total 86457 (delta 10), reused 22 (delta 8), pack-reused 86400 \nReceiving objects: 100% (86457/86457), 1.50 GiB | 4.73 MiB/s, done. \nResolving deltas: 100% (59779/59779), done. \n$ cd deploy/ \n$ git config core.sparsecheckout true \n$ echo www >> .git/info/sparse-checkout \n$ git checkout centos6 \nerror: invalid path 'configs/perl-modules/DIST.64/perl-HTML-Tree-1:5.03-1.el6.noarch.rpm'\nerror: invalid path 'configs/perlbrew/perls/perl-5.24.1/man/man3/App::Cpan.3'\n.\n. (repeat for many files)\n.\n\nThis was done with Git for Windows \"git version 2.28.0.windows.1\". I have also tried both types of line endings and using various version of .git/info/sparse-checkout such as:\n/*\n!/configs/perl-modules\n!/configs/perlbrew/perls/perl-5.24.1/man/man3\n\nCheckout works fine on Linux, MacOS and WSL, only problem is that my IDEs don't work there. Why isn't sparse-checkout working on Windows. Is there any other possibilities?" }, { "role": "assistant", "content": "After I opened an issue on the git-for-windows bug tracker (https://github.com/git-for-windows/git/issues/2803), I found that my issue had already been filed as https://github.com/git-for-windows/git/issues/2777. That issue suggested that I need to set another git flag:\ngit config core.protectNTFS false\n\nThis (#2777) indeed contains a bypass for the my problem. I hope the git or git-for-windows (who were very responsive) come up with a better warning message, or even a true fix like a filepath mapping scheme.\nNote that this is only an issue when using sparse-checkout with windows." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to find out which release(s) contain a given GIT commit?\nSomeone fixed a bug in HHVM in this commit:\nhttps://github.com/facebook/hhvm/commit/796f986aba300b3f00b9ece0bf654c452ee217be\nI want to know if this commit is already part of the official releases.\nIs there a way to list the releases/tags that contain this commit, either on GitHub, or in a local clone of the GIT repository on my machine?" }, { "role": "assistant", "content": "GitHub now shows you the tags containing a commit automatically when you open a commit (click on the ... to show all tags):" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What goes wrong when using git worktree with git submodules\nI recently discovered the git worktree command:\n\nThe new working directory is linked to the current repository, sharing everything except working directory specific files such as HEAD, index, etc.\n\nBut the docs also indicate \n\n… the support for submodules is incomplete. It is NOT recommended to make multiple checkouts of a superproject.\n\nwithout further explanation as to what goes wrong.\nCan someone enlighten me about the problems to expect? For example, will I be fine if I use the separate worktrees generated this way only for changes that do not affect the submodules?" }, { "role": "assistant", "content": "Commit a83a66a is quite clear about that:\n\ngit-submodule.sh expects $GIT_DIR/config to be per-worktree, at least for the submodule.* part.\n Here I think we have two options:\n\neither update config.c to also read\n $GIT_DIR/config.worktree (which is per worktree) in addition to\n $GIT_DIR/config (shared) and store worktree-specific vars in the new\n place, \nor update git-submodule.sh to read/write submodule.* directly\n from $GIT_DIR/config.submodule (per worktree).\n\nThese take time to address properly. Meanwhile, make a note to the\n user that they should not use multiple worktrees in submodule context.\n\nMore generally, where to put those submodules?\n\nThere are a couple options:\n\nYou may want to keep $SUB repos elsewhere (perhaps in a central\n place) outside $SUPER. This is also true for nested submodules\n where a superproject may be a submodule of another superproject.\nYou may want to keep all $SUB repos in $SUPER/modules (or some\n other place in $SUPER)\nWe could even push it further and merge all $SUB repos into $SUPER\n instead of storing them separately. But that would at least require\n ref namespace enabled.\n\n\nThis commit was an answer to commit df56607.\n\nFrom a git user point of view, that means a git submodule update --init --recursive does not know exactly where to checkout the submodules.\nAre they duplicated across all worktrees, or are they centralized somewhere? This isn't formally specified yet.\n\nA year later (and with git 2.9), clacke adds in the comments\n\nthe confusion has been resolved, but not in an optimal manner.\n Submodules work fine now as far as I can see, but each worktree has its own set of submodule repos (under motherrepo.git/worktree/<worktreename>/modules/<submodule>), so if you have a submodule that's big, you are facing some serious disk usage.\n\n\nGit aliases to handle submodules in subtrees:\n\nhttps://gitlab.com/clacke/gists/blob/0c4a0b6e10f7fbf15127339750a6ff490d9aa3c8/.config/git/config#L11\nhttps://gitlab.com/clacke/gists/blob/0c4a0b6e10f7fbf15127339750a6ff490d9aa3c8/.config/git/config#L12\n\nThe alias git wtas expects that git wta is defined globally, or at least for all the repos involved. No warranty included. Your favorite pet may catch a painful infection if your path names have spaces in them.\nIt expects a structure in your repo like the one in a non-bare repo with submodules initiated, so if you have a bare repo, you'll have to mimic that setup. A submodule with the name (not path) foo goes in <your-.git-directory>/modules/foo (not .../foo.git). It will not crash if some module is not present in the repo, it just skips it.\nThere is room for improvement. It does not handle submodules within submodules, it only goes one level down. It may work to just change the submodule git wta call to a git wtas call, but I haven't verified this yet.\n-- clacke\n\nSee also git worktree move (with Git 2.17+, Q2 2018).\n\nActually, before Git 2.21 (Q1 2019), \"git worktree remove\" and \"git worktree move\" refused to work when there is a submodule involved.\nThis has been loosened to ignore uninitialized submodules.\nSee commit 00a6d4d (05 Jan 2019) by Nguyễn Thái Ngọc Duy (pclouds).\n(Merged by Junio C Hamano -- gitster -- in commit 726f89c, 18 Jan 2019) \n\nworktree: allow to (re)move worktrees with uninitialized submodules\nUninitialized submodules have nothing valuable for us to be worried about. They are just SHA-1.\n Let \"worktree remove\" and \"worktree move\" continue in this case so that people can still use multiple worktrees on repos with optional submodules that are never populated, like sha1collisiondetection in git.git when checked out by doc-diff script.\nNote that for \"worktree remove\", it is possible that a user initializes a submodule (*), makes some commits (but not push), then deinitializes it.\n At that point, the submodule is unpopulated, but the precious new commits are still in:\n$GIT_COMMON_DIR/worktrees/<worktree>/modules/<submodule>\n\ndirectory and we should not allow removing the worktree or we lose those commits forever.\n The new directory check is added to prevent this.\n(*) yes they are screwed anyway by doing this since \"git submodule\"\n would add submodule.* in $GIT_COMMON_DIR/config, which is shared across multiple worktrees.\n But it does not mean we let them be screwed even more.\n\n\nBefore Git 2.25 (Q1 2020), if you had the submodule.recurse config option set, issuing git worktree add in a superproject with initialized submodules would fail. \nSee commit 4782cf2ab6 (27 Oct 2019) by Philippe Blain (phil-blain).\n(Merged by Junio C Hamano -- gitster -- in commit 726f89c, 1 Dec 2019) \n\nworktree: teach \"add\" to ignore submodule.recurse config\n\"worktree add\" internally calls \"reset --hard\", but if\n submodule.recurse is set, reset tries to recurse into\n initialized submodules, which makes start_command try to\n cd into non-existing submodule paths and die.\nFix that by making sure that the call to reset in \"worktree add\"\n does not recurse.\n\nA workaround for earlier versions is to momentarily deactivate the config: \ngit -c submodule.recurse=0 worktree add ...\n\n\nBefore Git 2.26 (Q2 2020), issuing git checkout --recurse-submodules (or reset or read-tree) in a linked worktree of a repo with initialized submodules would incorrectly move the submodule(s) HEAD(s) in the git repository of the main worktree, and clobber the .git gitfile in the working directory of the submodules in the linked worktree: \nSee commit a9472afb63 (21 Jan 2020) by Philippe Blain (phil-blain).\n(Merged by Junio C Hamano -- gitster -- in commit ff5134b2, 5 Fev 2020) \n\nsubmodule.c: use get_git_dir() instead of get_git_common_dir()\nEver since df56607 (git-common-dir: make \"modules/\"\n per-working-directory directory, 2014-11-30), submodules in linked worktrees\n are cloned to $GIT_DIR/modules, i.e. $GIT_COMMON_DIR/worktrees/<name>/modules.\nHowever, this convention was not followed when the worktree updater commands\n checkout, reset and read-tree learned to recurse into submodules. Specifically,\n submodule.c::submodule_move_head, introduced in 6e3c159 (update submodules:\n add submodule_move_head, 2017-03-14) and submodule.c::submodule_unset_core_worktree,\n (re)introduced in 898c2e6 (submodule: unset core.worktree if no working tree\n is present, 2018-12-14) use get_git_common_dir() instead of get_git_dir()\n to get the path of the submodule repository.\nThis means that, for example, 'git checkout --recurse-submodules <branch>'\n in a linked worktree will correctly checkout <branch>, detach the submodule's HEAD\n at the commit recorded in <branch> and update the submodule working tree, but the\n submodule HEAD that will be moved is the one in $GIT_COMMON_DIR/modules/<name>/,\n i.e. the submodule repository of the main superproject working tree.\n It will also rewrite the gitfile in the submodule working tree of the linked worktree\n to point to $GIT_COMMON_DIR/modules/<name>/.\n This leads to an incorrect (and confusing!) state in the submodule working tree\n of the main superproject worktree.\nAdditionally, if switching to a commit where the submodule is not present,\n submodule_unset_core_worktree will be called and will incorrectly remove\n 'core.wortree' from the config file of the submodule in the main superproject worktree,\n $GIT_COMMON_DIR/modules/<name>/config.\nFix this by constructing the path to the submodule repository using get_git_dir()\n in both submodule_move_head and submodule_unset_core_worktree." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to filter GitHub PRs with specific merge date?\n\nI use the below filter to get PRs closed above 2017-03-19; but, is there a way to filter with a specific date.\nis:pr is:closed merged:>=2017-03-19 base:master sort:updated-desc\n\n\nThe below fails:\nis:pr is:closed merged:=2017-03-19 base:master sort:updated-desc" }, { "role": "assistant", "content": "Yes, you can do so by filtering as follows:\nis:pr is:closed merged:2017-03-19..2017-03-19 base:master sort:updated-desc \n\nFor more information concerning searching issues and pull requests in GitHub see Searching issues documentation." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Get all git commits since last tag\nWhen I'm going to tag a commit, I need to know what changed since the last tagged commit. Eg:\na87a6sdf87a6d4 Some new feature\na87a6sdf87a6d3 Some bug fix\na87a6sdf87a6d2 Some comments added\na87a6sdf87a6d1 Some merge <- v1.4.0\n\nIn this example I would like to know about the 3 newest commits, or be able to print a log like above, that shows both commits their tags if any. And when I see there has been a new feature added, I would tag it v1.5.0.\nHow do you deal with this? Is this how I'm supposed to use tags? What should I write in the tag message? I always leave it blank: git tag -a v1.2.3 -m ''" }, { "role": "assistant", "content": "git log <yourlasttag>..HEAD\n\nIf you want them like in your example, on the one line with commit id + message, then\ngit log <yourlasttag>..HEAD --oneline\n\nand in case you don't know your latest tag or want this to be dynamic, on Linux / git bash / Windows bash you could do:\ngit log $(git describe --tags --abbrev=0)..HEAD --oneline\n\nand on Windows:\nfor /f \"delims=\" %a in ('git describe --tags --abbrev^=0') do @set latesttag=%a\ngit log %latesttag%..HEAD --oneline\n\nAlso, if you have a case where you know a tag in history and want to print everything from that tag up to current situation, you might want to add also --decorate so it would print out any tags in between." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Aborting `git stash apply` [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to reverse apply a stash?\n\n (14 answers)\n \n\nClosed 3 years ago.\n\n\n\nI regret having applied a stash (wrong branch). How can I undo this and have my stash back to my stash list in order to apply it later on the right branch?" }, { "role": "assistant", "content": "If you haven't committed, you should just be able to git stash again, possibly with a git reset HEAD first.\nAlso, git stash apply doesn't delete the stash like git stash pop does. So if you have committed, you could git reset --hard [last_good_commit] (if you haven't pushed) or git revert [last_good_commit] (if you have pushed) and just apply the stash again once you're on the right branch.\nNote: Running git reset --hard will delete any uncommitted code." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why does \"git status\" show I'm on the master branch and \"git branch\" does not in a newly created repository?\nI'm trying to automate a process and issue the git branch command to find out what branch I am on. Everything is working fine except for a newly initialized repo where git branch returns nothing. Given I've done nothing with the repo, not even the initial commit, I can accept the answer. However, if I run a git status it tells me I'm on the master branch, as seen here:\n$ mkdir todelete\n$ cd todelete\n$ git init\nInitialized empty Git repository in /u/u70021a/todelete/.git\n$ git status\nOn branch master\n\nNo commits yet\n\nnothing to commit (create/copy files and use \"git add\" to track)\n$ git branch\n$\n\nAm I doing something wrong? Is there some setting I haven't set properly?\nI also have a number of new people to Git and I can't explain to them why the command to show which branch they are on shows nothing, yet the status command does." }, { "role": "assistant", "content": "I upvoted two other answers, but I think the way to think of this is simple: You can be on a branch that doesn't exist. That's normal in a new empty repository, too, because for a branch name to exist, that branch name must identify the hash ID of an existing, valid commit. A new empty repository has no commits, so no branch names are allowed to exist yet.\nNonetheless, you are, initially, on some branch. The branch you are on is the one whose name is stored in the special name HEAD. In a new, empty repository, Git stores the name master (more precisely, refs/heads/master—the full name of the branch) in HEAD, so you are on master, while master does not exist.\nYou can change which non-existent branch you are on using git checkout -b:\n$ git init\nInitialized empty Git repository in [path]\n$ git checkout -b asdf\nSwitched to a new branch 'asdf'\n$ git checkout -b hello\nSwitched to a new branch 'hello'\n\nWhenever you are on a branch that does not exist, the next commit you make creates the branch. This is also how git checkout --orphan works." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-stash - Stash the changes in a dirty working directory away show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]" }, { "role": "assistant", "content": "Show the changes recorded in the stash entry as a diff between the\nstashed contents and the commit back when the stash entry was first\ncreated.\nBy default, the command shows the diffstat, but it will accept any\nformat known to git diff (e.g., git stash show -p stash@{1} to view the second most recent entry in patch form).\nIf no <diff-option> is provided, the default behavior will be given\nby the stash.showStat , and stash.showPatch config variables. You\ncan also use stash.showIncludeUntracked to set whether --include-untracked is enabled by default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is it possible to move/rename files in Git and maintain their history?\nI would like to rename/move a project subtree in Git moving it from\n/project/xyz\n\nto \n/components/xyz\n\nIf I use a plain git mv project components, then all the commit history for the xyz project gets lost. Is there a way to move this such that the history is maintained?" }, { "role": "assistant", "content": "Git detects renames rather than persisting the operation with the commit, so whether you use git mv or mv doesn't matter, as long as the move operation is committed separately from any changes to the file.\nThe log command takes a --follow argument that continues history before a rename operation, i.e., it searches for similar content using heuristics.\nTo lookup the full history, use the following command:\ngit log --follow ./path/to/file" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes notes.rewriteMode" }, { "role": "assistant", "content": "When copying notes during a rewrite (see the\n\"notes.rewrite.<command>\" option), determines what to do if\nthe target commit already has a note. Must be one of overwrite , concatenate , cat_sort_uniq , or ignore .\nDefaults to concatenate . This setting can be overridden with the GIT_NOTES_REWRITE_MODE environment variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a git-merge --dry-run option?\nI'm merging in a remote branch that may have a lot of conflicts. How can I tell if it will have conflicts or not?\nI don't see anything like a --dry-run on git-merge." }, { "role": "assistant", "content": "As noted previously, pass in the --no-commit flag, but to avoid a fast-forward commit, also pass in --no-ff, like so:\n$ git merge --no-commit --no-ff $BRANCH\n\nTo examine the staged changes:\n$ git diff --cached\n\nAnd you can undo the merge, even if it is a fast-forward merge:\n$ git merge --abort" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-format-patch - Prepare patches for e-mail submission -b --ignore-space-change" }, { "role": "assistant", "content": "Ignore changes in amount of whitespace. This ignores whitespace\nat line end, and considers all other sequences of one or\nmore whitespace characters to be equivalent." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Upload images to GitHub from the browser\n\nI am using GitHub Pages, Jekyll, and Prose to manage a Website. Everything works fine, besides I cannot find a way to upload images. The Prose image uploader is not working probably as discussed in various tickets (for instance here). \nSince the Website is for a friend without any git or command line experience, I am looking for another option to upload images easily from the browser to GitHub. Are there any other options like this? \nI don't want to host the image on an external site." }, { "role": "assistant", "content": "It is possible to upload the images from the browser, without using Git.\nCreate a new GitHub issue and drag the image into the textbox.\nGitHub will upload the image and create a link like this one:\nhttps://f.cloud.github.com/assets/19977/1656110/a3f8b280-5b6d-11e3-818d-c06ab05bd613.jpg\nSource: GitHub's Phil Haack" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git pushes with wrong user from terminal\n\nI have an issue with git and my terminal. Here's a gallery to show you my issue.\nWhen I push commits from my terminal, git says I push them with another username, that's a user from my organization (my company) with no commit at all and it seems it belongs to no one : (check gallery first pic)\nBut this doesn't happen when I use Github for mac, in the feed I see the commits pushed by myself.\nThe problem also affects my personal repositories, my terminal says that I don't have the permission to push commits on those repositories (which is obviously wrong) since it tries to push it with this user : (check gallery second pic)\nGuess what ? This doesn't happen with Github for mac too.\nI changed my computer to a brand new one few days ago, so I reset'ed all my ssh key of github and left only a new one generated by Github for Mac so I don't think that there's some ghost user/ssh key hidden somewhere, this hdd is brand new : (check gallery third pic)\nMy .gitconfig file is all clear, there's only my credentials : (check gallery fourth pic)\nI really don't get it, help, StackOverflow, you're my only hope.\n(My apologies for my poor Gimp skills and the Star Wars reference)\nEDIT : ssh-add -l only shows the good ssh key created by github for mac and I have only one github account\nEDIT2 : ssh -T [email protected] recognize me as the good user.\nEDIT3 : After a few tests it looks like my terminal does the commits with my username, but pushes them with the other one, Github for mac commits and pushes with the good username.This situation happen with every repo I have/make (even new ones).\nEDIT4 : In a personal repository git log --pretty=\"%h %an %ae\" shows my good username\nEDIT5 : No sign of environment variables that would override my credentials in my env. Even if I try to set those variables with the good credentials problem persists.\nEDIT6 : Things work back normally if I force the user in the path of /.git/config of a repository but I don't think that's the good option : http://[email protected]/USER/REPO.git\nEDIT7 : We deleted the git user that pushed the commits for me and this brings another error : remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/USER/REPO.git/'\nFINAL EDIT : I installed git with homebrew, typed git config --global push.default simple and now it takes my credentials even without forceing the user. That's strange. Thanks everybody for your help, you're great guys !" }, { "role": "assistant", "content": "I just had this problem at work. The builtin git that ships with mac or comes when you install xcode caches git credentials in keychain. The fix for me was to:\nstart keychain access (start spotlight via cmd + space, type keychain, press enter)\nUnder keychains on the upper left, select \"login\"\nUnder category on the left, select \"passwords\"\nfind the name \"github\" and delete it." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip --no-verify" }, { "role": "assistant", "content": "This option bypasses the pre-rebase hook. See also githooks ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Show the original branch for a commit\nI've used git-blame to find a particular commit. Now I want to find the branch that it originally came from. (From there, I'll use the branch name to find the particular ticket)\nLet's define \"original branch\" as \"the branch to which the commit was made before the branch was merged into any other branch\"." }, { "role": "assistant", "content": "Like the others said, if the branch you are looking for isn't local to the repository on which you are blaming this commit (e.g. a branch only in the personal repo of a distant developer), you are screwed.\nBut assuming that sought-after branch is something you can see, and that of course you have the commit's hash, say d590f2..., a partial answer is that you can do :\n$ git branch --contains d590f2\n tests\n* master\n\nThen, just to confirm you have the culprit:\n$ git rev-list tests | grep d590f2\n\nOf course, if d590f2 has been merged in more than one branch, you will have to be more subtle than this." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Very slow download from GitHub\n\nWhen cloning a repository from GitHub I sometimes only get a download rate between 50-100 KiB/sec (staying stable) while most of the time I have about 10 MiB/sec. When cloning the same repository from a different machine (= different global IP) I get full speed.\nDoes GitHub impose a rate limit on repository cloning? The repository in question is quite big (~100 MiB) and I clone it about twice a day." }, { "role": "assistant", "content": "I found a solution that worked very well for me.\nGo to github and copy the link to the clipboard.\nThen open a web proxy website (https://www.proxysite.com worked for me).\nAnd paste the link (I tried with US1) - instead of downloading 670mb in 1+ hour at least, it took less than 2 minutes.\nWorks like a charm!!" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to embed a video into GitHub README.md?\n\nIs it possible to embed a flash video into README.md on GitHub? It isn't showing up: https://github.com/mattdipasquale/PicSciP" }, { "role": "assistant", "content": "Add a url to video file in your ReadMe.\nGithub now supports videos, see more detailed answer here: https://stackoverflow.com/a/4279746/1092815\nYou can see a live example here (See at the end of the readme):\nhttps://github.com/alelievr/Mixture/blob/0.4.0/README.md\nGithub Pages\nI strongly recommend placing the video in a project website created with GitHub Pages instead of the readme, like described in VonC's answer; it will be a lot better than any of these ideas. But if you need a quick fix just like I needed, here are some suggestions.\nUse a gif\nSee aloisdg's answer, result is awesome, gifs are rendered on github's readme ;)\nUse a video player picture\nYou could trick the user into thinking the video is on the readme page with a picture. It sounds like an ad trick, it's not perfect, but it works and it's funny ;).\nExample:\n[![Watch the video](https://i.sstatic.net/Vp2cE.png)](https://youtu.be/vt5fpE0bzSY)\n\nResult:\n\nUse youtube's preview picture\nYou can also use the picture generated by youtube for your video.\nFor youtube urls in the form of:\nhttps://www.youtube.com/watch?v=<VIDEO ID>\nhttps://youtu.be/<VIDEO ID>\n\nThe preview urls are in the form of:\nhttps://img.youtube.com/vi/<VIDEO ID>/maxresdefault.jpg\nhttps://img.youtube.com/vi/<VIDEO ID>/hqdefault.jpg\n\nExample:\n[![Watch the video](https://img.youtube.com/vi/T-D1KVIuvjA/maxresdefault.jpg)](https://youtu.be/T-D1KVIuvjA)\n\nResult:\n\nUse asciinema\nIf your use case is something that runs in a terminal, asciinema lets you record a terminal session and has nice markdown embedding.\nHit the share button and copy the markdown snippet.\nExample:\n[![asciicast](https://asciinema.org/a/113463.png)](https://asciinema.org/a/113463)\n\nResult:" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "difference between fork and branch on github\n\nIf I fork a project that's hosted on github. Do I fork all the branches? How do I know which branch my fork is based on? In other words which branch will be downloaded to my PC?" }, { "role": "assistant", "content": "Think of it this way:\nThe repo[sitory] corresponds to the collaborated work of the team across one or many branches. All contributors have their own copy of it.\nEach fork of the main repo corresponds to a contributor's work. A fork is really a Github (not Git) construct to store a clone of the repo in your user account. As a clone, it will contain all the branches in the main repo at the time you made the fork.\nEach branch within the fork and/or in the main repo can correspond to several kinds of things, depending on how you want to work. Each branch could refer to a version of the project but can also correspond to different channels of development, like hotfixes or experimental work.\nThe pull request (in the GitHub ecosystem) corresponds to the task. Every time I want to contribute an isolated finished task to the main repo, I create a pull request corresponding to the commits made in that task. These commits are pulled from either my fork or my branch to the main repo.\nA commit is a set of changes to the code. This is one of the most interesting things about Git. You don't transfer files, you transfer logs of changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What if two Git repositories share common code\nI have a project which has client and server parts. I would like the client and the server code to be in different Git repositories for clear separation of the code, however, they share some files and ideally, the shared files will always be identical in both client and server.\nHow should I go about this? Is it better to have the third repository for the common code?" }, { "role": "assistant", "content": "I will not give advice on “How you should go about this”. But I'll explain how to accomplish integrating a third repository with common code into the other repositories: This is a job for git submodules. git submodules allow you to reference a snapshot of a git repository at a specified path:\ngit submodule add git://example.com/repository.git path\n\nAfterwards create a commit. Now a snapshot of the given repository is referenced at path.\nPopulating the submodule\n\nExecute git submodule init\nExecute git submodule update\n\nEvery configured submodule will be updated to match the state it is supposed to look like.\nUpdating a submodule to a later commit\n\nChange into the directory of the submodule\nPerform a git pull / git fetch + git checkout to update the submodule to the desired commit / tag\nCreate a new commit to update the commit in the .gitmodules file\n\nTake a look at the official manual for further information on submodules." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to change the fork that a repository is linked to\nI have a repo called at MAIN/repo.git and I've forked it to FORK/repo.git. I have both of these repos cloned onto my computer for different purposes. \nUsing Github for Windows, a bug seems to have switched FORK/repo.git over to MAIN/repo.git, as when I do git remote show origin, the Fetch URL and Push URL are set to the main repo. How can I switch this back so the corresponding folder on my local machine points to FORK/repo.git, instead of MAIN/repo.git?" }, { "role": "assistant", "content": "2023: gh repo fork allows since gh v2.37.0 to set default repo when forking repo.\nNow, If the repository is a fork, its parent repository will be set as the default remote repository. See issue 6827 and PR 7768, plus gh repo set-default.\n\n2012: The easiest way would be using command-line git remote, from within your local clone of FORK:\ngit remote rm origin\ngit remote add origin https://github.com/user/FORK.git\n\nOr, in one command, as illustrated in this GitHub article:\ngit remote set-url origin https://github.com/user/FORK.git\n\n\nA better practice is to:\n\nkeep a remote referencing the original repo\nmake your work in new branches (which will have upstream branches tracking your fork)\n\nSo:\ngit remote rename origin upstream\ngit branch -avv # existing branches like master are linked to upstream/xxx\n\ngit remote add origin https://github.com/user/FORK.git\ngit checkout -b newFeatureBranch\n\nWhenever you need to update your fork based on the recent evolution of the original repo:\ngit checkout master\ngit pull # it pulls from upstream!\ngit checkout newFeatureBranch\ngit rebase master # safe if you are alone working on that branch\ngit push --force # ditto. It pushes to origin, which is your fork." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Equivalent in git of \"hg cat\" or \"svn cat\"\nI want to extract a copy of the latest version of a file held in a git repository, and pass it into a script for some processing. With svn or hg, I just use the \"cat\" command:\n\nPrint the specified files as they were at the given revision. If\n no revision is given, the parent of the working directory is used,\n or tip if no revision is checked out.\n\n(that's from the description of hg cat in the hg documentation)\nWhat's the equivalent command to do this with git?" }, { "role": "assistant", "content": "git show rev:path/to/file\n\nWhere rev is the revision.\nSee http://git.or.cz/course/svn.html for a comparison of git and svn commands." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options pack.writeBitmapHashCache" }, { "role": "assistant", "content": "When true, git will include a \"hash cache\" section in the bitmap\nindex (if one is written). This cache can be used to feed git’s\ndelta heuristics, potentially leading to better deltas between\nbitmapped and non-bitmapped objects (e.g., when serving a fetch\nbetween an older, bitmapped pack and objects that have been\npushed since the last gc). The downside is that it consumes 4\nbytes per object of disk space. Defaults to true. When writing a multi-pack reachability bitmap, no new namehashes are\ncomputed; instead, any namehashes stored in an existing bitmap are\npermuted into their appropriate location when writing a new bitmap." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - skipping specific commits when merging\nI've been using Git for about a year now and think it's fantastic, but I've just started on a second version of the project and started a new branch for it. I'm struggling a little with the best way to handle things going forward.\nI have two branches called say master10 (for v1) and master20 (for v2). I've been making bug fixes in v1 on branch master10, and developing new stuff of master20. Whenever I make a bug fix I merge it into v2 by checking out master20 and doing git merge master10. So far so good.\nNow however, I've made a change in v1 that I don't want in v2, but I want to continue merging other bug fixes. How do I tell Git to skip that particular commit (or a range of commits), but that going forward I still want to merge other bug fixes.\nI thought git rebase might be what I need but read the doc and my head nearly exploded.\nI think what I want is something like a \"git sync\" command that tells git that two branches are now in-sync and in future only merge the commits from this sync-point on.\nAny help appreciated." }, { "role": "assistant", "content": "If you want to merge most but not all of the commits on branch \"maint\" to \"master\", for instance, you can do this. It requires some work---- as mentioned above, the usual use case is to merge everything from a branch--- but sometimes it happens that you made a change to a release version that shouldn't be integrated back (maybe that code's been superceded in master already), so how do you represent that? Here goes...\nSo let's suppose maint has had 5 changes applied, and one of those (maint~3) is not to be merged back into master, although all the others should be. You do this in three stages: actually merge everything before that one, tell git to mark maint~3 as merged even when it isn't, and then merge the rest. The magic is:\nbash <master>$ git merge maint~4\nbash <master>$ git merge -s ours maint~3\nbash <master>$ git merge maint\n\nThe first command merges everything before your troublesome maint commit onto master. The default merge log message will explain you're merging \"branch 'maint' (early part)\".\nThe second command merges the troublesome maint~3 commit, but the \"-s ours\" option tells git to use a special \"merge strategy\" which, in fact, works by simply keeping the tree you are merging into and ignoring the commit(s) you are merging completely. But it does still make a new merge commit with HEAD and maint~3 as the parents, so the revision graph now says that maint~3 is merged. So in fact you probably want to use the -m option to git merge as well, to explain that that maint~3 commit is actually being ignored!\nThe final command simply merges the rest of maint (maint~2..maint) into master so that you're all synced up again." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Gitlab CI - How to trigger a build only if changes happen on particular set of files\nIn Gitlab CI, how do you trigger a build only if changes happen on particular set of files?\nIs there a way to either include or exclude certain files from triggering a build? For eg: updating README.md, .gitignore files should not cause a build to trigger." }, { "role": "assistant", "content": "UPDATE 2\nOnly/except seem to be an unstable feature. The doc recommends using rules:changes instead:\njob:\n script:\n - build # replace with your build command\n rules:\n - changes:\n - /*.{java, py} # ... or whatever your file extension is\n - dockerfiles/**/* # all files under folder 'dockerfiles'\n\nUPDATE 1:\nLike Gajus mentioned in the comments, it is now possible!\nMerge Request: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21981\nDocumentation: https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic (Thanks to Connor Shea for the tip in the comments)\nOriginal post:\nNo, it is not possible – not now!\nI think this is the issue you are looking for: https://gitlab.com/gitlab-org/gitlab-ce/issues/19232 – It is a very high rated issue (over 100 thumps-up).\nThe milestone has changed to Next 3-6 months, 4 months ago. (https://gitlab.com/gitlab-org/gitlab-ce/issues/19232#note_31943850)\nI hope we will see this function soon." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git refuses to reset/discard files\nI have a project with certain js files which I cannot update. I run OSX locally and my remote/staging server is Linux (CentOS).\nRight after cloning my project locally, i noticed I have all those files with git status modified. I never modified them, so I tried to discard changes or reset them, but they come up again. The change that is in the modification is deleting all lines and adding them again. \nI'm not sure why this happens or how to fix it so that my git status is clean as it needs to be.\nHere is a few lines from the git status:\n# modified: app/webroot/js/ckeditor/plugins/devtools/lang/el.js\n# modified: app/webroot/js/ckeditor/plugins/devtools/lang/fa.js\n# modified: app/webroot/js/ckeditor/plugins/devtools/lang/gu.js\n\nUPDATE 1: \nI have now managed to commit the above files, but the staging server is locked because it won't pull new edits:\nerror: Your local changes to the following files would be overwritten by merge:\n app/webroot/js/ckeditor/_source/lang/ar.js\n app/webroot/js/ckeditor/_source/lang/bg.js\n app/webroot/js/ckeditor/_source/lang/bn.js\n app/webroot/js/ckeditor/_source/lang/cs.js\n ...\nAborting\n\nI can't commit/push because:\nUpdates were rejected because a pushed branch tip is behind its remote counterpart\n\nI tried:\ngit reset --hard\n\nand\ngit stash\ngit stash drop\n\nBut they don't work, nothing happens.\nUPDATE 2:\ngit diff gives me:\nThe file will have its original line endings in your working directory.\nwarning: CRLF will be replaced by LF in app/webroot/js/ckeditor/_source/lang/fa.js.\nThe file will have its original line endings in your working directory.\nwarning: CRLF will be replaced by LF in app/webroot/js/ckeditor/_source/lang/gu.js.\nThe file will have its original line endings in your working directory.\n..." }, { "role": "assistant", "content": "Normalize line endings\n\nThe change that is in the modification is deleting all lines and adding them again.\n\nThis is because the newlines are being changed between the committed files and the files on disk.\nGithub has a handy page detailing how to deal with this kind of problem, in brief (for linux/OSX), step one is to change your git config so it sorts out the line endings for you:\ngit config --global core.autocrlf input\n\nThen commit line-endings normalization:\ngit rm --cached -r .\n# Remove everything from the index.\n\ngit reset --hard\n# Write both the index and working directory from git's database.\n\ngit add .\n# Prepare to make a commit by staging all the files that will get normalized.\n# This is your chance to inspect which files were never normalized. You should\n# get lots of messages like: \"warning: CRLF will be replaced by LF in file.\"\n\ngit commit -m \"Normalize line endings\"\n# Commit\n\nAnd then, line endings should be handled correctly. See the help page on github for more information, or the relevant section of the git docs formatting and whitespace.\nResolving linux-machine conflicts\n\nthe staging server is locked because it won't pull new edits.\n\nThe error message reads \"Your local changes to the following files would be overwritten by merge:\", that means they contain local changes which should either be committed or discarded before continuing. Assuming normal usage for the staging server (it doesn't have any intentional changes) the local changes can be discarded. For example do the following:\n$ git fetch origin\n# Retrieve updates\n\n$ git reset --hard origin/master\n# Forcibly change the current branch to match origin/master\n\nThis will retrieve the repository history, without updating the working copy, and then update to exactly match the master branch in the repository. Note that the last command will discard all uncommitted changes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git revert <hash> not allowed due to a merge but no -m option was given\nI am trying to revert to a certain 'hash' number in git, by using the 'revert' command.\nI am using the following command:\ngit revert c14609d74eec3ccebafc73fa875ec58445471765\n\nBut, I am getting the following returned:\n\nerror: Commit c14609d74eec3ccebafc73fa875ec58445471765 is a merge but no -m option was given.\nfatal: revert failed\n\nWhat is happening & what should be done to resolve this?\n\nI want to revert back to this certain commit (c14609d74eec3ccebafc73fa875ec58445471765) that I see when running git log." }, { "role": "assistant", "content": "You are trying to revert a merge commit, and git doesn't know which parent to revert to. The -m allows us to choose which parent to choose. See the merge commit and note down which parent you want to go to. The parent information can be seen in git log, for example:\n\ncommit d02ee0f2179def10277f30c71c5d6f59ded3c595\nMerge: dd3a24c 2462a52\n\nand run:\ngit revert <hash> -m 1\n\nwhere 1 indicates parent number 1 (dd3a24c).\nIf you are trying to revert to that commit, do:\ngit reset --hard <hash>\n\nUnderstand the difference between git revert and git reset from the docs and decide which one you want. git revert is the safer option, but doesn't really do what you want. It just reverts the changes of a (set of) commit. git reset makes you move to a particular commit in history, and will rewrite your history." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-receive-pack" }, { "role": "assistant", "content": "Receive what is pushed into the repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options mergetool.<tool>.trustExitCode" }, { "role": "assistant", "content": "For a custom merge command, specify whether the exit code of\nthe merge command can be used to determine whether the merge was\nsuccessful. If this is not set to true then the merge target file\ntimestamp is checked, and the merge is assumed to have been successful\nif the file has been updated; otherwise, the user is prompted to\nindicate the success of the merge." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers" }, { "role": "assistant", "content": "DESCRIPTION This program is usually not what the end user wants to run directly.\nMost end users want to use one of the existing frontend programs,\nwhich parses a specific type of foreign source and feeds the contents\nstored there to git fast-import . fast-import reads a mixed command/data stream from standard input and\nwrites one or more packfiles directly into the current repository.\nWhen EOF is received on standard input, fast import writes out\nupdated branch and tag refs, fully updating the current repository\nwith the newly imported data. The fast-import backend itself can import into an empty repository (one that\nhas already been initialized by git init ) or incrementally\nupdate an existing populated repository. Whether or not incremental\nimports are supported from a particular foreign source depends on\nthe frontend program in use." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can git do a diff of the working copy with stash\nHow can I diff my current working copy against a stash?\nMy use case: my working copy already contains a subset of the changes in my stash@{0}, but I don't want to apply all the changes in stash@{0}. I want to do a diff to help determine which desirable changes in stash@{0} are still missing from my working copy." }, { "role": "assistant", "content": "If it was your most recent stash, git diff stash@{0} will do it. If not, you can use git stash list to get the index of which stash you want to compare to.\nTo see the difference between the actual working copy and the stash you would need to commit it first. You could then rollback the commit.\ngit add -A <- Add all the files\ngit commit -m \"temp\" <- commit them\ngit diff stash@{0}..HEAD <- diff the commit with your stash\ngit reset HEAD~ <- roll your commit back" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --placeholder-filename=<filename>" }, { "role": "assistant", "content": "Set the name of placeholder files created by --preserve-empty-dirs.\nDefault: \".gitignore\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git fails when pushing commit to github\n\nI cloned a git repo that I have hosted on github to my laptop. I was able to successfully push a couple of commits to github without problem. However, now I get the following error: \nCompressing objects: 100% (792/792), done.\nerror: RPC failed; result=22, HTTP code = 411\nWriting objects: 100% (1148/1148), 18.79 MiB | 13.81 MiB/s, done.\nTotal 1148 (delta 356), reused 944 (delta 214)\n\nFrom here it just hangs and I finally have to CTRL + C back to the terminal." }, { "role": "assistant", "content": "I had the same issue and believe that it has to do with the size of the repo (edited- or the size of a particular file) you are trying to push.\nBasically I was able to create new repos and push them to github. But an existing one would not work.\nThe HTTP error code seems to back me up it is a 'Length Required' error. So maybe it is too large to calc or greated that the max. Who knows.\nEDIT\n\nI found that the problem may be\nfiles that are large. I had one update\nthat would not push even though I had\nsuccessful pushes up to that point.\nThere was only one file in the commit\nbut it happened to be 1.6M\nSo I added the following config change\ngit config http.postBuffer 524288000\n\nTo allow up to the file size 500M and\nthen my push worked. It may have been\nthat this was the problem initially\nwith pushing a big repo over the http\nprotocol.\n\nEND EDIT\nthe way I could get it to work (EDIT before I modified postBuffer) was to tar up my repo, copy it to a machine that can do git over ssh, and push it to github. Then when you try to do a push/pull from the original server it should work over https. (since it is a much smaller amount of data than an original push)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --ignore-submodules[=<when>]" }, { "role": "assistant", "content": "Ignore changes to submodules in the diff generation. <when> can be\neither \"none\", \"untracked\", \"dirty\" or \"all\", which is the default.\nUsing \"none\" will consider the submodule modified when it either contains\nuntracked or modified files or its HEAD differs from the commit recorded\nin the superproject and can be used to override any settings of the ignore option in git-config or gitmodules . When\n\"untracked\" is used submodules are not considered dirty when they only\ncontain untracked content (but they are still scanned for modified\ncontent). Using \"dirty\" ignores all changes to the work tree of submodules,\nonly changes to the commits stored in the superproject are shown (this was\nthe behavior until 1.7.0). Using \"all\" hides all changes to submodules." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Which commit has this blob?\nGiven the hash of a blob, is there a way to get a list of commits that have this blob in their tree?" }, { "role": "assistant", "content": "Both of the following scripts take the blob’s SHA1 as the first argument, and after it, optionally, any arguments that git log will understand. E.g. --all to search in all branches instead of just the current one, or -g to search in the reflog, or whatever else you fancy.\nHere it is as a shell script – short and sweet, but slow:\n#!/bin/sh\nobj_name=\"$1\"\nshift\ngit log \"$@\" --pretty=tformat:'%T %h %s' \\\n| while read tree commit subject ; do\n if git ls-tree -r $tree | grep -q \"$obj_name\" ; then\n echo $commit \"$subject\"\n fi\ndone\n\nAnd an optimised version in Perl, still quite short but much faster:\n#!/usr/bin/perl\nuse 5.008;\nuse strict;\nuse Memoize;\n\nmy $obj_name;\n\nsub check_tree {\n my ( $tree ) = @_;\n my @subtree;\n\n {\n open my $ls_tree, '-|', git => 'ls-tree' => $tree\n or die \"Couldn't open pipe to git-ls-tree: $!\\n\";\n\n while ( <$ls_tree> ) {\n /\\A[0-7]{6} (\\S+) (\\S+)/\n or die \"unexpected git-ls-tree output\";\n return 1 if $2 eq $obj_name;\n push @subtree, $2 if $1 eq 'tree';\n }\n }\n\n check_tree( $_ ) && return 1 for @subtree;\n\n return;\n}\n\nmemoize 'check_tree';\n\ndie \"usage: git-find-blob <blob> [<git-log arguments ...>]\\n\"\n if not @ARGV;\n\nmy $obj_short = shift @ARGV;\n$obj_name = do {\n local $ENV{'OBJ_NAME'} = $obj_short;\n `git rev-parse --verify \\$OBJ_NAME`;\n} or die \"Couldn't parse $obj_short: $!\\n\";\nchomp $obj_name;\n\nopen my $log, '-|', git => log => @ARGV, '--pretty=format:%T %h %s'\n or die \"Couldn't open pipe to git-log: $!\\n\";\n\nwhile ( <$log> ) {\n chomp;\n my ( $tree, $commit, $subject ) = split \" \", $_, 3;\n print \"$commit $subject\\n\" if check_tree( $tree );\n}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options git diff HEAD" }, { "role": "assistant", "content": "compares a (c)ommit and the (w)ork tree;" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to use Bitbucket and GitHub at the same time for one project?\n\nI have one repository which I want to push into Bitbucket and GitHub.\nIt is vital for my repository to be hosted by both.\nIs there a way to do this in Git?" }, { "role": "assistant", "content": "You can use multiple remote repositories with git. But you'll have to push separately into 2 of your remotes I believe.\nFor example, if your project currently points to github, you can rename your current remote repository to github:\n$ git remote rename origin github\n\nYou can then add another remote repository, say bitbucket:\n$ git remote add bitbucket [email protected]:your_user/your_repo.git\n\nNow in order to push changes to corresponding branch on github or bitbucket you can do this:\n$ git push github HEAD\n$ git push bitbucket HEAD\n\nSame rule applies to pulling: you need to specify which remote you want to pull from:\n$ git pull github your_branch\n$ git pull bitbucket your_branch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I push to a pull request on github?\nI've added this to my .git/config file:\nfetch = +refs/pull/*/head:refs/remotes/origin/pr/*\n\nWhich allows me to pull down pull request diffs, but when I check it out it actually creates a branch with that same name. Is there any way for me to push to pr/2 and have it actually go to the pull request instead of going to a new branch named pr/2?" }, { "role": "assistant", "content": "Here are GitHub's \"Merging via command line\" instructions for pull requests (I am fulldecent, the other guy is ospr):\nStep 1: From your project repository, check out a new branch and test the changes.\ngit checkout -b ospr-image-rendering master\ngit pull https://github.com/ospr/FDWaveformView.git ospr-image-rendering\n\nStep 2: Merge the changes and update on GitHub.\ngit checkout master\ngit merge --no-ff ospr-image-rendering\ngit push origin master\n\n\nHere is the additional step that sends your changes back upstream(?) to the PR originator.\ngit push https://github.com/ospr/FDWaveformView.git ospr-image-rendering:image-rendering" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-for-each-ref - Output information on each ref ahead-behind:<committish>" }, { "role": "assistant", "content": "Two integers, separated by a space, demonstrating the number of\ncommits ahead and behind, respectively, when comparing the output\nref to the <committish> specified in the format." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I properly remove sensitive data pushed to a Git repo?\n\nI pushed a file containing a password to my repo by mistake - FYI the repo is just a small personal project.\nOnce I realised the password was present I added the file to .gitignore and executed git rm -r --cached <filename>, committed and pushed to the repo.\nI now realise the password is still present in the history - what is the best way to remove it?\nI read the Remove sensitive data page on Github which suggests changing the password - which I have done - but I would like to remove the history as well." }, { "role": "assistant", "content": "Since you have already made 5 commits since the commit containing the clear text password, you best bet is to do a git rebase -i in interactive mode on your local branch. Find the SHA-1 of the commit where you added the clear text password, and type the following:\ngit rebase --interactive dba507c^\n\nwhere dba507c are the first 7 characters of the SHA-1 for the bad commit.\nChange this:\npick dba507c comment for commit containing clear text password\n\nTo this:\nedit dba507c I have removed the clear text password\n\nMake the change to the password file to remove the clear text, then commit your result like this:\ngit commit --all --amend --no-edit\ngit rebase --continue\n\nFinish the rebase, then push your (correct) local branch to the remote via:\ngit push -f origin your_branch\n\nYou will need to force push your_branch because you have rewritten history (by modifying the password file). Now you have all your latest commits, but you have removed the clear text." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-worktree - Manage multiple working trees -v --verbose" }, { "role": "assistant", "content": "With prune , report all removals. With list , output additional information about worktrees (see below)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker <old|new>-hex" }, { "role": "assistant", "content": "are the 40-hexdigit SHA-1 hashes," } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern -r --recursive" }, { "role": "assistant", "content": "Same as --max-depth=-1 ; this is the default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to add license to an existing GitHub project\n\nWhen I created a GitHub project I chose None.\nHow can I now add a GPL license to my already added project?" }, { "role": "assistant", "content": "In your repository, click 'Create new file'\n\n\n\n2.\n a) Type 'LICENSE', 'LICENSE.md' or 'LICENSE.txt' as the new file's file name. \n b) The 'Want to use a new template?' dialog will appear. \n\n\n\nChoose your preferred license. \n\n\nThe accepted answer is almost there, but confused me, because it said 'click the blue plus' - the interface may have changed - and the image is the same as the OP's." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Add image with link in Github's README.md?\n\nHow to add an image that is also a link to an external page on Github's README.md?\nAdding a markdown to display an image is pretty simple (answer at Add images to README.md on GitHub). Adding a link is also pretty simple (GitHub relative link in Markdown file), but it seems there's is no way to add an image that is also a link to an external site.\n<a href=\"https://stackoverflow.com/\"><img src=\"RELATIVE_PATH_TO_IMAGE></img></a>" }, { "role": "assistant", "content": "Try simply the syntax:\n\n2020: [![name](link to image on GH)](link to your URL)\n2023: [<img src=\"path/to/image.png\">](https://link-to-your-URL/),\nsee my README as an example, from commit a932f85.\nSyntax from DaCuteRaccoon's answer.\n\nThat will wrap the image as a link" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --parseopt" }, { "role": "assistant", "content": "Use git rev-parse in option parsing mode (see PARSEOPT section below)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together merge.verbosity" }, { "role": "assistant", "content": "Controls the amount of output shown by the recursive merge\nstrategy. Level 0 outputs nothing except a final error\nmessage if conflicts were detected. Level 1 outputs only\nconflicts, 2 outputs conflicts and file changes. Level 5 and\nabove outputs debugging information. The default is level 2.\nCan be overridden by the GIT_MERGE_VERBOSITY environment variable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs on, m" }, { "role": "assistant", "content": "Make diff output for merge commits to be shown in the default\nformat. The default format can be changed using log.diffMerges configuration variable, whose default value\nis separate ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why can't Git Bash run my executable?\nI am on git-for-windows Git Bash. I can't run an executable on the command line: \nPedr@Abc-07 MINGW64 /c/dev\n$ ls sqlite3.exe\nsqlite3.exe*\n\nPedr@Abc-07 MINGW64 /c/dev\n$ sqlite3\nbash: sqlite3: command not found\n\nWhy is it so?" }, { "role": "assistant", "content": "To run a program in the current directory in bash, you put ./ in front of it. So in your case:\n$ ./sqlite3.exe\n\nWhen you run sqlite3, bash will look for a program with exactly that name in all directories of the PATH environment variable, which by default includes standard locations for executables like /usr/local/bin but not your current directory. See here for more info on that." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git error, need to remove large file\n\nI am getting this error when I try to push to git and I have no idea how to fix it.\nCounting objects: 1239, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (1062/1062), done.\nWriting objects: 100% (1239/1239), 26.49 MiB | 679.00 KiB/s, done.\nTotal 1239 (delta 128), reused 0 (delta 0)\nremote: warning: File log/development.log is 98.59 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB\nremote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.\nremote: error: Trace: efd2d13efa4a231e3216dad097ec25d6\nremote: error: See http://git.io/iEPt8g for more information.\nremote: error: File log/development.log is 108.86 MB; this exceeds GitHub's file size limit of 100.00 MB\nremote: error: File log/development.log is 108.74 MB; this exceeds GitHub's file size limit of 100.00 MB\nremote: error: File log/development.log is 108.56 MB; this exceeds GitHub's file size limit of 100.00 MB\nremote: error: File log/development.log is 106.58 MB; this exceeds GitHub's file size limit of 100.00 MB\nremote: error: File log/development.log is 103.70 MB; this exceeds GitHub's file size limit of 100.00 MB\nTo [email protected]:myUsername/myRepo.git\n! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:myUsername/myRepo.git'\n\nI'm guessing I need to remove the large file from the commit, but how do I do that?" }, { "role": "assistant", "content": "To remove large files, GitHub suggests:\n$ git rm --cached giant_file\n# Stage our giant file for removal, but leave it on disk\n\ngit commit --amend -CHEAD\n# Amend the previous commit with your change\n# Simply making a new commit won't work, as you need\n# to remove the file from the unpushed history as well\n\ngit push\n# Push our rewritten, smaller commit\n\nOr if you want more general information on how to work with large files on GitHub.\nAnd next time add /log in your .gitignore" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Running filter-branch over a range of commits\ngit filter-branch --env-filter '\nexport GIT_AUTHOR_EMAIL=\"[email protected]\"\nexport GIT_AUTHOR_NAME=\"foo\"' -- commita..commitb\n\nResults in Which ref do you want to rewrite?\nSo it seems that filter-branch doesn't allow you to use range notation use a range between two arbitrary refs.\nWhat is the most straight forward way of running a filter over a range of consecutive commits (somewhere within the history of a branch) if this approach isn't possible." }, { "role": "assistant", "content": "You cannot apply the filter-branch in the middle of the history, as said by @kan. You must apply from your known commit to the end of the history\ngit filter-branch --env-filter '...' SHA1..HEAD\n\nFilter-branch can check for the commit author or other information, to chose to change or not the commit, so there are ways to accomplish what you want, see https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History, look for \"Changing Email Addresses Globally\"\nRemember: if you have pushed the commits to a public repository you should not user filter-branch" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rebase - Reapply commits on top of another base tip -i --interactive" }, { "role": "assistant", "content": "Make a list of the commits which are about to be rebased. Let the\nuser edit that list before rebasing. This mode can also be used to\nsplit commits (see SPLITTING COMMITS below). The commit list format can be changed by setting the configuration option\nrebase.instructionFormat. A customized instruction format will automatically\nhave the commit hash prepended to the format. See also INCOMPATIBLE OPTIONS below." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I use Notepad++ (or other) with msysgit?\nHow do I use Notepad++ (or any other editor besides vim) with msysgit?\nI tried all of the following to no avail:\ngit config --global core.editor C:\\Program Files\\Notepad++\\notepad++.exe\n\ngit config --global core.editor \"C:\\Program Files\\Notepad++\\notepad++.exe\"\n\ngit config --global core.editor C:/Program Files/Notepad++/notepad++.exe\n\ngit config --global core.editor C:\\\\Program Files\\\\Notepad++\\\\notepad++.exe" }, { "role": "assistant", "content": "git config --global core.editor \"'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin\"\n\nOr, for 64-bit Windows and a 32-bit install of Notepad++:\ngit config --global core.editor \"'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin\"\n\nOr, the following can be issued on the command line on either 32-bit or 64-bit Windows. It will pull the location of notepad++.exe from the registry and configure git to use it automatically:\nFOR /F \"usebackq tokens=2*\" %A IN (`REG QUERY \"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\notepad++.exe\" /ve`) DO git config --global core.editor \"'%B' -multiInst -notabbar -nosession -noPlugin\"\n\nIf you wish to place the above from a .BAT or .CMD file, you must replace %A with %%A and %B with %%B" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-diff" }, { "role": "assistant", "content": "Show changes between commits, commit and working tree, etc" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to `git ls-files` for just one directory level.\nI'm using msysgit (1.7.9), and I'm looking for the right invocation of the git ls-files command to show just the (tracked) files and directories at the current level, either from the index, or the current working directory if that's easier. \nEssentially it would give a directory listing similar that that you would see on Github. Coming from Windows, I'm not too familiar with the right way of doing the globbing(?)." }, { "role": "assistant", "content": "(late edit for a feature added in Git 1.8.5, after the question and answer were written:)\nGit's pathspecs ordinarily match * with any path substring, including / separators, but you can use shell pathname-matching conventions by adding a magic :(glob) prefix. So to list just the files in the current directory,\ngit ls-files ':(glob)*' # just the files in the current directory\ngit ls-files ':(glob)test/*' # and so on\n\nAs a side note, you can do many more things with those magic prefixes, chase that link.\nYou can also turn on shell-style globbing with the --glob-pathspecs option on the Git command itself, so\n$ alias ggit='git --glob-pathspecs'\n$ # and a personal favorite:\n$ git config --global alias.ls 'ls-files --exclude-standard'\n$ # then whenever\n$ ggit ls '*' # note the quoting to bypass the shell's globbing,\n\n\nOriginal answer, still works:\nI think you want git ls-tree HEAD sed'd to taste. The second word of ls-tree's output will be tree for directories, blob for files, commit for submodules, the filename is everything after the ascii tab.\nEdit: adapting from @iegik's comment and to better fit the question as asked,\ngit ls-files . | sed s,/.*,/, | uniq\n\nwill list the indexed files starting at the current level and collapse directories to their first component.\nFurther edit: another way to do it is\ngit ls-tree `git write-tree` .\n\nand you can use git ls-tree's options for some nice seasoning." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Can't clone private repo on github from SourceTree\nA similar issue is described here however, my symptoms are a little different and none of the steps there seemed to work. Nor does the suggestion here work.\nI'm attempting to use SourceTree to clone a private repo belonging to github organization of which I am a part. I have full permissions to view and commit to the repo, I can see it online when I log in, AND I can clone just fine with the command line and also via the github desktop application. It only fails in SourceTree. \nFurther, it is not bad credentials or anything like that, because I can clone, commit and push to my other non-private repos on github using SourceTree with my github credentials.\nFrom the \"Clone a Repository\" dialog I enter the source URL, which looks something like this:\nhttps://github.com/MyOrgName/reponame.git\n\nI tab off of that field and it populates the destination path and name fields, but at the bottom of the dialog is a yellow exclamation point with this error:\nThis is not a valid source path / URL\n\nIf I click the error message, it brings up the \"Details\" dialog, which states the following (twice for some reason):\nremote: Repository not found.\nfatal: repository 'https://github.com/MyOrgName/reponame.git/' not found\nremote: Repository not found.\nfatal: repository 'https://github.com/MyOrgName/reponame.git/' not found\n\nI have also tried this by adding my username to the url like so:\nhttps://[email protected]/MyOrgName/reponame.git\n\nbut no luck there either." }, { "role": "assistant", "content": "It happens because Sourcetree didn't get some private access from Github while authenticating. So the solution is very simple.\n\nLogin to your Github account on any browser.\n\nFrom the top right corner select SETTINGS.\n\nNow select DEVELOPER SETTINGS.\n\nFrom DEVELOPER SETTINGS select PERSONAL ACCESS TOKEN.\n\nNow from PERSONAL ACCESS TOKEN select GENERATE TOKEN.\n\nFill Note as Sourcetree and Check All Scopes from the checkbox as shown in the below screenshots.\n\nAfter Click on Generate Token.\n\nNow Open Sourcetree.\n\nClick on Options in Tools menu & Click add Account.\n\nSelect options as shown below screenshot.\n\nEnter username as your Github account username and password as Generated Token from Github.\n\nClick on SAVE now you might see all your repository are visible and can clone too.\n\n\nHope it helps." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-push - Update remote refs along with associated objects push.followTags" }, { "role": "assistant", "content": "If set to true, enable --follow-tags option by default. You\nmay override this configuration at time of push by specifying --no-follow-tags ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options guitool.<name>.cmd" }, { "role": "assistant", "content": "Specifies the shell command line to execute when the corresponding item\nof the git-gui Tools menu is invoked. This option is\nmandatory for every tool. The command is executed from the root of\nthe working directory, and in the environment it receives the name of\nthe tool as GIT_GUITOOL , the name of the currently selected file as FILENAME , and the name of the current branch as CUR_BRANCH (if\nthe head is detached, CUR_BRANCH is empty)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options push.gpgSign" }, { "role": "assistant", "content": "May be set to a boolean value, or the string if-asked . A true\nvalue causes all pushes to be GPG signed, as if --signed is\npassed to git-push . The string if-asked causes\npushes to be signed if the server supports it, as if --signed=if-asked is passed to git push . A false value may\noverride a value from a lower-priority config file. An explicit\ncommand-line flag always overrides this config option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git tag delete and re-add\n\nOn git hub I re-added the tag by doing: \ngit tag -d 12.15\ngit push origin :refs/tags/12.15\ngit tag -a 12.15 -m '12.15'\ngit push --tags\n\nThe tag is still referring to the old tag on github, but locally it is done right.\nUPDATE: It seems github is listing the last commit wrong, but downloading it correctly." }, { "role": "assistant", "content": "The reference is https://stackoverflow.com/a/5480292/1317035\nYou just need to push an 'empty' reference to the remote tag name:\ngit push origin :tagname\n\nOr, more expressively, use the --delete option:\ngit push --delete origin tagname\n\nPushing a branch, tag, or other ref to a remote repository involves specifying \"push where, what source, what destination?\"\ngit push where-to-push source-ref:destination-ref\n\nA real world example where you push your master branch to the origin's master branch is:\ngit push origin refs/heads/master:refs/heads/master\n\nWhich because of default paths, can be shortened to:\ngit push origin master:master\n\nTags work the same way:\ngit push refs/tags/release-1.0:refs/tags/release-1.0\n\nBy omitting the source ref (the part before the colon), you push 'nothing' to the destination, deleting the ref on the remote end." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.renames" }, { "role": "assistant", "content": "Whether and how Git detects renames. If set to \"false\",\nrename detection is disabled. If set to \"true\", basic rename\ndetection is enabled. If set to \"copies\" or \"copy\", Git will\ndetect copies, as well. Defaults to true. Note that this\naffects only git diff Porcelain like git-diff and git-log , and not lower level commands such as git-diff-files ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers --allow-unsafe-features" }, { "role": "assistant", "content": "Many command-line options can be provided as part of the\nfast-import stream itself by using the feature or option commands. However, some of these options are unsafe (e.g.,\nallowing fast-import to access the filesystem outside of the\nrepository). These options are disabled by default, but can be\nallowed by providing this option on the command line. This\ncurrently impacts only the export-marks , import-marks , and import-marks-if-exists feature commands. Only enable this option if you trust the program generating the\nfast-import stream! This option is enabled automatically for\nremote-helpers that use the `import` capability, as they are\nalready trusted to run their own code." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What's the -practical- difference between a Bare and non-Bare repository?\nI've been reading about the bare and non-bare / default repositories in Git. I haven't been able to understand quite well (theoretically) the differences between them, and why I should \"push\" to a bare repository. Here's the deal:\nCurrently, I'm the only one working on a project on 3 different computers, but there will be more people involved in it later, so I'm using Git for the version control. I clone the bare repo on all computers, and when I finish my modifications on one of them, I commit and push the changes to the bare repo. From what I've read, the bare repository does NOT have a \"working tree\", so if I clone the bare repo, I won't have a \"working tree\".\nI'm guessing that the working tree stores the commit information, branches, etc. from the project. That wouldn't appear in the bare repo. So it seems better for me to \"push\" the commits to the repo with the working tree.\nThen, why should I use the bare repository and why not? What's the practical difference? That would not be beneficial to more people working on a project, I suppose.\nWhat are your methods for this kind of work? Suggestions?" }, { "role": "assistant", "content": "Another difference between a bare and non-bare repository is that a bare repository does not have a default remote origin repository:\n~/Projects$ git clone --bare test bare\nInitialized empty Git repository in /home/derek/Projects/bare/\n~/Projects$ cd bare\n~/Projects/bare$ git branch -a\n* master\n~/Projects/bare$ cd ..\n~/Projects$ git clone test non-bare\nInitialized empty Git repository in /home/derek/Projects/non-bare/.git/\n~/Projects$ cd non-bare\n~/Projects/non-bare$ git branch -a\n* master\n remotes/origin/HEAD -> origin/master\n remotes/origin/master\n\nFrom the manual page for git clone --bare:\n\nAlso the branch heads at the remote\n are copied directly to corresponding\n local branch heads, without mapping\n them to refs/remotes/origin/. When\n this option is used, neither\n remote-tracking branches nor the\n related configuration variables are\n created.\n\nPresumably, when it creates a bare repository, Git assumes that the bare repository will serve as the origin repository for several remote users, so it does not create the default remote origin. What this means is that basic git pull and git push operations won't work since Git assumes that without a workspace, you don't intend to commit any changes to the bare repository:\n~/Projects/bare$ git push\nfatal: No destination configured to push to.\n~/Projects/bare$ git pull\nfatal: /usr/lib/git-core/git-pull cannot be used without a working tree.\n~/Projects/bare$" } ]