messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "github: No supported authentication methods available\n\ni use github and have successfully added and synched files on my laptop in the past. \nas of recent i started getting \"PuTTY Fatal Error: Disconnected: No supported authentication methods available\" after running:\ngit pull origin master (or push)\nhowever\nssh [email protected] returns the correct response:\nERROR: Hi username! You've successfully authenticated, but GitHub does not provide shell access\nConnection to github.com closed.\nafter digging around on github i found this morcel:\nNo supported authentication methods available\nYou should be aware of the environment variable GIT_SSH, which is used by git to find your ssh-speaking client, if ssh doesn’t work for you. The git install may be using plink.exe (via GIT_SSH) to perform the authentication. If so, make sure you have pageant.exe running, and the key you created for github loaded into it. This provides the key to plink.exe; without it, the above error will occur.\nnot sure what plink.exe or peagant.exe is.. and the fact that ssh [email protected] seems to authenticate correctly makes me wonder what the best solution here is.. i certainly don't want to overcomplicate my setup if not necessary."
},
{
"role": "assistant",
"content": "You can create a file named \".profile\" in your home directory, for me that's C:\\Users\\[user]\nInside that file, put the following line of code:\nGIT_SSH=\"/usr/bin/ssh.exe\"\n\nThis will set the GIT_SSH environment variable to use the ssh client included with git.\nThe .profile script gets executed when you start your Git Bash command line.\nEdit:\nThis is my .profile. It will ask you for your password the first time you start the git command prompt, then will remember it from then on, until you reboot your computer. Very handy so you don't have to keep entering your password each time you want to do something.\nSSH_ENV=\"$HOME/.ssh/environment\"\nGIT_SSH=\"/usr/bin/ssh.exe\"\n\nfunction start_agent {\necho \"Initializing new SSH agent...\"\n/usr/bin/ssh-agent | sed 's/^echo/#echo/' > \"${SSH_ENV}\"\necho succeeded\nchmod 600 \"${SSH_ENV}\"\n. \"${SSH_ENV}\" > /dev/null\n/usr/bin/ssh-add;\n}\n\n# Source SSH settings, if applicable\nif [ -f \"${SSH_ENV}\" ]; then\n. \"${SSH_ENV}\" > /dev/null\n#ps ${SSH_AGENT_PID} doesn't work under cygwin\nps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {\nstart_agent;\n}\nelse\nstart_agent;\nfi"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you center text in Gitlab markdown?\n\nAfter Gitlab switched its markdown engine to CommonMark it's no longer as easy to add things like custom styling to your markdown files.\nI've used Gitlab for some time and for the longest time I've liked how nicely I could make my README.md file look, having a centered icon, title and description for my project. When they switched the engine all my markdown files that relied on having such stylings look really bad.\nHow do I center text in Gitlab after the transition to CommonMark?"
},
{
"role": "assistant",
"content": "Update\nI checked out an old project of mine and noticed that it was already centered. It turns out that CommonMark allows you to set align=\"center\" on <div> tags as well!\nSo, the simplest solution for centering is currently (note the empty line after the opening <div>:\n<div align=\"center\">\n\n# This is gonna be centered!\n</div>\n\nOriginal\nThe only CommonMark html object that supports centering (as far as I know) is when you center a table cell. First you might've thought about just making a table and then using align=\"center\", but the table won't take up the entire width of the page, so you'd get a small table on the left hand side of the page, which wouldn't solve our problem of wanting to center stuff relative to the page rather than the table.\nTo get around this we set the table width (not using CSS with an inline style tag since it's not supported in CommonMark at the time of writing) to a large value that will take up way more than the total width of the page. Since the max-width: CSS property of tables in Gitlab markdown is 100% it means that by setting a ridiculously high width=\"\" we're essentially setting the table width: to 100% by using only the allowed pure html width=\"\" property.\nThe markdown below if placed in e.g. README.md in your Gitlab project will result in a 100% width table with a centered image, title and description. The most notable part is that we're setting width=\"9999\" on the <td> element in the table.\n<table align=\"center\"><tr><td align=\"center\" width=\"9999\">\n<img src=\"/icon.png\" align=\"center\" width=\"150\" alt=\"Project icon\">\n\n# MyProject\n\nDescription for my awesome project\n</td></tr></table>\n\n... More content\n\nBelow you can see an example of how your README.md file could look on Gitlab using the above markdown."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options -l --list"
},
{
"role": "assistant",
"content": "List all variables set in config file, along with their values."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options color"
},
{
"role": "assistant",
"content": "The value for a variable that takes a color is a list of\ncolors (at most two, one for foreground and one for background)\nand attributes (as many as you want), separated by spaces. The basic colors accepted are normal , black , red , green , yellow , blue , magenta , cyan , white and default . The first\ncolor given is the foreground; the second is the background. All the\nbasic colors except normal and default have a bright variant that can\nbe specified by prefixing the color with bright , like brightred . The color normal makes no change to the color. It is the same as an\nempty string, but can be used as the foreground color when specifying a\nbackground color alone (for example, \"normal red\"). The color default explicitly resets the color to the terminal default,\nfor example to specify a cleared background. Although it varies between\nterminals, this is usually not the same as setting to \"white black\". Colors may also be given as numbers between 0 and 255; these use ANSI\n256-color mode (but note that not all terminals may support this). If\nyour terminal supports it, you may also specify 24-bit RGB values as\nhex, like #ff0ab3 . The accepted attributes are bold , dim , ul , blink , reverse , italic , and strike (for crossed-out or \"strikethrough\" letters).\nThe position of any attributes with respect to the colors\n(before, after, or in between), doesn’t matter. Specific attributes may\nbe turned off by prefixing them with no or no- (e.g., noreverse , no-ul , etc). The pseudo-attribute reset resets all colors and attributes before\napplying the specified coloring. For example, reset green will result\nin a green foreground and default background without any active\nattributes. An empty color string produces no color effect at all. This can be used\nto avoid coloring specific elements without disabling color entirely. For git’s pre-defined color slots, the attributes are meant to be reset\nat the beginning of each item in the colored output. So setting color.decorate.branch to black will paint that branch name in a\nplain black , even if the previous thing on the same output line (e.g.\nopening parenthesis before the list of branch names in log --decorate output) is set to be painted with bold or some other attribute.\nHowever, custom log formats may do more complicated and layered\ncoloring, and the negated forms may be useful there."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Lost my schema.rb! Can it be regenerated?\nDue to some deployment issues I stopped tracking schema.rb in git. Somehow I have stuffed this up and somewhere along the way my schema.rb file has disappeared.\nIs there a way of regenerating schema.rb from the database or from the migrations? I would prefer not to lose the existing data."
},
{
"role": "assistant",
"content": "If you run a rake -T it will list all possible rake tasks for your Rails project. One of them is db:schema:dump which will recreate the schema.rb for the Rails app from the database.\nbundle exec rake db:schema:dump"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "When will `git pull --rebase` get me in to trouble?\nI understand that when I use git pull --rebase, git will re-write history and move my local commits to occur after all of the commits in the branch I just pulled from. \nWhat I don't understand is how this would ever be a bad thing. People talk about getting in to trouble with git pull --rebase where you can end up with a branch that other people can't pull from. But I don't get how that's possible since all you're doing is replaying your local, not-yet-public, commits on top of the branch you pulled from. So, what's the problem there?"
},
{
"role": "assistant",
"content": "It is only an issue if you have only published (pushed) some of your commits, because they would be harder to merge to other repos which have already those commits. Since their SHA1 have changed, Git would try to replay them again on those repos.\nIf you have not (pushed any of those commits again), any rebase should be safe.\nSo the issue here is: are you sure that all the local commit you are rebasing are still actually... local?\nAnd are you sure of that 'git pull --rebase' after 'git pull --rebase'?\nIf you are working on a 'private branch' (a branch that you never pushed, but only merge or rebase on a public branch, one that you will push), then you are safe to rebase that private branch any time you want.\nIn the end, it all depends on the workflow of merge you have chosen to establish."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-update-ref - Update the object name stored in a ref safely commit"
},
{
"role": "assistant",
"content": "Commit all reference updates queued for the transaction, ending the\ntransaction."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Push to origin from GitHub action\nI'm trying to push to origin remote from GitHub action. The logic of my action is:\n\nhandle pull_request_review events and filter by comment message\ncheckout to master, merge PR branch, run some checks and push it to origin\n\nThe script is:\nif [[ \"${GITHUB_EVENT_NAME}\" != \"pull_request_review\" ]]; then\n echo \"unsupported event: ${GITHUB_EVENT_NAME}\"\n exit 1\nfi\n\nuser=$(jq -r .review.user.login ${GITHUB_EVENT_PATH})\ncmd=$(jq -r .review.body ${GITHUB_EVENT_PATH})\necho \"reviewer is ${user}, command is ${cmd}\"\n\nif [[ \"${cmd}\" == \"merge\" ]]; then\n head=$(jq -r .pull_request.head.ref ${GITHUB_EVENT_PATH})\n git config user.email [email protected]\n git config user.name test\n git checkout -B _tmp origin/${head}\n git checkout -B master origin/master\n git merge --no-ff _tmp\n git push origin master\nfi\n\nI'm running this script from alpine:3.10 Docker container:\nFROM alpine:3.10\n\nLABEL \"com.github.actions.name\"=\"Hello world action\"\nLABEL \"com.github.actions.icon\"=\"shield\"\nLABEL \"com.github.actions.color\"=\"green\"\n\nWORKDIR /app\nCOPY action.sh action.sh\nRUN apk --update add bash git jq\nCMD [\"bash\", \"/app/action.sh\"]\n\nFirst steps are working fine (checkout and merge), but action failed to push the merge to origin because of the error:\n\n+ git push origin master\n fatal: could not read Username for 'https://github.com': No such device or address\n\nIt looks like GitHub-action Docker container is not configured to push to GitHub. How can I configure it? Is it possible to use some of the env variables provided by GitHub or maybe some mounted files (like in /github/* path)?"
},
{
"role": "assistant",
"content": "actions/checkout@v2 onwards\nFrom version 2 of checkout, the detached HEAD state issue is resolved and simplifies pushing to origin.\nname: Push commit\non: push\npermissions:\n contents: write\njobs:\n report:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v3\n - name: Create report file\n run: date +%s > report.txt\n - name: Commit report\n run: |\n git config --global user.name 'Your Name'\n git config --global user.email '[email protected]'\n git commit -am \"Automated report\"\n git push\n\nIf you need the push event to trigger other workflows, use a repo scoped Personal Access Token.\n - uses: actions/checkout@v3\n with:\n token: ${{ secrets.PAT }}\n\nactions/checkout@v1 (original answer)\nTo add some further detail to the excellent answer by @rmunn. The problem is that the actions/checkout@v1 action leaves the git repository in a detached HEAD state. See this issue about it for more detailed information: https://github.com/actions/checkout/issues/6\nHere is a complete example to demonstrate how to get the checked out repository to a usable state and push to the remote.\nname: Push commit\non: push\njobs:\n report:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v1\n - name: Create report file\n run: date +%s > report.txt\n - name: Commit report\n run: |\n git config --global user.name 'Your Name'\n git config --global user.email '[email protected]'\n git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY\n git checkout \"${GITHUB_REF:11}\"\n git commit -am \"Automated report\"\n git push\n\nTo include untracked (new) files change the workflow to use the following.\n git add -A\n git commit -m \"Automated report\"\n\nThe above workflow should work for the majority of events. For on: pull_request workflows the merging branch (GITHUB_HEAD_REF) should be checked out to replace the default merge commit.\nImportant: If you have other pull request checks besides the following workflow then you must use a Personal Access Token instead of the default GITHUB_TOKEN.\nThis is due to a deliberate limitation imposed by GitHub Actions that events raised by a workflow (such as push) cannot trigger further workflow runs.\nThis is to prevent accidental \"infinite loop\" situations, and as an anti-abuse measure.\nUsing a repo scoped Personal Access Token is an approved workaround. See this GitHub issue for further detail on the workaround.\nname: Push commit on pull request\non: pull_request\njobs:\n report:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v1\n with:\n ref: ${{ github.head_ref }}\n - name: Create report file\n run: date +%s > report.txt\n - name: Commit report\n run: |\n git config --global user.name 'Your Name'\n git config --global user.email '[email protected]'\n git remote set-url origin https://x-access-token:${{ secrets.PAT }}@github.com/${{ github.repository }}\n git commit -am \"Automated report\"\n git push\n\nFor further examples of push to origin during an on: pull_request workflow see this blog post, GitHub Actions: How to Automate Code Formatting in Pull Requests."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can't connect IntelliJ-IDEA to GitLab with SSH\n\nI am trying to connect my GitLab repository with IntelliJ-IDEA, and it still cant connect to the repo. I have tried the next things:\n\nI have msysgit installed correctly\nGenerated the SSH keys (https://help.github.com/articles/generating-ssh-keys/)\nAdded the key on GitLab keys\nDefine the enviroment variables HOME USERPROFILE point to C:\\Users\\sebastian.garces.ssh. %USERPROFILE$/.ssh %HOME$/.ssh\nIn IntelliJ changed SSH executable to Native\n\nI did a lot of things from this links:\n\nHow do I connect IntelliJ to GitHub using SSH\nHow to store SSH host key in IntelliJ IDEA\n\nAnd many other google searchs\nI dont know what else to do nothing is working.\nUPDATE: When i try to Clone the repository and press the Test Button it loads and loads and nothing happen after a while it give me this error: repository test has failed"
},
{
"role": "assistant",
"content": "Try to install plugin:\nSettings -> Plugins -> Browse repositories -> type GitLab Projects Plugin minimum version 1.3.0\nand go to Settings -> Other Settings -> GitLab Settings\nFill GitLab Server Url with https://gitlab.com/ (ensure slash at the end) \nand \nGitLab API Key with string (private token which is shown as the first thing on: https://gitlab.com/profile/account)\n\nAnd then the test in IntelliJ IDEA will pass and you will be able to use ssh or https for each repository...\nUPDATE: GitLab UI changed, so private tokens are created at https://gitlab.com/profile/personal_access_tokens"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git push >> fatal: no configured push destination\n\nI'm still going through some guides on RoR and I'm stuck here at Deploying The Demo App \nI followed instructions:\n\nWith the completion of the Microposts resource, now is a good time to push the repository up to GitHub:\n$ git add .\n$ git commit -a -m \"Done with the demo app\"\n$ git push\n\n\nWhat happened wrong here was the push part.. it outputted this:\n$ git push\nfatal: No configured push destination.\nEither specify the URL from the command-line or configure a remote repository using\ngit remote add <name> <url>\ngit push <name>\n\nSo I tried following the instructions by doing this command:\n$ git remote add demo_app 'www.github.com/levelone/demo_app'\nfatal: remote demo_app already exists.\n\nSo I push:\n$ git push demo_app\nfatal: 'www.github.com/levelone/demo_app' does not appear to be a git repository\nfatal: The remote end hung up unexpectedly\n\nWhat can I do here? Any help would be much appreciated."
},
{
"role": "assistant",
"content": "You are referring to the section \"2.3.5 Deploying the demo app\" of this \"Ruby on Rails Tutorial \":\nIn section 2.3.1 Planning the application, note that they did:\n$ git remote add origin [email protected]:<username>/demo_app.git\n$ git push -u origin master\n\nThat is why a simple git push worked (using here an ssh address).\nDid you follow that step and made that first push?\n www.github.com/levelone/demo_app\n\nThat would not be a writable URI for pushing to a GitHub repo.\nhttps://[email protected]/levelone/demo_app.git\n\nThis should be more appropriate.\nCheck what git remote -v returns, and if you need to replace the remote address, as described in GitHub help page, use git remote --set-url.\ngit remote set-url origin https://[email protected]/levelone/demo_app.git\n# or \ngit remote set-url origin [email protected]:levelone/demo_app.git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Push into Production (FTP)\nI would like to know if there is an easy way to push a GIT repository into production (on a FTP server) ?\nThanks"
},
{
"role": "assistant",
"content": "Some tools recently added to the Git wiki:\n\ngit-ftp by René Moser is a simple\nshell script for doing FTP the Git\nway. Use git-ftp.sh to upload only the\nGit tracked files to a FTP server,\nwhich have changed since the last\nupload. This saves time and bandwidth.\nEven if you play with different\nbranches, git-ftp.sh knows which files\nare different. No ordinary FTP client\ncan do that.\ngit-ftp by Edward Z. Yang is a\nsimple script written in python for\nuploading files in a Git repository\nvia FTP, only transferring new files\nand removing old files."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Create new repo on Bitbucket from Git Bash terminal?\nIs it possible to create a new repository in Bitbucket by using command line Git? I have tried the following:\ngit clone --bare https://[email protected]/username/new_project.git\n\nI get this message:\n\nCloning into bare repository 'new_project.git'...\n fatal: https://[email protected]/username/new_project.git/info/refs not found: did you run git update-server-info on the server?\n\nIt would be nice to do this without going to the web app."
},
{
"role": "assistant",
"content": "You can use the Bitbucket REST API and cURL. For example:\ncurl --user login:pass https://api.bitbucket.org/1.0/repositories/ \\\n--data name=REPO_NAME\n\nto create new repository named REPO_NAME.\nSee Use the Bitbucket REST APIs for more information.\nUPDATE\nFor Bitbucket V2 specifically, see POST a new repo"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options pack.writeReverseIndex"
},
{
"role": "assistant",
"content": "When true, git will write a corresponding .rev file (see: gitformat-pack )\nfor each new packfile that it writes in all places except for git-fast-import and in the bulk checkin mechanism.\nDefaults to true."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git rm - fatal: pathspec did not match any files\nI added over 9000 photos by accident to my project folder. And committed them. Then deleted them from the disk. Committed.\nNow I try to push changes to the git server. But it takes too long and tries to send 12 GB of data.\nI checked files size on the disk and saw that really .git folder takes 12 GB.\nHow to delete photos from there? I tried git rm, but fails:\n❯ git rm public/photos\nfatal: pathspec 'public/photos' did not match any files\n\nBecause I already deleted them from the disk, but they are still in .git folder.\nI tried to add public/photos to .gitignore:\npublic/photos/\n*.zip\n\nBut no result.\nOf course, I could hard reset head to the moment when I did not have so many junk photos in my project. But since that time I committed many times and made a lot of changes in code."
},
{
"role": "assistant",
"content": "In your case, use git filter-branch instead of git rm.\ngit rm will delete the files in the sense that they will not be tracked by git any more, but that does not remove the old commit objects corresponding to those images, and so you will still be stuck with pushing the earlier commits which correspond to 12GB of images.\nThe git filter-branch, on the other hand, can remove those files from all the previous commits as well, thus doing away with the need to push any of them.\n\nUse the command\n git filter-branch --force --index-filter \\\n 'git rm -r --cached --ignore-unmatch public/photos' \\\n --prune-empty --tag-name-filter cat -- --all\n\n\nAfter the filter branch is complete, verify that no unintended file was lost.\n\nNow add a .gitignore rule\n echo public/photos >> .gitignore\n git add .gitignore && git commit -m \"ignore rule for photos\"\n\n\nNow do a push\n git push -f origin branch\n\n\n\nCheck this, this and this for further help. Just to be on the safer side, I would suggest you create a backup copy of the repo on your system before going ahead with these instructions.\nAs for your original error message, it is happening because you already untracked them using git rm, and hence git is complaining because it can't remove a file it isn't tracking. Read more about this here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git pull remote branch cannot find remote ref\nI'm not sure why this doesn't work. When I do git branch -a, this is what I see:\n\nI'm trying to pull from the DownloadManager on the online GitHub repository. I have tried\n\ngit pull, but then it complains about not knowing which branch to pull from\ngit pull origin, doesn't know which branch\ngit pull origin downloadmanager gives fatal: Couldn't find remote ref downloadmanager. Unexpected end of commands stream\ngit pull origin remotes/origin/DownloadManager gives fatal couldn't find remote ref remotes/origin/DownloadManager. Unexpected end of commands stream\n\nIs there something I'm missing? In Xcode, When I try to connect to the repository, nothing ever shows up. I have been able to push to it in the past. But I can't push again until I pull the most recent changes."
},
{
"role": "assistant",
"content": "Be careful - you have case mixing between local and remote branch!\nSuppose you are in local branch downloadmanager now (git checkout downloadmanager)\nYou have next options:\n\nSpecify remote branch in pull/push commands every time (case sensitive):\ngit pull origin DownloadManager\nor \ngit pull origin downloadmanager:DownloadManager\n\n\n\nSpecify tracking branch on next push:\ngit push -u origin DownloadManager\n(-u is a short form of --set-upstream)\nthis will persist downloadmanager:DownloadManager link in config automatically (same result, as the next step). \n\n\n\nSet in git config default remote tracking branch:\ngit branch -u downloadmanager origin/DownloadManager\n(note, since git 1.8 for branch command -u is a short form of --set-upstream-to, which is a bit different from deprecated --set-upstream)\nor edit config manually (I prefer this way):\ngit config --local -e \n-> This will open editor. Add block below (guess, after \"master\" block):\n[branch \"downloadmanager\"]\n remote = origin\n merge = refs/heads/DownloadManager\n\n\n\nand after any of those steps you can use easily:\ngit pull\nIf you use TortoiseGit:\nRightClick on repo -> TortoiseGit -> Settings -> Git -> Edit local .git/config"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git on Mac OS X v10.7 (Lion)\nI just upgraded my Mac to Mac OS X v10.7 (Lion), and now Git is gone:\n$ git\n-bash: git: command not found\n\nHow can I get Git back?"
},
{
"role": "assistant",
"content": "The default install location is /usr/local, so add this to your ~/.bash_profile file:\nexport PATH=$PATH:/usr/local/git/bin/\n\nThen run source ~/.bash_profile in Terminal."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip --no-ff --force-rebase -f"
},
{
"role": "assistant",
"content": "Individually replay all rebased commits instead of fast-forwarding\nover the unchanged ones. This ensures that the entire history of\nthe rebased branch is composed of new commits. You may find this helpful after reverting a topic branch merge, as this option\nrecreates the topic branch with fresh commits so it can be remerged\nsuccessfully without needing to \"revert the reversion\" (see the revert-a-faulty-merge How-To for\ndetails)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options difftool.<tool>.cmd"
},
{
"role": "assistant",
"content": "Specify the command to invoke the specified diff tool.\nThe specified command is evaluated in shell with the following\nvariables available: LOCAL is set to the name of the temporary\nfile containing the contents of the diff pre-image and REMOTE is set to the name of the temporary file containing the contents\nof the diff post-image. See the --tool=<tool> option in git-difftool for more details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Confusing error message from git\nI got this message from Git:\n\nYou asked to pull from the remote 'origin', but did not specify\n a branch. Because this is not the default configured remote\n for your current branch, you must specify a branch on the command line.\n\nCan anyone explain it? and more important how to fix it?"
},
{
"role": "assistant",
"content": "You have to tell git which branch you want to pull from the \"origin\" remote repos.\nI guess you want the default branch (master) so git pull origin master should fix your problem.\nSee git help branch, git help pull and git help fetch for more informations."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts mergetool.<tool>.hideResolved"
},
{
"role": "assistant",
"content": "Allows the user to override the global mergetool.hideResolved value\nfor a specific tool. See mergetool.hideResolved for the full\ndescription."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I push to a repo from within a gitlab CI pipeline?\n\nIn my CI pipeline I am generating an artifact public/graph.png that visualises some aspect of my code. In a later step I want to commit that to the repo from within the CI pipeline. Here's the pertinent part of .gitlab-ci.yml:\ncommit-graph:\n stage: pages\n script:\n - git config user.email \"[email protected]\"\n - git config user.name \"CI Pipeline\"\n - cd /group/project\n - mv public/graph.png .\n - git add graph.png\n - git commit -m \"committing graph.png [ci skip]\"\n - echo $CI_COMMIT_REF_NAME\n - git push origin HEAD:$CI_COMMIT_REF_NAME\n\nWhen the pipeline runs within gitlab it fails with:\n\n$ git config user.email \"[email protected]\"\n $ git config user.name \"CI Pipeline\"\n $ cd /group/project\n $ mv public/graph.png .\n $ git add graph.png\n $ git commit -m \"committing graph.png [ci skip]\"\n [detached HEAD 22a50d1] committing graph.png [ci skip]\n 1 file changed, 0 insertions(+), 0 deletions(-)\n create mode 100644 graph.png\n $ echo $CI_COMMIT_REF_NAME\n jamiet/my-branch\n $ git push origin HEAD:$CI_COMMIT_REF_NAME\n fatal: unable to access 'https://gitlab-ci-token:[email protected]/group/project/project.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none\n\nNot sure what I'm doing wrong and don't know enough about SSL to understand that error. Can anyone advise?\nWe are hosting gitlab ourselves by the way."
},
{
"role": "assistant",
"content": "Nowadays there is a much cleaner way to solve this without using SSH but using a project scoped access token, also see this answer.\nIn the GitLab project create an project scoped access token so it is linked to the project, not to an individual. Next store this token as an GitLab CI/CD variable. You can now connect using the following:\npush-back-to-remote:\n script:\n - git config user.email \"[email protected]\"\n - git config user.name \"ci-bot\"\n - git remote add gitlab_origin https://oauth2:[email protected]/path-to-project.git\n - git add .\n - git commit -m \"push back from pipeline\"\n - git push gitlab_origin HEAD:main -o ci.skip # prevent triggering pipeline again"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Omnibus GitLab on IP without a domain-name and with custom relative_url_root\n\nI already know that you can download and install gitlab with the omnibus package(easy way). But I'm caught at the configuration of the IP / domain. Because I don't have a domain I want to use my static server IP like this:\nSudo gitlab-ctl reconfigure -> \"133.713.37.01/gitlab\"\nIs it even possible to set up gitlab without a domain or am I doing something wrong?\nI'm grateful for any help"
},
{
"role": "assistant",
"content": "Using an IP directly seems to work, since most networking utilities accept either: just add external_url \"http://127.0.0.1\" to /etc/gitlab/gitlab.rb and run sudo gitlab-ctl reconfigure.\nWhat does not work is adding the /gitlab root path to the external_url: gitlab-ctl says:\nRuntimeError\n------------\nUnsupported external URL path: /gitlab\n\nServing from a relative URL root seems to be simply not implemented on Omnibus GitLab (since no template variable is inserted there).\nYou could work around that by modifying all the required configuration files manually as explained in the comment on gitlab.yml, but that would really be a lot of manual work and those configs would get overwritten if you reconfigure, so I recommend you request the feature on the GitLab forum and send a pull request implementing that."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "how can I customize git's merge commit message?\nEvery time I do a merge I need for a merge commit to be generated and I would like it to have more than just the summary of all the commits.\nMy question is how can I format git-fmt-merge-msg or what determines this automated message (I can do this manually after a commit by amending it and using git-log --pretty=format:'...')\nFor example I would like to format it as such:\n Merge branch 'test' \n * test: \n [BZ: #123] fifth commit subject \n [BZ: #123] fourth commit subject \n [BZ: #123] third commit subject \n [BZ: #123] second commit subject \n [BZ: #123] first commit subject \n\n __________________________________________\n Merge details: \n [BZ: #123] fifth commit subject \n at 2010-06-30 11:29:00 +0100 \n - fifth commit body \n\n [BZ: #123] fourth commit subject \n at 2010-06-30 11:22:17 +0100 \n - fourth commit body \n\n [BZ: #123] third commit subject \n at 2010-06-30 11:21:43 +0100 \n - third commit body \n\n [BZ: #123] second commit subject \n at 2010-06-30 11:21:30 +0100 \n - second commit body \n\n [BZ: #123] first commit subject \n at 2010-06-30 11:29:57 +0100 \n - first commit body"
},
{
"role": "assistant",
"content": "I'm aware this isn't answering the original question, but for the benefit of git noobs like myself who reach this page because it's currently the first Google result for \"git change merge commit message\", I'll mention that it is possible to:\ngit commit --amend -m\"New commit message\"\n\nto change the commit message of a merge commit without losing the link to any of the parents of the merge commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git merge reports \"Already up-to-date\" though there is a difference\nI have a git repository with 2 branches: master and test.\nThere are differences between master and test branches.\nBoth branches have all changes committed.\nIf I do:\n\ngit checkout master\ngit diff test\n\nA screen full of changes appears showing the differences. I want to merge the changes in the test branch and so do:\ngit merge test\nBut get the message \"Already up-to-date\"\nHowever, examining files under each different branch clearly shows differences.\nWhat's the problem here and how do I resolve it?"
},
{
"role": "assistant",
"content": "The message “Already up-to-date” means that all the changes from the branch you’re trying to merge have already been merged to the branch you’re currently on. More specifically it means that the branch you’re trying to merge is a parent of your current branch. Congratulations, that’s the easiest merge you’ll ever do. :)\nUse gitk to take a look at your repository. The label for the “test” branch should be somewhere below your “master” branch label.\nYour branch is up-to-date with respect to its parent. According to merge there are no new changes in the parent since the last merge. That does not mean the branches are the same, because you can have plenty of changes in your working branch and it sounds like you do. \nEdit 10/12/2019: \nPer Charles Drake in the comment to this answer, one solution to remediate the problem is:\ngit checkout master\ngit reset --hard test\n\nThis brings it back to the 'test' level. \nThen do:\ngit push --force origin master\n\nin order to force changes back to the central repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-worktree - Manage multiple working trees --lock"
},
{
"role": "assistant",
"content": "Keep the worktree locked after creation. This is the\nequivalent of git worktree lock after git worktree add ,\nbut without a race condition."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I load a specific git commit?\nI cloned a repository and want to switch to a commit to test my plugin against the core."
},
{
"role": "assistant",
"content": "Instead of passing the name of a branch, you can pass any commit ID to checkout:\ngit checkout <commit-id>\n\nSee the man page."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-grep - Print lines matching a pattern --and --or --not ( … )"
},
{
"role": "assistant",
"content": "Specify how multiple patterns are combined using Boolean\nexpressions. --or is the default operator. --and has\nhigher precedence than --or . -e has to be used for all\npatterns."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Bash won't run my python files?\nI have been trying to run my python files in Git Bash but I keep getting an error and can't figure out how to fix it. My command as follows in the git bash executable python filename.py then it says \n\"Bash.exe\": python.exe: command not found\n\nI'm a windows user and I have added the path to my environment variables like so C:\\Python27\\python.exe;C:\\Program Files\\Git\\bin\\bash.exe\nI have been looking around but I can't find anyone that has had this problem or they don't give a straightforward answer please help.\nAlso I have never used Git before this is my first time."
},
{
"role": "assistant",
"content": "Adapting the PATH should work. Just tried on my Git bash:\n$ python --version\nsh.exe\": python: command not found\n\n$ PATH=$PATH:/c/Python27/\n\n$ python --version\nPython 2.7.6\n\nIn particular, only provide the directory; don't specify the .exe on the PATH ; and use slashes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rm - Remove files from the working tree and from the index git rm Documentation/\\*.txt"
},
{
"role": "assistant",
"content": "Removes all *.txt files from the index that are under the Documentation directory and any of its subdirectories. Note that the asterisk * is quoted from the shell in this\nexample; this lets Git, and not the shell, expand the pathnames\nof files and subdirectories under the Documentation/ directory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip rebase.rescheduleFailedExec"
},
{
"role": "assistant",
"content": "Automatically reschedule exec commands that failed. This only makes\nsense in interactive mode (or when an --exec option was provided).\nThis is the same as specifying the --reschedule-failed-exec option."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options submodule.propagateBranches"
},
{
"role": "assistant",
"content": "[EXPERIMENTAL] A boolean that enables branching support when\nusing --recurse-submodules or submodule.recurse=true .\nEnabling this will allow certain commands to accept --recurse-submodules and certain commands that already accept --recurse-submodules will now consider branches.\nDefaults to false."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitFlow: merge to master first or after prod release?\n\nLearning GitFlow and I have some concerns that I don't see addressed in any of the docs/articles I've read about it.\nAt some point code on the develop branch needs to be deployed to a QA/staging environment and tested rigorously. So with GitFlow you cut a release branch off of develop, and then you deploy release to said staging environment.\nFirst, just wanted to clarify something real quick: the very first time a particular project/repo goes through this process, you'll actually be forking/creating this new release branch from develop, yes? And that all other times in the future, you're simply merging develop into release, yes?\nSo then QA tests the release branch on the staging env, all looks good, and we're ready to deploy to prod. Do you:\n\nDeploy to prod and then merge release into master? ; or\nMerge release to master and then deploy to prod?\n\nI ask because it seems like in the former case you would need to deploy the release branch to prod, then deploy to prod, and then merge to master. Which sounds OK, but often prod and non-prod environments are not identical and code that runs perfectly fine in staging chokes the second it fires up on prod servers. I know GitFlow supports the concepts of hotfix branches but they are reserved for minor fixes. In the case of a complicated fix that requires a rollback/backout release, we now have \"dirty code\" (code that breaks prod for some reason) merged into master.\nAnd in the latter case, it might take hours or even days (especially if you need to involve IT/Ops to do prod deploys) from the time you merge and put in the prod release request in, to the time the prod deploy actually occurs. And during this time you have a master branch that says \"features X, Y and Z are in prod\" but they are actually not.\nI'm wondering if GitFlow actually solves this somehow or what the known workarounds to either case are."
},
{
"role": "assistant",
"content": "The project I work in is very chaotic, decisions change in a matter of minutes, so my strategy is to procrastinate as much as possible software configuration management decisions.\nParticularly, merging into master: we only merge to master after we deployed in production and we have a confirmation e-mail that smoke tests worked fine. This way we embrace chaos by managing the risk of decision changes, rollbacks in the deploy, technical problems or whichever issue may happen.\nAt the beginning we merged into master before going into production, but technical issues, rollbacks, management decisions at the very last minute... caused lots of problems to us, so we changed the strategy, and it's been working fine for the last 3 years.\nIf, eventually, after going to production some regression is found, that's a hotfix and must be handled like that :)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary upstream branch"
},
{
"role": "assistant",
"content": "The default branch that is merged into the branch in\nquestion (or the branch in question is rebased onto). It is configured\nvia branch.<name>.remote and branch.<name>.merge. If the upstream branch\nof A is origin/B sometimes we say \" A is tracking origin/B \"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git returns http error 407 from proxy after CONNECT\nI have a problem while connecting to github from my PC, using git. System Win 7.\nI have connection through proxy, so i specified it in git config files (both in general git folder, and in git repo folder). To do this i entered next line to my git bush:\n$ git config --global http.proxy http://<username>:<userpsw>@<proxy>:<port>\n\nThe way it works on other programms (ex: maven) it looks like that:\n<username> - my login to our corp system\n<userpsw> -my password to corporat system\n<proxy> - 10.65.64.77\n<port> - 3128\n\nBut when i try to push or to clone my repo, i receive\nfatal: unable to access '<repo githup link>' Received HTTP code 407 from proxy after CONNECT\n\nI try already to enter not just my username but domain\\username, changed my password in case there are problems with code language tables. And i even entered wrong password. Error stayed the same.\nWhen i entered in '10.65.64.177.com' and tried to push repo, i received:\nfatal: unable to access '<repo github link>': Failed connect to github.com:3128; No error\n\nJust don't know what to try."
},
{
"role": "assistant",
"content": "What worked for me is something similar to what rohitmohta is proposing ; in regular DOS command prompt (not on git bash) :\nfirst\ngit config --global http.proxy http://username:password@proxiURL:proxiPort\n\nand in some cases also\ngit config --global https.proxy http://username:password@proxiURL:proxiPort\n\nthen\ngit config --global http.sslVerify false\n\n(I confirm it's necessary : if set to true getting \"SSL certificate problem: unable to get local issuer certificate\" error)\nin my case, no need of defining all_proxy variable\nand finally \ngit clone https://github.com/someUser/someRepo.git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Enable SSL on GitLab with Docker on Synology NAS\n\nI have a working installation of GitLab via the official GitLab Package on my Synology NAS (DSM 5.2) in a Docker container.\nI now like to access the Webinterface via https instead of just http. I have seen in several posts that it is possible to do with some docker magic, but\ndid not find any detailed instructions.\nCan anyone please explain how to achieve this?\nIt's a pity that this is not default."
},
{
"role": "assistant",
"content": "With DSM6, the changes (except generation of the cert) are now possible using the dsm docker interface:\n1) Create a key/cert:\nmkdir /volume1/docker/gitlab/certs\ncd /volume1/docker/gitlab/certs\nopenssl genrsa -out gitlab.key 2048\nopenssl req -new -key gitlab.key -out gitlab.csr\nopenssl x509 -req -days 3650 -in gitlab.csr -signkey gitlab.key -out gitlab.crt\nopenssl dhparam -out dhparam.pem 2048\nchmod 400 gitlab.key\n\n2) Set up gitlab docker environment:\n\n3) Set gitlab docker port bindings:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git push results in \"Authentication Failed\"\nI have been using GitHub for a little while, and I have been fine with git add, git commit, and git push, so far without any problems. Suddenly I am having an error that says:\n\nfatal: Authentication Failed\n\nIn the terminal I cloned a repository, worked on a file and then I used git add to add the file to the commit log and when I did git commit, it worked fine. Finally, git push asks for username and password. I put those in correctly and every time I do this, it says the same error.\nWhat is the cause of this problem and how can I fix it?\nThe contents of .git/config are:\n[core]\n repositoryformatversion = 0\n filemode = true\n bare = false\n logallrefupdates = true\n[remote \"origin\"]\n url = http://www.github.com/######/Random-Python-Tests\n fetch = +refs/heads/*:refs/remotes/origin/*\n[branch \"master\"]\n remote = origin\n merge = refs/heads/master\n[user]\n name = #####\n email = ############"
},
{
"role": "assistant",
"content": "If you enabled two-factor authentication in your GitHub account you\nwon't be able to push via HTTPS using your accounts password. Instead\nyou need to generate a personal access token. This can be done in the\napplication settings of your GitHub account. Using this token as your\npassword should allow you to push to your remote repository via HTTPS.\nUse your username as usual.\n\nCreating a personal access token\nYou may also need to update the origin for your repository if it is set to HTTPS. Do this to switch to SSH:\ngit remote -v\ngit remote set-url origin [email protected]:USERNAME/REPONAME.git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_TRACE2_PERF"
},
{
"role": "assistant",
"content": "In addition to the text-based messages available in GIT_TRACE2 , this\nsetting writes a column-based format for understanding nesting\nregions.\nSee GIT_TRACE2 for available trace output options and Trace2 documentation for full details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to track but not stage and how to unstage but not untrack?\nI have two concise questions:\n\nHow I can track files but without staging them ?\nHow I can unstage files for commit without untracking them ?\n\nNOTE: I know that I can do an initial commit to track the files and start from there with my files tracked. But is possible to specifically do what I'm asking above ?\nI tried to use git add -N <expr> but it tracks the file and add it for commit:\nPS C:\\> git add -N fileA\nPS C:\\> git status\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# new file: fileA\n#\n# Changes not staged for commit:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# modified: README.md\n# modified: composer.lock\n# modified: fileA\n#\n\nIf I do git reset HEAD fileA or git rm --cached fileA unstages it but also untracks the file.\nThis command git rm fileA suggest me to use the flag -f that removes the file fisically.\nSo, It is possible to only track but not stage, and to only unstage but not untrack files ?"
},
{
"role": "assistant",
"content": "Update (May 2015)\n\nI tried to use git add -N <expr> but it tracks the file and add it for commit:\n\nThat is no longer the case with the upcoming Git 2.5 (Q2 2015).\nSee \"File doesn′t get into the commit after using git add -N\"\n\nOriginal answer (March 2013)\n\nHow I can unstage files for commit without untracking them ?\n\nthis is the official way:\ngit reset HEAD fileA\n\nBut since it is a new file, you would untrack it as well (remove it from the index, without any previous commit referencing it).\nStarting tracking a file means having it in a index (stage) or a commit.\nI would recommend making a branch for those files, in order to add them/commit them there.\nSee \"What is Tracked files and Untracked files in the context of GIT?\"\n\n\nTracked files are files that were in the last snapshot; they can be unmodified, modified, or staged. \nUntracked files are everything else — any files in your working directory that were not in your last snapshot and are not in your staging area (index)\n\n\nThat means that, for a new file, unstaged it means untrack it.\n\n(Source: Pro Git Book, 2.2 Git Basics - Recording Changes to the Repository)\n(Thank you, louisfischer, for the update/fix in the comments)\nSee also \"git - how to tell if a file is git tracked (by shell exit code)?\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitformat-pack"
},
{
"role": "assistant",
"content": "Git pack format"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "HEAD~ vs HEAD^ vs HEAD@{} also known as tilde vs caret vs at sign\nHEAD is a pointer at the current branch. I have seen a variety of notations for ancestors of HEAD including \n\nHEAD~2\nHEAD^2\nHEAD@{2}\nHEAD~~\nHEAD^^\n\nWhat does each of the above mean, exactly? Where is the documentation for this?"
},
{
"role": "assistant",
"content": "From the docs here.\n\nHEAD~2 : 2 commits older than HEAD\nHEAD^2 : the second parent of HEAD, if HEAD was a merge, otherwise illegal\nHEAD@{2} : refers to the 3rd listing in the overview of git reflog\nHEAD~~ : 2 commits older than HEAD\nHEAD^^ : 2 commits older than HEAD\n\n\nIf HEAD was a merge, then\n\nfirst parent is the branch into which we merged,\nsecond parent is the branch we merged.\n\n\nSome Combinations and Synonyms\nFirst Parent First Grandparent Second Parent Second Grandparent\n\nHEAD~\nHEAD^\nHEAD~1 HEAD~2 HEAD^2 HEAD^2~ \nHEAD^1 HEAD^^ HEAD^2^"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Renaming remote git branch\nI have 2 git branches: master and experimental.\nExperimental became good, I want to make it the master. I figured I would rename to shuffle things around, but here is what I got:\nnutebook:Stuff nathan$ git remote rename master old\nerror: Could not rename config section 'remote.master' to 'remote.old'\n\nI use GitHub and Git-Tower."
},
{
"role": "assistant",
"content": "The following is a guide to rename your master branch. It will work just as easily to rename your experimental branch.\n\nHere's how I did the renaming.\nFirst, in your working tree, locally rename master to something\n else.\ngit branch -m master old-dev\n\nRenaming a branch does work while you are on the branch, so\n there's no need to checkout something else.\nThen, locally rename the maintenance branch (2.63-branch) to\n master:\ngit branch -m 2.63-branch master\n\nNow, time to mess with the remote. Just in case you screw up, you\n might want to make sure you have a current backup. First, delete the\n remote's master:\ngit push origin :master\n\nAnd now, give the remote your new master:\ngit push origin master:refs/heads/master\n\nUpdate: When creating a new branch, the refs/heads/ prefix is\n needed on the remote side. If the branch already exists (as master did\n above) only the branch name is required on the remote side.\n... and your now-renamed old master:\ngit push origin old-dev:refs/heads/old-dev\n\nFinally, delete the old name of your maintenance branch to prevent\n confusion:\ngit push origin :2.63-branch\n\nClients will now get the 'new' master branch when they pull.\n\nsee this site."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-add - Add file contents to the index"
},
{
"role": "assistant",
"content": "EXAMPLES Adds content from all *.txt files under Documentation directory\nand its subdirectories: $ git add Documentation/\\*.txt Note that the asterisk * is quoted from the shell in this\nexample; this lets the command include the files from\nsubdirectories of Documentation/ directory. Considers adding content from all git-*.sh scripts: $ git add git-*.sh Because this example lets the shell expand the asterisk (i.e. you are\nlisting the files explicitly), it does not consider subdir/git-foo.sh ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database badEmail"
},
{
"role": "assistant",
"content": "(ERROR) Invalid email format in an author/committer line."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to re-commit a past commit if someone overwrote my commit\nJust faced an issue where someone overwritten my whole commit and there are lot of other commits on top of this, now I have to re-commit that particular commit. Any help would be appreciated.\nSomeone got merge conflict and while merging he lost my all changes. I don't know what he did, but my changes are not there. IN history my commit is there but If I am seeing above his merge my changes are reverted.\nNow I cannot revert his merge commit because it contains lots of files as compare to me also I don't want to change each file one by one manually. Is there any way to get back my changes without effecting other's."
},
{
"role": "assistant",
"content": "You can do that typing the following commands:\n$ git reflog\n\nthen select the ID of the commit that you want to retrieve.\nThen type the following command:\n$ git cherry-pick <'ID'>\n\nInstead of <'ID'> enter the ID from the above reflog.\nThen you will have the changes of that commit.\nNow check if anything is still remaining by:\n$ git status\n\nIf anything is in unstaged commit, then add it by the following commands and commit:\n$ git add -A //Any other option or the name of the file with the path that you want to commit\n$ git commit -m \"Your message here for that commit\"\n$ git push\n\nI hope this answer is what you are expecting for."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip patience"
},
{
"role": "assistant",
"content": "Deprecated synonym for diff-algorithm=patience ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: Find the most recent common ancestor of two branches\nHow to find the most recent common ancestor of two Git branches?"
},
{
"role": "assistant",
"content": "You are looking for git merge-base. Usage:\n$ git merge-base branch2 branch3\n050dc022f3a65bdc78d97e2b1ac9b595a924c3f2"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: difference \"git rebase origin/branch\" VS \"git rebase origin branch\"\nDoes anyone know what is the difference? Seems to me, it is the same. But when I run it, it didn't do the same thing:\ngit rebase origin/branch - ok rebases from remote branch\ngit rebase origin branch - makes conflicts"
},
{
"role": "assistant",
"content": "@Mar's answer is right and perfectly solved this question, just add one comment.\nif you want to rebase a branch based on remote master branch, git rebase origin/master is not enough, it will not get new commits directly from origin/master. You need to git fetch before git rebase origin/master.\nor you can use another way to rebase a branch.\n\nswitch to master git checkout master\ngit pull origin master\nswitch back to your own branch git checkout {your branch}\ngit rebase origin/master\n\nthen, your branch is updated to newest commits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git branch name - case sensitive or insensitive?\nI am a new git user and recently been handed with an out of date git repository to look after.\nThis is the original state ( output by git show-branch):\n! [cr232] CR 232 Release\n * [dev] Style Changes\n---------------\n * [dev] Style Changes\n * [dev^] SMS 5.4\n * [dev~2] Logo Change\n * [dev~3] SMS 5.3\n * [dev~4] SMS 5.2\n * [dev~5] SIT R-0.3.3 EDW SMS Layers\n * [dev~6] SIT Release R 0.3.0\n +* [cr232] CR 232 Release\n +* [cr232^] Dashboard Fix\n +* [cr232~2] Release for system testing\n\nNote that there is a branch called ‘dev’ at this point. Note that highlighted there are several references to dev (i.e. dev, dev^, dev~2 etc).\nFor my development purpose, I was trying to come up with a branch called ‘DEV’, all capital.\nSo I went ahead and create new branch (git branch DEV) and now running git show-branch –date-order:\n! [DEV] Style Changes\n ! [cr232] CR 232 Release\n * [dev] Style Changes\n---------------\n * [DEV] Style Changes\n * [DEV^] SMS 5.4\n * [DEV~2] Logo Change\n * [DEV~3] SMS 5.3\n * [DEV~4] SMS 5.2\n * [DEV~5] SIT R-0.3.3 EDW SMS Layers\n * [DEV~6] SIT Release R 0.3.0\n +* [cr232] CR 232 Release\n +* [cr232^] Dashboard Fix\n +* [cr232~2] Release for system testing\n\nNote that both dev and DEV are listed as branch. Note also that on the 5th line the references to dev have now changed to DEV (i.e. DEV, DEV^, DEV~2 etc).\nWhat is the 5th line output referring to? I would expect it to remain “dev” instead of being changed to “DEV” as the descriptions next to it refers to the description of old work during “dev” branch.\nI am trying to return back to how it was by modifying the DEV branch name to DV (running git branch –m DEV DV) and showing the branch now look like:\n! [DV] Style Changes\n ! [cr232] CR 232 Release\n * [dev] Style Changes\n---------------\n * [DV] Style Changes\n * [DV^] SMS 5.4\n * [DV~2] Logo Change\n * [DV~3] SMS 5.3\n * [DV~4] SMS 5.2\n * [DV~5] SIT R-0.3.3 EDW SMS Layers\n * [DV~6] SIT Release R 0.3.0\n +* [cr232] CR 232 Release\n +* [cr232^] Dashboard Fix\n +* [cr232~2] Release for system testing\n\nNote that the branch is now including DV and dev. Note also that the 5th line references to dev have now changed to DV (i.e. DV, DV^, DV~2 etc).\nIs there any way to get back to how it was during original state in term of the DV references? Did the git got confused and renamed my historic information with a branch that is similar and only differs by capital case?\nPlease assist on how I can fix this. Thanks heaps"
},
{
"role": "assistant",
"content": "Answering just the question in the subject line, without addressing anything about git show-branch (like ElpieKay, I never actually use git show-branch; it seems mainly mis-informative):\nGit branch names—and tag names, and all other reference names, as Git calls them—were originally intended to be case-sensitive.\nThis all works perfectly on Linux / Unix machines, where Git's code is case-sensitive to start with. When Git stores branch names in the file system as file names (which it only does sometimes), the file system is also case-sensitive.1\nIt sometimes fails on Windows and some MacOS systems. Specifically, it fails when Git stores references in individual files, whose names are derived from the reference name, and those file names are case-insensitive (e.g., case-preserving, but fold case during name-matching; or even converting everything to uppercase-only, as in the really old FAT 8.3 format, but we can hope no modern file system does this).\nAs noted above, Git does not always store reference names as file names. In fact, on initial clone, all the names are in a single file called .git/packed-refs,2 so at this point they are case sensitive. But they become \"unpacked\" over time,3 and then on some systems they become case-folding.\nBecause it sometimes fails on some systems, it's generally best to avoid using multiple reference names that differ only in case.\n\n1Of course, on modern Unix/Linux systems, you can now get access to case-preserving-but-case-insensitive file systems, and Windows and MacOS can now be told not to do case-folding for some file systems. (But if you change from the defaults, expect software that is intended for your box to fail, because it will. Things like Photoshop internally try to use files named foo and FOO and expect this to refer to the same file!)\n2This packed-references file has been around for quite a while, but not forever, and very early versions of Git may not use it. Internally, Git is acquiring a new \"pluggable reference name interface\" and future versions of Git might use neither this file, nor individual per-reference files.\n3In general, creating or updating a reference causes an unpacked reference file to come into existence. Running git pack-refs --all will replace unpacked references with packed ones, restoring full case-sensitivity. Without --all, git pack-refs only packs already-packed references, which is largely a useless mode of operation (it was intended for a case that is no longer used)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Python setuptools: How can I list a private repository under install_requires?\n\nI am creating a setup.py file for a project which depends on private GitHub repositories. The relevant parts of the file look like this:\nfrom setuptools import setup\nsetup(name='my_project',\n ...,\n install_requires=[\n 'public_package',\n 'other_public_package',\n 'private_repo_1',\n 'private_repo_2',\n ],\n dependency_links=[\n 'https://github.com/my_account/private_repo_1/master/tarball/',\n 'https://github.com/my_account/private_repo_2/master/tarball/',\n ],\n ...,\n)\n\nI am using setuptools instead of distutils because the latter does not support the install_requires and dependency_links arguments per this answer.\nThe above setup file fails to access the private repos with a 404 error - which is to be expected since GitHub returns a 404 to unauthorized requests for a private repository. However, I can't figure out how to make setuptools authenticate.\nHere are some things I've tried:\n\nUse git+ssh:// instead of https:// in dependency_links as I would if installing the repo with pip. This fails because setuptools doesn't recognize this protocol (\"unknown url type: git+ssh\"), though the distribute documentation says it should. Ditto git+https and git+http.\nhttps://<username>:<password>@github.com/... - still get a 404. (This method doesn't work with curl or wget from the command line either - though curl -u <username> <repo_url> -O <output_file_name> does work.)\nUpgrading setuptools (0.9.7) and virtualenv (1.10) to the latest versions. Also tried installing distribute though this overview says it was merged back into setuptools. Either way, no dice.\n\nCurrently I just have setup.py print out a warning that the private repos must be downloaded separately. This is obviously less than ideal. I feel like there's something obvious that I'm missing, but can't think what it might be. :)\nDuplicate-ish question with no answers here."
},
{
"role": "assistant",
"content": "I was trying to get this to work for installing with pip, but the above was not working for me. From [1] I understood the PEP508 standard should be used, from [2] I retrieved an example which actually does work (at least for my case).\nPlease note; this is with pip 20.0.2 on Python 3.7.4\nsetup(\n name='<package>',\n...\n install_requires=[\n '<normal_dependency>',\n # Private repository\n '<dependency_name> @ git+ssh://[email protected]/<user>/<repo_name>@<branch>',\n # Public repository\n '<dependency_name> @ git+https://github.com/<user>/<repo_name>@<branch>',\n ],\n)\n\nAfter specifying my package this way installation works fine (also with -e settings and without the need to specify --process-dependency-links).\nReferences\n[1] https://github.com/pypa/pip/issues/4187\n[2] https://github.com/pypa/pip/issues/5566"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-stash - Stash the changes in a dirty working directory away Interrupted workflow"
},
{
"role": "assistant",
"content": "When you are in the middle of something, your boss comes in and\ndemands that you fix something immediately. Traditionally, you would\nmake a commit to a temporary branch to store your changes away, and\nreturn to your original branch to make the emergency fix, like this: # ... hack hack hack ...\n$ git switch -c my_wip\n$ git commit -a -m \"WIP\"\n$ git switch master\n$ edit emergency fix\n$ git commit -a -m \"Fix in a hurry\"\n$ git switch my_wip\n$ git reset --soft HEAD^\n# ... continue hacking ... You can use git stash to simplify the above, like this: # ... hack hack hack ...\n$ git stash\n$ edit emergency fix\n$ git commit -a -m \"Fix in a hurry\"\n$ git stash pop\n# ... continue hacking ..."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "heroku and github at the same time\n\nSo I understand that heroku functions as a git repository, but let's say i want to use github as well as a repository. How do I set it up such that I have two repositories and both are in sync?"
},
{
"role": "assistant",
"content": "You can have multiple remotes on a git installation. You would have a github remote, and a heroku remote.\nAssuming you already have github setup, then you probably push to github with something like:\ngit push origin master\norigin is your remote, and master is your branch.\nFollow the instructions in getting started with Heroku choose your desired language and continue through the tutorial. This tutorial assumes that you already have github setup, and will show you how to create your heroku remote - via heroku create.\nYou then push to github as normal, and push to heroku via:\ngit push heroku master\nThe same format applies - heroku is your remote, and master is your branch. You are not overwriting your Github remote here, you are adding another, so you can still do both pushes via one commit with workflow such as:\ngit add .\ngit commit -m \"Going to push to Heroku and Git\"\ngit push origin master -- push to Github Master branch\ngit push heroku master -- push to Heroku"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.noPrefix"
},
{
"role": "assistant",
"content": "If set, git diff does not show any source or destination prefix."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Viewing full version tree in git\nI am using the command line version of Git and gitk. I want to see the full version tree, not just the part that is reachable from the currently checked out version. Is it possible?"
},
{
"role": "assistant",
"content": "if you happen to not have a graphical interface available you can also print out the commit graph on the command line:\ngit log --oneline --graph --decorate --all\n\nif this command complains with an invalid option --oneline, use:\ngit log --pretty=oneline --graph --decorate --all"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you fork your own repository on GitHub?\n\nI have a public repository on GitHub. I want to replicate/copy it and work on a new project based on this repository, but I don't want to affect how it is now. I tried forking it using the GitHub UI but it didn't do anything."
},
{
"role": "assistant",
"content": "I don't think you can fork your own repo.\nClone it and push it to a new repo is good but you need to:\ngit clone https://github.com/userName/Repo New_Repo\ncd New_Repo\ngit remote set-url origin https://github.com/userName/New_Repo\ngit remote add upstream https://github.com/userName/Repo\ngit push origin master\ngit push --all\n\n(see git push)\nSee the all process described at \"Fork your own project on GitHub\".\n\nSix years later (2016), you now have the GitHub importer which allows you to import a repo from another source... including GitHub.\nSee \"Importing a repository with GitHub Importer\"\n\nnarf's answer (upvoted) also illustrate that process.\nThat will allow you to create a new repository and import the full history of the old one into the new one, using its GitHub url.\nAgain: what you get is a copy, not a real fork: you cannot make pull request from the new repo to the old one.\nAgain (bis), as stated in the comments by mpersico, this is not a TRUE FORK.\n\nIf I have a foo which is the canonical source repo for an open source project that I want other people to fork and have access to do PR, then I do not want to work in that repo, I want a fork I can use to issue proper PRs against my project.\nI have solved this my creating a second account in GitHub and forking to that."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is a \"stale\" git branch?\n\nA \"Stale\" git branch is a term I've heard a lot. I know it has something to do with branches which are regarded as less useful or useless, but cannot find an exact definition. What is a \"stale\" git branch?"
},
{
"role": "assistant",
"content": "The oldest reference to \"stale\" is found in commit e194cd1 (Jan. 2007, Git 1.5.0), which detected \"stale tracking branches in remote\": when tracking a branch which was removed by the remote system.\nHence git remote prune.\nThat is the main definition for stale branch: a remote tracking branch (a local reference of a remote repo branch) which no longer tracks anything (because the actual branch on the remote repo is gone).\ngit remote show is able to list those.\n\nIncidentally, you have two other definitions of \"stale\" in the Git system:\n\nAnother reference to \"stale\" involves git reflog --stale-fix in commit 1389d9d (Git 1.5.0), for tracking \"broken commit\": a commit that is not reachable from any of the refs and there is a missing object among the commit, tree, or blob objects reachable from it that is not reachable from any of the\nrefs.\nThat helps fixing situation after running non reflog-aware git prune from an older git in the presence of reflogs.\nCommit 740fdd2 (March 2008, Git 1.5.5) also introduces \"stale\" for symbolic refs, when the ref they point to no longer exists. \n\n\nAs mentioned by @SteelToe: \nThe definition of a stale branch, as per GitHub documentation, is a branch that has not had any commits in the previous 3 months.\nThis generally indicates an old/unmaintained/not current branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitfaq - Frequently asked questions about using Git How do I specify my credentials when pushing over HTTP?"
},
{
"role": "assistant",
"content": "The easiest way to do this is to use a credential helper via the credential.helper configuration. Most systems provide a standard\nchoice to integrate with the system credential manager. For example,\nGit for Windows provides the wincred credential manager, macOS has the osxkeychain credential manager, and Unix systems with a standard\ndesktop environment can use the libsecret credential manager. All of\nthese store credentials in an encrypted store to keep your passwords or\ntokens secure. In addition, you can use the store credential manager which stores in a file\nin your home directory, or the cache credential manager, which does not\npermanently store your credentials, but does prevent you from being prompted for\nthem for a certain period of time. You can also just enter your password when prompted. While it is possible to\nplace the password (which must be percent-encoded) in the URL, this is not\nparticularly secure and can lead to accidental exposure of credentials, so it is\nnot recommended."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio\n\nI have one project on Gitlab and I worked with it for the last few days!\nNow i want pull project on my home PC but show me below error : \nInvocation failed Unexpected Response from Server: Unauthorized\n java.lang.RuntimeException: Invocation failed Unexpected Response from Server: Unauthorized\n at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassXmlRpcClient.handleInput(GitNativeSshAskPassXmlRpcClient.java:34)\n at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassApp.main(GitNativeSshAskPassApp.java:30)\n Caused by: java.io.IOException: Unexpected Response from Server: Unauthorized\n at org.apache.xmlrpc.LiteXmlRpcTransport.sendRequest(LiteXmlRpcTransport.java:231)\n at org.apache.xmlrpc.LiteXmlRpcTransport.sendXmlRpc(LiteXmlRpcTransport.java:90)\n at org.apache.xmlrpc.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:72)\n at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:194)\n at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:185)\n at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:178)\n\nMy android studio version is 3.4 !"
},
{
"role": "assistant",
"content": "Enabling credentials helper worked for me, using Android Studio 3.6.2 on Windows 10\nAndroidStudio -> File -> Settings -> Git -> Use credential helper"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %f"
},
{
"role": "assistant",
"content": "sanitized subject line, suitable for a filename"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I push to a pull request on github?\n\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-config - Get and set repository or global options am.threeWay"
},
{
"role": "assistant",
"content": "By default, git am will fail if the patch does not apply cleanly. When\nset to true, this setting tells git am to fall back on 3-way merge if\nthe patch records the identity of blobs it is supposed to apply to and\nwe have those blobs available locally (equivalent to giving the --3way option from the command line). Defaults to false .\nSee git-am ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I rename a git stash?\nI have a stash with an incorrect name. I would like to fix the name so it's accurate. \nHow can I rename a stash?"
},
{
"role": "assistant",
"content": "Let's assume your stash list looks like this:\n$ git stash list\nstash@{0}: WIP on master: Add some very important feature \nstash@{1}: WIP on master: Fix some silly bug\n\nFirst, you must remove stash entry which you want to rename:\n$ git stash drop stash@{1}\nDropped stash@{1} (af8fdeee49a03d1b4609f294635e7f0d622e03db)\n\nNow just add it again with new message using sha of commit returned after dropping:\n$ git stash store -m \"Very descriptive message\" af8fdeee49a03d1b4609f294635e7f0d622e03db\n\nAnd that's it:\n$ git stash list\nstash@{0}: Very descriptive message\nstash@{1}: WIP on master: Add some very important feature\n\nThis solution requires git 1.8.4 or later, and yes, it works with dirty working directory too."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to diff between git tag and branch\nWhile trying to understand the difference between the HEAD of Appium 1.4 branch and tag v1.4.16, I didn't find a way to tell git diff to differentiate between the tag and the branch.\nAs far as I understand, from git diff's perspective, both the tag and the branch are just aliases to a commit hash, aren't they?\nI eventually just created tag 'v1.4' pointing to the branch head (git checkout 1.4; git tag -a v1.4) and then I could do git diff v1.4.16..v1.4 and see the difference I was after.\nBut this seems a bit strange, is this the only way to achieve what I needed?"
},
{
"role": "assistant",
"content": "Thanks everyone for the leading suggestions. The issue seems to be that I didn't have a local branch 1.4. I could achieve what I wanted (i.e. diff between the tag and the branch head on the original Git repo) in a couple of ways:\n\nSwitch to it (with git checkout 1.4), then I could do git diff v1.4.16\nRefer to it on the remote: git diff v1.4.16..origin/1.4\n\nBoth achieved what I wanted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --relative[=<path>] --no-relative"
},
{
"role": "assistant",
"content": "When run from a subdirectory of the project, it can be\ntold to exclude changes outside the directory and show\npathnames relative to it with this option. When you are\nnot in a subdirectory (e.g. in a bare repository), you\ncan name which subdirectory to make the output relative\nto by giving a <path> as an argument. --no-relative can be used to countermand both diff.relative config\noption and previous --relative ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects %cI"
},
{
"role": "assistant",
"content": "committer date, strict ISO 8601 format"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why do I have to \"git push --set-upstream origin <branch>\"?\nI created a local branch for testing Solaris and Sun Studio. I then pushed the branch upstream. After committing a change and attempting to push the changes:\n$ git commit blake2.cpp -m \"Add workaround for missing _mm_set_epi64x\"\n[solaris 7ad22ff] Add workaround for missing _mm_set_epi64x\n 1 file changed, 5 insertions(+)\n$ git push\nfatal: The current branch solaris has no upstream branch.\nTo push the current branch and set the remote as upstream, use\n\n git push --set-upstream origin solaris\n\nWhy do I have to do something special for this?\nIs there any reasonable use case where someone would create <branch>, push the <branch> to remote, and then claim a commit on <branch> is not supposed to be for <branch>?\n\nI followed this question and answer on Stack Overflow: Push a new local branch to a remote Git repository and track it too. I'm guessing it's another instance of an incomplete or wrong accepted answer. Or, it's another instance of Git taking a simple task and making it difficult.\n\nHere's the view on a different machine. The branch clearly exists, so it was created and pushed:\n$ git branch -a\n alignas\n* master\n remotes/origin/HEAD -> origin/master\n remotes/origin/alignas\n remotes/origin/arm-neon\n remotes/origin/det-sig\n remotes/origin/master\n remotes/origin/solaris"
},
{
"role": "assistant",
"content": "TL;DR: git branch --set-upstream-to origin/solaris\n\nThe answer to the question you asked—which I'll rephrase a bit as \"do I have to set an upstream\"—is: no, you don't have to set an upstream at all.\nIf you do not have upstream for the current branch, however, Git changes its behavior on git push, and on other commands as well.\nThe complete push story here is long and boring and goes back in history to before Git version 1.5. To shorten it a whole lot, git push was implemented poorly.1 As of Git version 2.0, Git now has a configuration knob spelled push.default which now defaults to simple. For several versions of Git before and after 2.0, every time you ran git push, Git would spew lots of noise trying to convince you to set push.default just to get git push to shut up.\nYou do not mention which version of Git you are running, nor whether you have configured push.default, so we must guess. My guess is that you are using Git version 2-point-something, and that you have set push.default to simple to get it to shut up. Precisely which version of Git you have, and what if anything you have push.default set to, does matter, due to that long and boring history, but in the end, the fact that you're getting yet another complaint from Git indicates that your Git is configured to avoid one of the mistakes from the past.\nWhat is an upstream?\nAn upstream is simply another branch name, usually a remote-tracking branch, associated with a (regular, local) branch.\nEvery branch has the option of having one (1) upstream set. That is, every branch either has an upstream, or does not have an upstream. No branch can have more than one upstream.\nThe upstream should, but does not have to be, a valid branch (whether remote-tracking like origin/B or local like master). That is, if the current branch B has upstream U, git rev-parse U should work. If it does not work—if it complains that U does not exist—then most of Git acts as though the upstream is not set at all. A few commands, like git branch -vv, will show the upstream setting but mark it as \"gone\".\nWhat good is an upstream?\nIf your push.default is set to simple or upstream, the upstream setting will make git push, used with no additional arguments, just work.\nThat's it—that's all it does for git push. But that's fairly significant, since git push is one of the places where a simple typo causes major headaches.\nIf your push.default is set to nothing, matching, or current, setting an upstream does nothing at all for git push.\n(All of this assumes your Git version is at least 2.0.)\nThe upstream affects git fetch\nIf you run git fetch with no additional arguments, Git figures out which remote to fetch from by consulting the current branch's upstream. If the upstream is a remote-tracking branch, Git fetches from that remote. (If the upstream is not set or is a local branch, Git tries fetching origin.)\nThe upstream affects git merge and git rebase too\nIf you run git merge or git rebase with no additional arguments, Git uses the current branch's upstream. So it shortens the use of these two commands.\nThe upstream affects git pull\nYou should never2 use git pull anyway, but if you do, git pull uses the upstream setting to figure out which remote to fetch from, and then which branch to merge or rebase with. That is, git pull does the same thing as git fetch—because it actually runs git fetch—and then does the same thing as git merge or git rebase, because it actually runs git merge or git rebase.\n(You should usually just do these two steps manually, at least until you know Git well enough that when either step fails, which they will eventually, you recognize what went wrong and know what to do about it.)\nThe upstream affects git status\nThis may actually be the most important. Once you have an upstream set, git status can report the difference between your current branch and its upstream, in terms of commits.\nIf, as is the normal case, you are on branch B with its upstream set to origin/B, and you run git status, you will immediately see whether you have commits you can push, and/or commits you can merge or rebase onto.\nThis is because git status runs:\n\ngit rev-list --count @{u}..HEAD: how many commits do you have on B that are not on origin/B?\ngit rev-list --count HEAD..@{u}: how many commits do you have on origin/B that are not on B?\n\nSetting an upstream gives you all of these things.\nHow come master already has an upstream set?\nWhen you first clone from some remote, using:\n$ git clone git://some.host/path/to/repo.git\n\nor similar, the last step Git does is, essentially, git checkout master. This checks out your local branch master—only you don't have a local branch master.\nOn the other hand, you do have a remote-tracking branch named origin/master, because you just cloned it.\nGit guesses that you must have meant: \"make me a new local master that points to the same commit as remote-tracking origin/master, and, while you're at it, set the upstream for master to origin/master.\"\nThis happens for every branch you git checkout that you do not already have. Git creates the branch and makes it \"track\" (have as an upstream) the corresponding remote-tracking branch.\nBut this doesn't work for new branches, i.e., branches with no remote-tracking branch yet.\nIf you create a new branch:\n$ git checkout -b solaris\n\nthere is, as yet, no origin/solaris. Your local solaris cannot track remote-tracking branch origin/solaris because it does not exist.\nWhen you first push the new branch:\n$ git push origin solaris\n\nthat creates solaris on origin, and hence also creates origin/solaris in your own Git repository. But it's too late: you already have a local solaris that has no upstream.3\nShouldn't Git just set that, now, as the upstream automatically?\nProbably. See \"implemented poorly\" and footnote 1. It's hard to change now: There are millions4 of scripts that use Git and some may well depend on its current behavior. Changing the behavior requires a new major release, nag-ware to force you to set some configuration field, and so on. In short, Git is a victim of its own success: whatever mistakes it has in it, today, can only be fixed if the change is either mostly invisible, clearly-much-better, or done slowly over time.\nThe fact is, it doesn't today, unless you use --set-upstream or -u during the git push. That's what the message is telling you.\nYou don't have to do it like that. Well, as we noted above, you don't have to do it at all, but let's say you want an upstream. You have already created branch solaris on origin, through an earlier push, and as your git branch output shows, you already have origin/solaris in your local repository.\nYou just don't have it set as the upstream for solaris.\nTo set it now, rather than during the first push, use git branch --set-upstream-to. The --set-upstream-to sub-command takes the name of any existing branch, such as origin/solaris, and sets the current branch's upstream to that other branch.\nThat's it—that's all it does—but it has all those implications noted above. It means you can just run git fetch, then look around, then run git merge or git rebase as appropriate, then make new commits and run git push, without a bunch of additional fussing-around.\n\n1To be fair, it was not clear back then that the initial implementation was error-prone. That only became clear when every new user made the same mistakes every time. It's now \"less poor\", which is not to say \"great\".\n2\"Never\" is a bit strong, but I find that Git newbies understand things a lot better when I separate out the steps, especially when I can show them what git fetch actually did, and they can then see what git merge or git rebase will do next.\n3If you run your first git push as git push -u origin solaris—i.e., if you add the -u flag—Git will set origin/solaris as the upstream for your current branch if (and only if) the push succeeds. So you should supply -u on the first push. In fact, you can supply it on any later push, and it will set or change the upstream at that point. But I think git branch --set-upstream-to is easier, if you forgot.\n4Measured by the Austin Powers / Dr Evil method of simply saying \"one MILLLL-YUN\", anyway."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc diff.ignoreSubmodules"
},
{
"role": "assistant",
"content": "Sets the default value of --ignore-submodules. Note that this\naffects only git diff Porcelain, and not lower level diff commands such as git diff-files . git checkout and git switch also honor\nthis setting when reporting uncommitted changes. Setting it to all disables the submodule summary normally shown by git commit and git status when status.submoduleSummary is set unless it is\noverridden by using the --ignore-submodules command-line option.\nThe git submodule commands are not affected by this setting.\nBy default this is set to untracked so that any untracked\nsubmodules are ignored."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cherry-pick - Apply the changes introduced by some existing commits --rerere-autoupdate --no-rerere-autoupdate"
},
{
"role": "assistant",
"content": "After the rerere mechanism reuses a recorded resolution on\nthe current conflict to update the files in the working\ntree, allow it to also update the index with the result of\nresolution. --no-rerere-autoupdate is a good way to\ndouble-check what rerere did and catch potential\nmismerges, before committing the result to the index with a\nseparate git add ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Use a different user.email and user.name for Git config based upon remote clone URL\nI configure my global ~/.gitconfig properties user.name and user.email like this:\n\ngit config --global user.email \"[email protected]\" \ngit config --global user.name \"mkobit\"\n\nThis is the default configuration I want for working on personal projects, open source stuff, etc.\nWhen I am working on a project from a specific domain, a corporate domain for example, I am configuring it for each repository when I clone it so that it uses a different user.name/user.email:\ngit clone ssh://[email protected]:1234/groupA/projectA.git\ncd projectA\ngit config user.email \"[email protected]\"\ngit config user.name \"m.kobit\"\n\nOne decent option would be to setup an alias for cloning these kinds of repositories:\ngit config --global alias.clonecorp 'clone \\ \n -c user.name=\"m.kobit\" -c user.email=\"[email protected]\"'\ngit clonecorp ssh://[email protected]:1234/groupA/projectA.git\n\nBoth of these can be error prone because they both depend on me being smart and following the right steps. Evidence shows that this is near-guaranteed for me to screw-up sometime.\nIs there a way to configure Git such that repositories from a certain domain (the mycorp.com in this example) will be configured a certain way?"
},
{
"role": "assistant",
"content": "The release of Git 2.13 has introduced a feature called conditional includes. In 2.13 the only supported configuration is filesystem path. That is easy to use in this case because I am already separating them. \nThe example provided on the release notes is:\n\nYou can configure two conditional includes in your home directory's ~/.gitconfig file:\n[includeIf \"gitdir:~/work/\"]\n path = .gitconfig-work\n[includeIf \"gitdir:~/play/\"]\n path = .gitconfig-play\n\nNow you can put whatever options you want into those files:\n$ cat ~/.gitconfig-work\n[user]\nname = Serious Q. Programmer\nemail = [email protected]\n\n$ cat ~/.gitconfig-play\n[user]\nname = Random J. Hacker\nemail = [email protected]\n\n\n\nOld answer\nIn Git 2.8, a global configuration user.useconfigonly has been added that insists the user set their user.email and user.name are set before committing. Here is the relevant text from the linked blog post by Github:\n\nBut if, say, you want Git to use one email address for your open source projects and a different one for your work projects, you've undoubtedly made the mistake of committing to a new Git repository without having first set your email address in that repository. In this situation, Git emits a warning, but it creates the commit anyway, using an email address that it guesses from the local system hostname. If you're trying to do something as complicated as different addresses for different projects, this is almost certainly not what you want.\nNow you can tell Git not to guess, but rather to insist that you set user.name and user.email explicitly before it will let you commit:\ngit config --global user.useconfigonly true\n\n\nThis doesn't solve the auto-config based on certain clone URLs, but does make the process a little bit less error prone by forcing configuration at the start."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I print the log for a branch other than the current one? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I run git log to see changes only for a specific branch?\n\n (10 answers)\n \n\nClosed 10 months ago.\n\n\n\nI'm on a branch with some changes. Changing branch is a pain as some files are locked by processes, so to change branch I'd have to stop all the processes which have locks, then stash the changes before checking out the other branch to see its log.\nIs it possible to view the log for a different branch, without having to check it out?"
},
{
"role": "assistant",
"content": "TL;DR\nUse\ngit log <branch>\n\nwhere <branch> is the name of the branch of interest.\nFrom the git-log man-page...\nA simplified version of the git-log synopsis given in that command's man page is\ngit log [<revision range>]\n\nFurther down, you can find the following passage:\n\nWhen no <revision range> is specified, it defaults to HEAD (i.e. the whole history leading to the current commit)\n\nIn others words, git log is equivalent to git log HEAD. If you're on a branch, called mybranch, say, this command is also equivalent to git log mybranch.\nYou want to limit the log to commits reachable from another branch, i.e. a branch you're not currently on. The easiest way to do that is to explicitly pass the name of the branch of interest to git log:\ngit log <branchname>\n\nSee the gitrevisions manpage for more details about the many forms that the <revision-range> argument can take."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab api to get commits in a merge request\n\nFrom the GITLAB API documentation, I can get the merge request details,\nfrom which I can get the source project and the branch.\nThe api to get the list of commits in the branch, list all the commits in that branch.\nIs there a way to get the list of commits specific to a merge request through API.?\nThe objective is to know only the new commits in the merge request.\nThank You."
},
{
"role": "assistant",
"content": "I think you are looking for this:\ncurl --header \"PRIVATE-TOKEN: ****\" \"http://gitlab/api/v3/projects/:project_id:/merge_requests/:mr_id:/commits\"\n\nhttps://docs.gitlab.com/ce/api/merge_requests.html#get-single-mr-commits"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-rebase"
},
{
"role": "assistant",
"content": "Reapply commits on top of another base tip"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "giteveryday - A useful minimum set of commands for Everyday Git Use a tarball as a starting point for a new repository."
},
{
"role": "assistant",
"content": "$ tar zxf frotz.tar.gz\n$ cd frotz\n$ git init\n$ git add . (1) $ git commit -m \"import of frotz source tree.\"\n$ git tag v2.43 (2) add everything under the current directory. make a lightweight, unannotated tag."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git with SSH on Windows\nI've went through the excellent guide provided by Tim Davis which is about configuring Git to work with SSH under Windows in order to produce a Git Server in order to have a main place for my DVCS.\nI am in the process of creating a clone for my project. I’ve went through all the steps till this point, but I keep getting this from TortoiseGit:\ngit.exe clone -v “ssh://[email protected]:22/SSH/Home/administrator/myapp.git” “E:\\GitTest\\myapp”\n\nbash: [email protected]: command not found\nInitialized empty Git repository in E:/GitTest/myapp/.git/\nfatal: The remote end hung up unexpectedly\nSuccess\n\nand nothing gets cloned.\nBTW: The TortoisePLink comes up just before this message appears and asks me: “login as:” ( I thought that this info is given in the command, i.e: Administrator@blahblah.\nMy home variable is set to the correct place:\nFrom a Git Bash shell:\necho $HOME\n/c/SSH/home/Administrator\n\nI’ve also tried using Putty’s plink instead of TortoisePLink (in both Git’s and TortoiseGit’s installation). This time the error was narrowed down to:\ngit.exe clone -v “ssh://[email protected]:22/c:/SSH/Home/administrator/myapp.git” “E:\\GitTest\\myapp”\n\nInitialized empty Git repository in E:/GitTest/myapp/.git/\nfatal: The remote end hung up unexpectedly"
},
{
"role": "assistant",
"content": "I fought with this problem for a few hours before stumbling on the obvious answer. The problem I had was I was using different ssh implementations between when I generated my keys and when I used git.\nI used ssh-keygen from the command prompt to generate my keys and but when I tried \"git clone ssh://...\" I got the same results as you, a prompt for the password and the message \"fatal: The remote end hung up unexpectedly\".\nDetermine which ssh windows is using by executing the Windows \"where\" command.\nC:\\where ssh\nC:\\Program Files (x86)\\Git\\bin\\ssh.exe\n\nThe second line tells you which exact program will be executed.\nNext you need to determine which ssh that git is using. Find this by:\nC:\\set GIT_SSH\nGIT_SSH=C:\\Program Files\\TortoiseSVN\\bin\\TortoisePlink.exe\n\nAnd now you see the problem.\nTo correct this simply execute:\nC:\\set GIT_SSH=C:\\Program Files (x86)\\Git\\bin\\ssh.exe\n\nTo check if changes are applied:\nC:\\set GIT_SSH\nGIT_SSH=C:\\Program Files (x86)\\Git\\bin\\ssh.exe\n\nNow git will be able to use the keys that you generated earlier.\nThis fix is so far only for the current window. To fix it completely you need to change your environment variable.\n\nOpen Windows explorer\nRight-click Computer and select Properties\nClick Advanced System Settings link on the left\nClick the Environment Variables... button\nIn the system variables section select the GIT_SSH variable and press the Edit... button\nUpdate the variable value.\nPress OK to close all windows\n\nNow any future command windows you open will have the correct settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Combining multiple git repositories\nLet's say I've got a setup that look something like\nphd/code/\nphd/figures/\nphd/thesis/\n\nFor historical reasons, these all have their own git repositories. But I'd like to combine them into a single one to simplify things a little. For example, right now I might make two sets of changes and have to do something like\ncd phd/code\ngit commit \ncd ../figures\ngit commit\n\nIt'd be (now) nice to just to perform\ncd phd\ngit commit\n\nThere seems to be a couple of ways of doing this using submodules or pulling from my sub-repositories, but that's a little more complex than I'm looking for. At the very least, I'd be happy with\ncd phd\ngit init\ngit add [[everything that's already in my other repositories]]\n\nbut that doesn't seem like a one-liner. Is there anything in git that can help me out?"
},
{
"role": "assistant",
"content": "Here's a solution I gave here:\n\nFirst do a complete backup of your phd directory: I don't want to be held responsible for your losing years of hard work! ;-)\n $ cp -r phd phd-backup\n\n\nMove the content of phd/code to phd/code/code, and fix the history so that it looks like it has always been there (this uses git's filter-branch command):\n $ cd phd/code\n $ git filter-branch --index-filter \\\n 'git ls-files -s | sed \"s#\\t#&code/#\" |\n GIT_INDEX_FILE=$GIT_INDEX_FILE.new \\\n git update-index --index-info &&\n mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE' HEAD\n\n\nSame for the content of phd/figures and phd/thesis (just replace code with figures and thesis).\n\n\nNow your directory structure should look like this:\n phd\n |_code\n | |_.git\n | |_code\n | |_(your code...)\n |_figures\n | |_.git\n | |_figures\n | |_(your figures...)\n |_thesis\n |_.git\n |_thesis\n |_(your thesis...)\n\n\nThen create a git repository in the root directory, pull everything into it and remove the old repositories:\n $ cd phd\n $ git init\n\n $ git pull code\n $ rm -rf code/code\n $ rm -rf code/.git\n\n $ git pull figures --allow-unrelated-histories\n $ rm -rf figures/figures\n $ rm -rf figures/.git\n\n $ git pull thesis --allow-unrelated-histories\n $ rm -rf thesis/thesis\n $ rm -rf thesis/.git\n\n\n\nFinally, you should now have what you wanted:\n phd\n |_.git\n |_code\n | |_(your code...)\n |_figures\n | |_(your figures...)\n |_thesis\n |_(your thesis...)\n\nOne nice side to this procedure is that it will leave non-versioned files and directories in place.\n\nJust one word of warning though: if your code directory already has a code subdirectory or file, things might go very wrong (same for figures and thesis of course). If that's the case, just rename that directory or file before going through this whole procedure:\n$ cd phd/code\n$ git mv code code-repository-migration\n$ git commit -m \"preparing the code directory for migration\"\n\nAnd when the procedure is finished, add this final step:\n$ cd phd\n$ git mv code/code-repository-migration code/code\n$ git commit -m \"final step for code directory migration\"\n\nOf course, if the code subdirectory or file is not versioned, just use mv instead of git mv, and forget about the git commits."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-daemon - A really simple server for Git repositories --interpolated-path=<pathtemplate>"
},
{
"role": "assistant",
"content": "To support virtual hosting, an interpolated path template can be\nused to dynamically construct alternate paths. The template\nsupports %H for the target hostname as supplied by the client but\nconverted to all lowercase, %CH for the canonical hostname,\n%IP for the server’s IP address, %P for the port number,\nand %D for the absolute path of the named repository.\nAfter interpolation, the path is validated against the directory\nlist."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "ssh: Could not resolve hostname git: Name or service not known fatal: Could not read from remote repository\n\nAfter I switched from HTTPS to SSH for my repo then I received this error when pushing to origin master:\nssh: Could not resolve hostname git: 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 also add my ssh in the gitlab. What should I do?"
},
{
"role": "assistant",
"content": "I was getting the same error.\n\nThis error typically occurs when there is an issue with the SSH configuration or the Git remote repository's hostname cannot be resolved.\n\nHere, you can check your remote by running:\ngit remote -v\n\nThere are few reasons why this error occurs:\n\nIncorrect Hostname\nSSH Configuration\nNetwork Connection\nDNS Resolution\nFirewall or Proxy\n\nTypically, you can solve this by Change the [remote \"origin\"] URL value in .gitconfig or .config/git/config file\nPreviously:\nhttps://[email protected]:userName/repo.git\n\nOR\nssh://[email protected]:userName/repo.git\n\nNew:\n[email protected]:userName/repo.git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git stash: \"Cannot apply to a dirty working tree, please stage your changes\"\nI am trying to apply changes I stashed earlier with git stash pop and get the message:\nCannot apply to a dirty working tree, please stage your changes\n\nAny suggestion on how to deal with that?"
},
{
"role": "assistant",
"content": "When I have to apply stashed changes to a dirty working copy, e.g. pop more than one changeset from the stash, I use the following:\n$ git stash show -p | git apply -3 && git stash drop\n\nBasically it \n\ncreates a patch\npipes that to the apply command\nif there are any conflicts they will need to be resolved via 3-way merge\nif apply (or merge) succeeded it drops the just applied stash item...\n\nI wonder why there is no -f (force) option for git stash pop which should exactly behave like the one-liner above.\nIn the meantime you might want to add this one-liner as a git alias:\n$ git config --global --replace-all alias.unstash \\\n '!git stash show -p | git apply -3 && git stash drop'\n$ git unstash\n\n\nThanks to @SamHasler for pointing out the -3 parameter which allows to resolve conflicts directly via 3-way merge."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to add Google Analytics Tracking ID to GitHub Pages\n\nCould be a simple question but I am full of doubts right now about adding Google Analytics Tracking ID to GitHub page.\nI am using GitHub automatic page generator to create my GitHub page but it asks for \"Google Analytics Tracking ID\". I tried to sign up with Google Analytics but there on it asks for website URL.\nNow what I am supposed to do? \nOne more ques: can we add Google Analytics Tracking ID later on after GitHub Page has been created?"
},
{
"role": "assistant",
"content": "Update: Added steps descriptions for others \nSolved it:\nhad to include username.github.io (link that I want to track) in Google Analytics website section.\nyou can check GitHub help page here \n\n\n\nAfter that I was provided with an Tracker ID. \n\nNote: You can easily change or add more websites on Google Analytics page from your Google Analytics admin panel.\n\nUpdate 2: - Adding Google Analytics Tracking ID to Already created Github pages (As requested by @avi-aryan ) \n\nBrowse to your github pages branch - which would be something like - ( https://github.com/YourUserName/YourRepository/tree/gh-pages ) \nThen edit index.html from listed files\nNow in within HEAD tag of index.html - paste your Google Analytics Tracking ID Script ( if have already signed up for Google analytics then you can browse it under admin and then tracking info tab )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What's an easy way to detect modified files in a Git workspace?\nDuring make, I create string fields which I embedded in the linked output. Very useful. \nOther than a complex sed/grep parsing of the git status command, how can I easily determine if files in the workspace have been modified according to git?"
},
{
"role": "assistant",
"content": "If you just want a plain “Are there any differences from HEAD?”:\ngit diff-index --quiet HEAD\n\nIf the exit code is 0, then there were no differences.\nIf you want “What files have changed from HEAD?”:\ngit diff-index --name-only HEAD\n\nIf you want “What files have changed from HEAD, and in what ways have they changed (added, deleted, changed)?”:\ngit diff-index --name-status HEAD\n\nAdd -M (and -C) if you want rename (and copy) detection.\nThese commands will check both the staged contents (what is in the index) and the files in the working tree. Alternatives like git ls-files -m will only check the working tree against the index (i.e. they will disregard any staged (but uncommitted) content that is also in the working tree)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: error: RPC failed; result=22, HTTP code = 411\nSymptoms:\nGit suddenly refused to push a repository (to github in my case):\n$ git push\nCounting objects: 9292, done.\nDelta compression using up to 8 threads.\nCompressing objects: 100% (2136/2136), done.\nerror: RPC failed; result=22, HTTP code = 411\nfatal: The remote end hung up unexpectedly\nWriting objects: 100% (8222/8222), 1.27 MiB | 837 KiB/s, done.\nTotal 8222 (delta 6060), reused 8181 (delta 6033)\nfatal: The remote end hung up unexpectedly\nEverything up-to-date"
},
{
"role": "assistant",
"content": "Here is what helped, the following command increases git buffer to 500mb:\ngit config http.postBuffer 524288000"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Use of an exclamation mark in a Git commit message via the command line\nHow do I enter an exclamation point into a Git commit message from the command line?\nIt is possible to escape the exclamation point with a backslash, but then the backslash ends up in the commit message as well.\nI want something like this:\ngit commit -am \"Nailed it!\""
},
{
"role": "assistant",
"content": "Use single quotes instead of double quotes\ngit commit -am 'Nailed it!'\n\nAlternatively, if you need to use double quotes for whatever reason but still want a literal ! then turn off history expansion at the top of your script via set +H"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-restore"
},
{
"role": "assistant",
"content": "Restore working tree files"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitattributes - Defining attributes per path"
},
{
"role": "assistant",
"content": "DEFINING MACRO ATTRIBUTES Custom macro attributes can be defined only in top-level gitattributes\nfiles ( $GIT_DIR/info/attributes , the .gitattributes file at the\ntop level of the working tree, or the global or system-wide\ngitattributes files), not in .gitattributes files in working tree\nsubdirectories. The built-in macro attribute \"binary\" is equivalent\nto: [attr]binary -diff -merge -text"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker githooks"
},
{
"role": "assistant",
"content": "Hooks used by Git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git : fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists\nI am getting this error - \nD:\\Projects\\wamp\\www\\REPO [master]> git pull origin master\nWarning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of known hosts.\nERROR: Repository not found.\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nThe output of git remote -v\nD:\\Projects\\wamp\\www\\REPO [master]> git remote -v\norigin [email protected]:username/repo.git (fetch)\norigin [email protected]:username/repo.git (push)\n\nFinal message of ssh -Tv [email protected] command - \nHi [My Username]! You've successfully authenticated, but GitHub does not provide shell access.\n\nHow can I solve it?"
},
{
"role": "assistant",
"content": "change your ssh url by an http url for your remote 'origin', use:\n> git remote set-url origin https://github.com/<user_name>/<repo_name>.git\n\nIt will ask for your GitHub password on the git push."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Renaming a branch in GitHub\nI just renamed my local branch using\ngit branch -m oldname newname\n\nbut this only renames the local version of the branch. How can I rename the one on GitHub?"
},
{
"role": "assistant",
"content": "As mentioned, delete the old one on GitHub and re-push, though the commands used are a bit more verbose than necessary:\ngit push origin :name_of_the_old_branch_on_github\ngit push origin new_name_of_the_branch_that_is_local\n\nDissecting the commands a bit, the git push command is essentially:\ngit push <remote> <local_branch>:<remote_branch>\n\nSo doing a push with no local_branch specified essentially means \"take nothing from my local repository, and make it the remote branch\". I've always thought this to be completely kludgy, but it's the way it's done.\nAs of Git 1.7 there is an alternate syntax for deleting a remote branch:\ngit push origin --delete name_of_the_remote_branch\n\nAs mentioned by @void.pointer in the comments\n\nNote that you can combine the 2 push operations:\ngit push origin :old_branch new_branch\nThis will both delete the old branch and push the new one.\n\nThis can be turned into a simple alias that takes the remote, original branch and new branch name as arguments, in ~/.gitconfig:\n[alias]\n branchm = \"!git branch -m $2 $3 && git push $1 :$2 $3 -u #\"\n\nUsage:\ngit branchm origin old_branch new_branch\n\nNote that positional arguments in shell commands were problematic in older (pre 2.8?) versions of Git, so the alias might vary according to the Git version. See this discussion for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-count-objects - Count unpacked number of objects and their disk consumption"
},
{
"role": "assistant",
"content": "DESCRIPTION Counts the number of unpacked object files and disk space consumed by\nthem, to help you decide when it is a good time to repack."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Switching between multiple ssh keys in Git on Windows\nI need to have multiple keys in my client to access two different accounts on Repository hosting. See https://redefy.repositoryhosting.com/support -> How do I manage multiple accounts with multiple keypairs on my client?\nI do not understand how to change between different ssh keys in Git on Windows, can anybody help me?"
},
{
"role": "assistant",
"content": "I assume you use git bash and openssh.\nLike what it's written in the article, you can make a configuration file for ssh client that lists all of your accounts. You can write the following configuration in your own ssh client configuration file in ~/.ssh/config\nHost account-one\nHostName server.example.com\nUser user-one\nIdentityFile ~/.ssh/key-one\n\nHost account-two\nHostName server.example.com\nUser user-two\nIdentityFile ~/.ssh/key-two\n\nWhat it says is you define two, kind of, \"host aliases\" named account-one and account-two. If you use them, when making connection, the ssh client will use the corresponding HostName, User, and IdentityFile for the server address, username, and ssh key file. With this you can use them to access your accounts and keys at even the same server.\nIn git, you can define two remotes using them\n$ git remote add one account-one:repository.git\n$ git remote add two account-two:repository.git\n\nthen you can push to those remotes\n$ git push one master\n$ git push two master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "fatal: unable to access 'https://dev.azure.com/xxx': OpenSSL SSL_connect: Connection was reset in connection to dev.azure.com:443\nI've been working with a repo in Azure for months without any issue, but recently started getting this error intermittently when I try to update my remotes or push/pull:\nOpenSSL SSL_connect: Connection was reset in connection to dev.azure.com:443\nIf I keep retrying, it will eventually work. No idea what is causing this.\nThings I've tried:\n\nUpdated Git\nTurned off firewall\nTried on a different computer with no issues"
},
{
"role": "assistant",
"content": "This seems to have something to do with IPv6 - you can disable it by doing the following:\n\nGo to View Network Connections\n\n\nRight click on your current network and select Properties\n\n\nDeselect IPv6 Internet Prorotcol Version 6"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout-index - Copy files from the index to the working tree"
},
{
"role": "assistant",
"content": "NAME git-checkout-index - Copy files from the index to the working tree"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to add my current project to an already existing GitHub repository\n\nI'm very new to Git. I've been searching for an answer, but I couldn't find one.\nIn my computer I have a project folder like this:\nproject_a\n--some_folder\n--another_folder\n--.git\n\nAnd I have a repository on GitHub, let’s say https://github.com/company/our_repo.git. Under this repository I have some folders. So my goal is to put my project_a under trunk/bin. How do I achieve this? (Again, I'm very very very new.)"
},
{
"role": "assistant",
"content": "Open your Terminal, access to this folder and write:\ngit init\ngit add .\ngit commit -m \"my commit\"\ngit remote set-url origin [email protected]:username/repo.git\ngit push origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Download github release with curl\n\nOn this URL I'm able to download a .tar.gz which contains an official release. (I know it's also available on an API endpoint but this contains the test package too.\nNow I'm wondering why this isn't working:\n$ curl -O https://github.com/yarnpkg/yarn/releases/download/v0.23.4/yarn-v0.23.4.tar.gz\n\nI get some .tar.gz which is 4KB instead of 3.6MB. It isn't showing an error. What am I missing? I want to use this URL and not the API if that's possible."
},
{
"role": "assistant",
"content": "If you do the following it will download correctly:\nwget https://github.com/yarnpkg/yarn/releases/download/v0.23.4/yarn-v0.23.4.tar.gz\n\nIf you want to use curl you have to use the redirect -L option to follow redirect link and direct the output in a file like this:\ncurl -L https://github.com/yarnpkg/yarn/releases/download/v0.23.4/yarn-v0.23.4.tar.gz > yarn.tar.gz"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clone - Clone a repository into a new directory -n --no-checkout"
},
{
"role": "assistant",
"content": "No checkout of HEAD is performed after the clone is complete."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-add"
},
{
"role": "assistant",
"content": "Add file contents to the index"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together"
},
{
"role": "assistant",
"content": "NAME git-merge - Join two or more development histories together"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub search - how to exclude (logical NOT) company or user from search results\n\nIn this search query (test it live ↗) I'm searching for:\n\nall pull requests \nby user limonte (me)\nfor the vaadin company\n\nHow can I search for all my pull requests except (logical NOT) those for vaadin company?\n\nThese two options I tried without success: \n\nis:pr author:limonte user:!vaadin\nis:pr author:limonte user:NOT vaadin"
},
{
"role": "assistant",
"content": "Prefixing any search qualifier with a - excludes all results that are matched by that qualifier.\nFor example, you might be interested in finding all \"cats\" repositories with more than 10 stars that are not written in JavaScript:\ncats stars:>10 -language:javascript\n\nYou might also want to find all issues mentioning @defunkt that are not in repositories in the GitHub organization:\nmentions:defunkt -user:github\n\n\nThe answer for your question is:\n\nis:pr author:limonte -user:vaadin\n\n\nFor more refer the GitHub Search Syntax"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-read-tree - Reads tree information into the index --empty"
},
{
"role": "assistant",
"content": "Instead of reading tree object(s) into the index, just empty\nit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --color[=<when>]"
},
{
"role": "assistant",
"content": "Show colored diff. --color (i.e. without =<when> ) is the same as --color=always . <when> can be one of always , never , or auto .\nIt can be changed by the color.ui and color.diff configuration settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Pylint badge in gitlab\n\nGitlab has functionality to generade badges about build status and coverage percentage.\nIs it possible to create custom badge to display Pylint results?\nOr just display this results in README.md?\nI already have CI job for Pylint"
},
{
"role": "assistant",
"content": "I have written a python badge generation package that produces badges very visually similar to the main badge services. It is highly flexible, you can import and use in your python code, or run from the command line.\nI use this in GitLab CI to display pylint and coverage scores.\nThere are other ways to do this using shields.io (see other answer from kubouch), but this approach can be used in situations where you may not have external internet access, such as in a corporate / enterprise setting where firewalls or proxies are blocking internet access.\nGitLab CI Setup\n1. Generate the badge\nMy CI pipeline has a step that runs pylint, and I used sed to extract the score from the output text. I then use anybadge (details below) to generate a pylint score badge, and save it as public/pylint.svg.\npylint:\n stage: test\n script:\n - pylint --rcfile=.pylintrc --output-format=text <LIST-OF-FILES-TO-RUN-PYLINT-AGAINST> | tee pylint.txt\n - score=$(sed -n 's/^Your code has been rated at \\([-0-9.]*\\)\\/.*/\\1/p' pylint.txt)\n - echo \"Pylint score was $score\"\n - anybadge --value=$score --file=public/pylint.svg pylint\n\nIf pylint generates a non-zero rc then GitLab will see that as a command error and the job will fail, meaning no badge is generated, and missing image will show where the badge is used.\nNOTE: pylint WILL OFTEN generate non-zero return codes since it uses the exit code to communicate the status of the lint check. I suggest using something like pylint-exit to handle pylint return codes in CI pipelines.\n2. Register badge as pipeline artifact\nI register the generated badge file as an artifact in the CI job by including this in the .gitlab-ci.yml:\npylint:\n ...\n - echo \"Pylint score was $score\"\n - anybadge --value=$score --file=public/pylint.svg pylint\n artifacts:\n paths:\n - public/pylint.svg\n\n3. Publish badge to GitLab Pages\nI include a pages publish step, which deploys everything in the public directory to GitLab pages:\npages:\n stage: deploy\n artifacts:\n paths:\n - public\n only:\n - master\n\n4. Include badge in README.md\nWhen the master pipeline runs for the project, the pylint.svg file is published to GitLab Pages, and I can then reference the image from my project README.md so that the latest pylint badge is displayed.\nIf you are using https://gitlab.com for your project then the URL for the svg artifact will usually be something like this (replace NAMESPACE with your username, or group name if your project is under a group - more details here):\nhttps://NAMESPACE.gitlab.io/pyling.svg\nIn your README.md you can include an image with:\n\n\nIf you want to make the image into a link you can use:\n[](LINKTARGET)\n\nLet me know if you need more information on any of the setup.\nAnybadge Python Package\nHere's some more info on the anybadge Python package:\nYou can set the badge label and value, and you can set the color based on thresholds. There are pre-built settings for pylint, coverage, and pipeline success, but you can create any badge you like.\nHere is a link to the github project with more detailed documentation: https://github.com/jongracecox/anybadge\nInstall with pip install anybadge\nExample python code:\nimport anybadge\n\n# Define thresholds: <2=red, <4=orange <8=yellow <10=green\nthresholds = {2: 'red',\n 4: 'orange',\n 6: 'yellow',\n 10: 'green'}\n\nbadge = anybadge.Badge('pylint', 2.22, thresholds=thresholds)\n\nbadge.write_badge('pylint.svg')\n\nExample command line use:\nanybadge --label pylint --value 2.22 --file pylint.svg 2=red 4=orange 8=yellow 10=green\n\nUpdate 2019\nUsing GitLab Pages is no longer required\nIt is now possible to directly access to the latest articfact, which simplify the workaround.\n\nUse a dedicated pylint artifact instead of public, and remove the unnecessary deploy step (or edit it if already used):\n\npylint:\n stage: test\n before_script:\n - pip install pylint pylint-exit anybadge\n script:\n - mkdir ./pylint\n - pylint --output-format=text . | tee ./pylint/pylint.log || pylint-exit $?\n - PYLINT_SCORE=$(sed -n 's/^Your code has been rated at \\([-0-9.]*\\)\\/.*/\\1/p' ./pylint/pylint.log)\n - anybadge --label=Pylint --file=pylint/pylint.svg --value=$PYLINT_SCORE 2=red 4=orange 8=yellow 10=green\n - echo \"Pylint score is $PYLINT_SCORE\"\n artifacts:\n paths:\n - ./pylint/\n\nNote that here I copy the Pylint log file in the folder artifact, in this way it will be accessible without looking at the pipeline logs.\nThe badge image will then be available at https://gitlab.example.com/john-doe/foo/-/jobs/artifacts/master/raw/pylint/pylint.svg?job=pylint, and the Pylint log at https://gitlab.example.com/john-doe/foo/-/jobs/artifacts/master/raw/pylint/pylint.log?job=pylint.\n2. You can use GitLab's builtin badges instead of images in README\nGitLab can now include badges in a projet or group, that will be displayed in the project header.\nGot to Settings / General / Badges, then create a new badge by setting its link and image link, as described above:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index <patch>…"
},
{
"role": "assistant",
"content": "The files to read the patch from. - can be used to read\nfrom the standard input."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.