messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Getting rid of '... does not point to a valid object' for an old git branch\nI have a fork of a Git repo and my clone appears to have an issue with an old, no longer existant, branch. I keep seeing this message:\nerror: refs/heads/t_1140 does not point to a valid object!\nI don't have any other messages and the repo works fine. There's no operation that stops me from working on other branches, pushing changes, pulling...etc.\nI've looked around and there's less than clear instructions on how to get around this issue. I've tried to execute git fsck --full but I see no errors. Just a load on dangling ... messages.\nI've also checked my .git/config and there's no references to this branch and have also checked .git/refs/heads and there's no reference to t_1140\nAny idea how to get rid of this error?\np.s I've tried to clone my repo again and it seems like the error is my Github repo too. So, the only thing I can think of right now is to ditch my repo and fork again." }, { "role": "assistant", "content": "This will clean out any missing refs:\ngit for-each-ref --format=\"%(refname)\" | while read ref; do\n git show-ref --quiet --verify $ref 2>/dev/null || git update-ref -d $ref\ndone" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Why are connections to GitHub over SSH throwing an error \"Warning: Remote Host Identification Has Changed\"?\nJust sometime ago I started getting this warning when pushing to GitHub.\nWARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!\n\nIT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\nIt is also possible that a host key has just been changed.\n\nIs this normal and how do I resolve it?" }, { "role": "assistant", "content": "This happened because on the 24th of March 2023, GitHub updated their RSA SSH host key used to secure Git operations for GitHub.com because the private key was briefly exposed in a public GitHub repository. You will get that message if you had remembered GitHub’s previous key fingerprint in your SSH client before that date.\nAs per per the linked blog post, the solution is to remove the old key by running this command:\n$ ssh-keygen -R github.com\n\nNow the next git connection (pull, push or clone) should ask if you trust the new SSH key. Before entering yes, ensure the shown new key is valid, using the list:\nhttps://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints\nRefer to the blog post for other ways to fix the issue." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Suddenly getting \"No supported authentication methods available\" when pushing to github\n\nI started a github project a few weeks ago. I was able to push changes without any problems (I'm using TortoiseGIT).\nSuddenly today when I tried to push my changes, I got \"PuTTY Fatal Error\" \"Disconnected: No supported authentication methods availble\" error window.\nAnything you can recommend to remedy the problem?" }, { "role": "assistant", "content": "For me there was a problem to perform actions against the remote repository only when using TortoiseGit, through CMD / GitBash there have been no issue at all.\nSo what I did was Very simple:\nI opened TortoiseGit-->Settings --> Network and in SSH Client I changed to \"C:\\Program Files\\Git\\usr\\bin\\ssh.exe\" instead of \"TortoiseGitPlink.exe\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-describe - Give an object a human readable name based on an available ref" }, { "role": "assistant", "content": "BUGS Tree objects as well as tag objects not pointing at commits, cannot be described.\nWhen describing blobs, the lightweight tags pointing at blobs are ignored,\nbut the blob is still described as <commit-ish>:<path> despite the lightweight\ntag being favorable." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to 'git pull' into a branch that is not the current one?\nWhen you run git pull on the master branch, it typically pulls from origin/master. I am in a different branch called newbranch, but I need to run a command that does a git pull from origin/master into master but I cannot run git checkout to change the selected branch until after the pull is complete. Is there a way to do this?\nTo give some background, the repository stores a website. I have made some changes in newbranch and deployed them by switching the website to newbranch. Now those changes have been merged upstream into the master branch, I am trying to switch the website back to the master branch as well. At this point, newbranch and origin/master are identical, but master is lagging behind origin/master and needs to be updated. The problem is, if I do it the traditional way:\n$ git checkout master\n # Uh oh, production website has now reverted back to old version in master\n$ git pull\n # Website is now up to date again\n\nI need to achieve the same as above (git checkout master && git pull), but without changing the working directory to an earlier revision during the process." }, { "role": "assistant", "content": "Straightforward: Updating from a remote branch into a currently not checked-out branch master:\ngit fetch origin master:master\n\nwhere origin is your remote and you are currently checked out in some branch e.g. dev.\nIf you want to update your current branch in addition to the specified branch at one go:\ngit pull origin master:master" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab Runner - ERROR: Failed to remove network for build\n\nHere is my gitlab-ci.yml:\nimage: vibraniumcore/gcc-cmake-boost-mysqlcon\n#image: gitlab/dind\n\nstages:\n - test\n - build\n\nRun Tests:\n stage: test\n tags:\n - c++\n script:\n - mkdir build\n - cd build\n - cmake ..\n - cmake --build . --target VibraniumCoreTests\n - cd ./Tests\n - ./VibraniumCoreTests\n\nBuild VibraniumCore:\n stage: build\n tags:\n - c++\n script:\n - mkdir build\n - cd build\n - cmake ..\n - cmake --build .\n\nBuild AuthServer:\n stage: build\n tags:\n - c++\n script:\n - cd Scripts\n - ./build_authserver.sh\n\nBuild WorldServer:\n stage: build\n tags:\n - c++\n script:\n - cd Scripts\n - ./build_worldserver.sh\n\nWhen I try to run my pipeline I get this error:\nRunning with gitlab-runner 13.1.1 (6fbc7474)\n on GCC-CMAKE HdBd6UX6\nPreparing the \"docker\" executor\n00:35\nERROR: Failed to remove network for build\nERROR: Preparation failed: error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/info: read unix @->/var/run/docker.sock: read: connection reset by peer (docker.go:894:4s)\nWill be retried in 3s ...\nERROR: Failed to remove network for build\nERROR: Preparation failed: error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/info: read unix @->/var/run/docker.sock: read: connection reset by peer (docker.go:894:10s)\nWill be retried in 3s ...\nERROR: Failed to remove network for build\nERROR: Preparation failed: error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/info: read unix @->/var/run/docker.sock: read: connection reset by peer (docker.go:894:10s)\nWill be retried in 3s ...\nERROR: Job failed (system failure): error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/info: read unix @->/var/run/docker.sock: read: connection reset by peer (docker.go:894:10s)\n\nAny idea why I get this error and how can I fix it?" }, { "role": "assistant", "content": "If you want to have your runner setup with executor=\"docker\", you may encounter the \"ERROR: Failed to remove network for build\" error if you have not installed docker on your machine hosting the runner.\nIn Ubuntu, try:\nsudo apt install docker.io\n\nAnd then re-run the pipeline." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git: How to move back and forth between commits\nI have a newbie question about Git:\nI need to move back and forth in a history of a branch.\nThat means, I need to get all the files to the state they were in in some old revision, and then I need to get back to the latest state in the repository. I don't need to commit.\nWith SVN, it would be\nsvn up -r800\n\nto get to revision 800, and \nsvn up\n\nto get in sync with the repository.\nI know the hash of the commit I want to get back to, so I tried\ngit reset <hash>\n\nwhich seems to get me there. But then I tried\ngit pull\n\nbut that complains about conflicts.\nSo what's the proper way to move through the history of the branch?\nI'm thinking in terms of SVN, so don't hezitate to point me to some nice tutorial. Note that I've already checked http://git.or.cz/course/svn.html and http://www.youtube.com/watch?v=8dhZ9BXQgc4 .\nThanks, Ondra." }, { "role": "assistant", "content": "I'm a former svn user too and now use git for all my projects.\nWhen using git, you should change your way of thinking from the client-server architecture that's used in svn. In svn, every change needs a connection with the server. Using git, your repo is in the working directory. You don't need a connection for every repo action.\nOnly use git push and git pull to synchronise with the repo. Think of it as using rsync or any backup solution to make two places have exactly the same content. Just like when you connect external backup hard disk, then make the content in it same with the content in your main. That's the usage of git pull and git push.\nIf you just want to go back and forth in the history, do it using git checkout. See the revision id using git log. If you're using Linux, use gitk to see the revision tree. In Windows, tortoise git can display it using revision graph.\nTo get back to latest revision, use git checkout master. Before doing any command, always make yourself do git status. This command will display anything you need to know about current repo condition, and what action you need to do to make it right. Before doing git pull and git push, it's better to make sure that the git status result shows working directory clean.\nIf you need to revert a file to its previous revision, you can do it with git merge. Before doing it to a file, test it first with git diff. Ex: git diff rev1:rev2 filename. It will print out any differences between two revisions. Changes in rev1 will be replaced by the changes in rev2. So to do revert, rev2 will be the older than rev1. After you are satisfied with the diff result, do it with git merge, just replace diff with merge and all other parameters stay the same.\nI hope this helps you. The main key is to see that your working dir is your repo. Understanding this will help you use git to it's full capability. Good luck." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-apply - Apply a patch to files and/or to the index apply.ignoreWhitespace" }, { "role": "assistant", "content": "When set to change , tells git apply to ignore changes in\nwhitespace, in the same way as the --ignore-space-change option.\nWhen set to one of: no, none, never, false, it tells git apply to\nrespect all whitespace differences.\nSee git-apply ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-notes - Add or inspect object notes prune" }, { "role": "assistant", "content": "Remove all notes for non-existing/unreachable objects." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I fold content in Github markdown?\n\nHow does github fold text blocks?\nlook at this issuecomment" }, { "role": "assistant", "content": "Check if this follows dear-github issue 166, which mentions:\ncollapsible sections are supported:\n<details>\n<summary>Click to expand</summary>\n\nwhatever\n\n</details>\n\nSee more in this example.\n\nThe key is to wrap the whole contents inside the <p>:\n\n<details><summary>stuff with *mark* **down**</summary><p>\n\n## _formatted_ **heading** with [a](link)\n\n---\n{{standard 3-backtick code block omitted from here due to escaping issues}}\n---\n\nCollapsible until here.\n</p></details>\n\n\nGabriel Devillers reports in the comments that GitLab also have a similar collapsible section support." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "is it dangerous to create a branch with same name as a deleted branch?\nI've been working on a feature in a branch; call it 'foo'. I'm done for now and merging it into master and would like to delete it locally and remotely. But sometime in the future I may start working on this feature again and will be tempted to create a new branch also called 'foo'.\nI don't think this will be a problem for me, but if someone else has their own copy of my current foo branch, and then they try to pull after the new foo branch has been created, will they get screwed up?" }, { "role": "assistant", "content": "No, it's not a problem.\nThe behaviour would be the same, as if the branch has not been deleted: Git will try to merge (or rebase) them when someone pulls the new branch. If there are conflicts, they would be there in either case.\nBranches are, simply, pointers to commits. If you delete a branch, and create another one with the same name later on another commit, this is the same as if you would reset it to that commit (git reset)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does \"Keep Index\" option of Git stash dialog in Intellij IDEA do?\nIt is said in IDEA documentation\n\nSelect this check box to have IntelliJ IDEA bring the changes staged in the index to your working tree for examination and testing.\n\nCan somebody please explain what does this mean?" }, { "role": "assistant", "content": "This determines if the stash is created with the git --keep-index flag.\nFrom GIT docs:\n\nIf the --keep-index option is used, all changes already added to the index are left intact.\n\nSo in other words, any files you've added to git will also remain outside of the stash when you create it. Whereas normally newly added files would be removed after stashing. (See this question for a more indepth description of where the index is.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc git diff --no-index a b" }, { "role": "assistant", "content": "compares two non-git things (1) and (2)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I see 'git diff' on the Visual Studio Code side-by-side file?\nI would like to know how to see as a file with the command git diff master origin/master in the terminal on Visual Studio Code.\nI did a git fetch from my remote repository, and now I want to see the diff, but with the command just show me in the terminal.\nExample of what I want:" }, { "role": "assistant", "content": "In Visual Studio Code, on the left side, there is a Git icon that looks like this:\n\nBy clicking on this icon, then double-clicking one of the files listed under Changes you can see the Git difference in two sides." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In Git, list names of branches with unpushed commits\nGiven a project with several local branches, each tracking some remote branch, is there a command that lists all branches that have unpushed commits? (That is, even if none of those branches are checked out.)\nI don't want to see the commits themselves, nor do I want to see branches that are up-to-date, I just want to see which branches are ahead of their remotes.\nI have tried git log --branches --not --remotes --simplify-by-decoration --decorate --oneline, but it doesn't seem to show what I need. Running it on my current repo gives no output, but running git status on my current branch shows Your branch is ahead of 'origin/branchname' by 2 commits.\ngit for-each-ref --format=\"%(refname:short) %(push:track)\" refs/heads and git branch -v both show branches that are up to date as well as ones that need pushing. However, they do both show my current branch as [ahead 2].\nOther commands I have found eg. git log @{u}.., git cherry -v list the commits themselves, not the branches.\nSide question: why would the output from git log --branches --not --remotes --simplify-by-decoration --decorate --oneline not include branches that git branch -v shows as ahead? Isn't the former command just looking at which refs/heads do not correspond to a known remote; so wouldn't a branch listed as [ahead 2] meet this criteria?" }, { "role": "assistant", "content": "The --no-walk option to log seems to do a better job of what I need than --simplify-by-decoration. My full command is:\ngit log --branches --not --remotes --no-walk --decorate --oneline\n...which I've aliased to unpushed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-describe - Give an object a human readable name based on an available ref --match <pattern>" }, { "role": "assistant", "content": "Only consider tags matching the given glob(7) pattern,\nexcluding the \"refs/tags/\" prefix. If used with --all , it also\nconsiders local branches and remote-tracking references matching the\npattern, excluding respectively \"refs/heads/\" and \"refs/remotes/\"\nprefix; references of other types are never considered. If given\nmultiple times, a list of patterns will be accumulated, and tags\nmatching any of the patterns will be considered. Use --no-match to\nclear and reset the list of patterns." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --glob=<glob-pattern>" }, { "role": "assistant", "content": "Pretend as if all the refs matching shell glob <glob-pattern> are listed on the command line as <commit> . Leading refs/ ,\nis automatically prepended if missing. If pattern lacks ? , * ,\nor [ , /* at the end is implied." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "In a git merge conflict, what are the BACKUP, BASE, LOCAL, and REMOTE files that are generated?\nI assume the LOCAL and REMOTE files are just what their name suggests, but what are BASE and BACKUP for?" }, { "role": "assistant", "content": "Git performs a three-way merge, finding the common ancestor (aka \"merge base\") of the two branches you are merging. When you invoke git mergetool on a conflict, it will produce these files suitable for feeding into a typical 3-way merge tool. Thus:\n\nfoo.LOCAL: the \"ours\" side of the conflict - ie, your branch (HEAD) that will contain the results of the merge\nfoo.REMOTE: the \"theirs\" side of the conflict - the branch you are merging into HEAD\nfoo.BASE: the common ancestor. useful for feeding into a three-way merge tool\nfoo.BACKUP: the contents of file before invoking the merge tool, will be kept on the filesystem if mergetool.keepBackup = true." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-upload-pack not found\n\nI'm trying to clone an existing github-repository (Git for Windows) to an empty folder using\ngit clone https://github.com/di98jgu/D0016E---Digitalt-projekt.git\n\nbut keep getting the error message:\n\nfatal: https://github.com/di98jgu/D0016E---Digitalt-projekt.git/info/refs?service=git-upload-pack not found: did you run git update-server-info on the server?\n\nThe server is working fine (others are using it). Have tried adding the paths of git-upload-pack and git-receive-pack to gitconfig, \n[remote \"origin\"] \nurl = https://github.com/di98jgu/D0016E--Digital-projekt.git \nfetch = +refs/heads/*:refs/remotes/origin/* \nuploadpack = libexec/git-core/git-upload-pack\nreceivepack = libexec/git-core/git-receive-pack\n\nbut it didn't help. Seems like a lot of people are having problems causing a similar, but not exactly the same, error message git-upload-pack command not found, but don't think these solutions apply to my situation.\nAnyone know how to solve this?" }, { "role": "assistant", "content": "I just come across this issue right now, it is caused by permissions, please make sure that you current account has the permissions of git pull and git push,in your case , maybe you create a private repository in Github, and not add this account as Manage Collaborators, then the issue come.\nCertainly you also should check if the remote URL is completely correct, include case insensitive, https or http." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the default gitlab-ci image?\n\nI've looked at the gitlab docker documentation but I cannot find it, what is the default gitlab-ci docker image?\n(I'm not setting default:image:)" }, { "role": "assistant", "content": "So taking from the comments, the image is shown at start of build and for the curious around gitlab.com shared runners there's details on gitlab site for the saas_runners\nFor linux shared runners the default image at time of writing is ruby:3.1\nFor on premise (own runners), the default image is specified at time of registering the runner." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker --no-optional-locks" }, { "role": "assistant", "content": "Do not perform optional operations that require locks. This is\nequivalent to setting the GIT_OPTIONAL_LOCKS to 0 ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-maintenance" }, { "role": "assistant", "content": "Run tasks to optimize Git repository data" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-hash-object" }, { "role": "assistant", "content": "Compute object ID and optionally create an object from a file" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitfaq - Frequently asked questions about using Git Why do I have a file that’s always modified?" }, { "role": "assistant", "content": "Internally, Git always stores file names as sequences of bytes and doesn’t\nperform any encoding or case folding. However, Windows and macOS by default\nboth perform case folding on file names. As a result, it’s possible to end up\nwith multiple files or directories whose names differ only in case. Git can\nhandle this just fine, but the file system can store only one of these files,\nso when Git reads the other file to see its contents, it looks modified. It’s best to remove one of the files such that you only have one file. You can\ndo this with commands like the following (assuming two files AFile.txt and afile.txt ) on an otherwise clean working tree: $ git rm --cached AFile.txt\n$ git commit -m 'Remove files conflicting in case'\n$ git checkout . This avoids touching the disk, but removes the additional file. Your project\nmay prefer to adopt a naming convention, such as all-lowercase names, to avoid\nthis problem from occurring again; such a convention can be checked using a pre-receive hook or as part of a continuous integration (CI) system. It is also possible for perpetually modified files to occur on any platform if a\nsmudge or clean filter is in use on your system but a file was previously\ncommitted without running the smudge or clean filter. To fix this, run the\nfollowing on an otherwise clean working tree: $ git add --renormalize ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I see all the issues I'm watching on Github?\n\nGithub has a great feature where you can \"watch\" an issue. This is handy for getting notifications about progress on that issue.\nHowever, sometimes you want to find the status of an issue you know you've flagged to watch, but can't remember what it was. This is particularly interesting, imho, for projects that are not your own projects. E.g. watching a bug in a library that your project uses but you don't contribute to frequently.\nWhat I tried: Note that this is different from watching a repo. I tried searching github help (for \"watch issue\" and \"subscribe issue\" with no luck. I read the Unsubscribing from Conversations with some hope, but it didn't quite apply. While looking at the issues for the repository that I (think! I) subscribed to, I tried the various search criteria dropdowns with no luck. Last but not least, I read how to subscribe here at SO in case it mentioned how to see the subscribed list.\nTo those who might flag this as not being about programming, I can only ask for a better place to put this? As Github is a commonly used programming tool, I view this as highly relevant." }, { "role": "assistant", "content": "You can see all the GitHub issues you are currently subscribed to at https://github.com/notifications/subscriptions\nYou can navigate to this page from any page by clicking the notification/bell icon on the top right and then selecting \"Manage notifications\" > \"Subscriptions\" from the left menu panel." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I set up a private Git repository on GitHub? Is it even possible?\n\nI intend to share my source code on an invite-only basis to a few dozen users maybe. The source code itself should not be public. Participants are allowed and encouraged to submit their changes. So I need source control, preferably Git, hosted on a public server with private access for multiple users.\nI learned that it is possible to set up private Git repositories on GitHub which use https:// links. On GitHub itself such a project does not show up in searches. For participating users the project shows a \"lock\" icon. So there are obviously private repositories; I just don't know how set one up. A lot of tutorials use SSH to set up private repositories but they all require you to have \"your own server\".\nI don't care about secure connections when pushing/pulling source code nor do I have trust issues with GitHub. All I care about is giving access only to users I invite. Maybe I'm naive and such a solution is only available via commercial hosting (e.g., Unfuddle, Assembla), but if not, I'd really like to know how it's done!" }, { "role": "assistant", "content": "On January 7th 2019, GitHub announced free and unlimited private repositories for all GitHub users, paying or not. When creating a new repository, you can simply select the Private option." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-archive - Create an archive of files from a named tree tar.umask" }, { "role": "assistant", "content": "This variable can be used to restrict the permission bits of\ntar archive entries. The default is 0002, which turns off the\nworld write bit. The special value \"user\" indicates that the\narchiving user’s umask will be used instead. See umask(2) for\ndetails. If --remote is used then only the configuration of\nthe remote repository takes effect." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Dependencies Between Workflows on Github Actions\n\nI have a monorepo with two workflows:\n.github/workflows/test.yml\nname: test\n\non: [push, pull_request]\n\njobs:\n test-packages:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v1\n - name: test packages\n run: |\n yarn install\n yarn test\n...\n\n.github/workflows/deploy.yml\nname: deploy\n\non:\n push:\n tags:\n - \"*\"\n\njobs:\n deploy-packages:\n runs-on: ubuntu-latest\n needs: test-packages\n steps:\n - uses: actions/checkout@v1\n - name: deploy packages\n run: |\n yarn deploy\n env:\n NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}\n...\n\nThis doesn't work, I can't reference a job in another workflow:\n### ERRORED 19:13:07Z\n\n- Your workflow file was invalid: The pipeline is not valid. The pipeline must contain at least one job with no dependencies.\n\nIs there a way to create a dependency between workflows?\nWhat I want is to run test.yml then deploy.yml on tags, and test.yml only on push and pull requests. I don't want to duplicate jobs between workflows." }, { "role": "assistant", "content": "Now it's possible to have dependencies between workflows on Github Actions using workflow_run.\nUsing this config, the Release workflow will work when the Run Tests workflow is completed.\nname: Release\non:\n workflow_run:\n workflows: [\"Run Tests\"]\n branches: [main]\n types: \n - completed" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "My pull request has been merged, what to do next?\nI recently participated in a project from GitHub. I did the following:\nForked the original repository, cloned it to my local machine, made a branch to fix existing bug, fixed bug being in that branch, pushed that branch to my repo, send a pull request to the author of the repository to merge my fix branch to its master branch.\nIt was my first time I commited on another's code so I don't know what to do. Now my pull request has been merged to original repo/project by the author. \nWhat should I do next? Should I delete the branch? Should I merge the branch? Anything else?\n\nAdditional info:\nThe original project has a single branch.\nI also have a upstream set to get latest updates form the original repo. (I did it like this):\ngit remote add upstream https://path/to/original/repo.git\n\nAnd I get updates like this:\ngit fetch upstream" }, { "role": "assistant", "content": "What to do next is: going on contributing new features or fixing other bugs in their own dedicated branches (pushed only to your fork). \nMeaning your fork stays, but the branches within your fork can come and go. \nYou can also remove the fork if you are not planning to contribute further, but it will remove the corresponding entry in 'Repositories you contribute to'.\nIt is easier to:\n\ndelete your fix branch (actually, it is now deleted for you) on your fork (and in your local cloned repo: see \"Delete a Git branch both locally and remotely\")\ngit pull upstream master (if master was the branch in which your fix has been integrated: the merge will be a fast-forward one): no rebase needed at this point.\nrecreate a fix branch on top of your updated local master (now with the latest from upstream master).\n\n\nHowever, never forget one step before submitting any future pull request:\nrebase first your current branch (fix) from upstream destination branch\n(upstream being the original repo you have forked: see \"What is the difference between origin and upstream in github\")\nBefore submitting anything back to the original repo (\"upstream\"), you need to make sure your work is based on top of the latest from said original repo (or the pull-request won't result in a fast-forward merge once applied back on upstream repo).\nSee, for instance, \"Workflow for managing pull requests on shared repos in github\".\nIn other words, upstream can evolve (have new commits pushed on it) while you are busy fixing stuff. You need to replay your fixes on top of that latest work from upstream to make sure your commits are still compatible with the latest of upstream.\n\nThe OP Santosh Kumar asks in the comments:\n\nI have pulled and merged from upstream to master, now what? \n\nIf you haven't made any new fixes since your recent pull request, see above (delete and recreate an new branch fix on top of your updated master).\nIf you have done any more work since your pull request, I wouldn't merge from upstream if I want to make a new pull request: I would pull and rebase:\ngit pull --rebase upstream master\n\nThat way, all my new local work is replayed on top of the most recent upstream master commits (fetched in my local repo), supposing that master is the target branch that will integrate my future pull request.\nThen I can push my local work to 'origin', which is my fork on GitHub of upstream.\nAnd from my fork on GitHub, I can safely make a pull request, knowing that it will only add new commits to upstream without needing any merge resolution: merging those new commits in upstream repo will mean a simple fast-forward merge.\n\nA git pull --rebase without specifying the branch on top of which you want to rebase your (currently checked out) fix branch wouldn't work:\n\nThat (git pull --rebase) says: \n\nYou asked to pull from the remote '`upstream`', but did not specify a branch. \n\n\nShould I append master at last? And what will this do?, will it delete my fix branch?\n\nYes, you can specify the branch which will be the target of the pull request, for instance 'master'.\nThat will not delete your fix branch, but will replay it on top of upstream master fetched in your repo." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How can I make git do the \"did you mean\" suggestion?\nI type \ngit puhs\n\nAnd git says:\nkristian@office:~/myrepo$ git puhs\ngit: 'puhs' is not a git command. See 'git --help'\n\nDid you mean this?\n push\n\nWhat is the config setting to make git just do the suggested command if it only has one suggestion ?" }, { "role": "assistant", "content": "According to git-config(1), you want to set help.autocorrect appropriately. For example, git config --global help.autocorrect 5 will make it wait half a second before running the command so you can see the message first." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git commit -m vs. git commit -am\n\nSeems easy but I just don't get it. I am in the root of my application.\nHere is my workflow.\ngit add .\ngit commit -m \"added a new feature some files changed\"\ngit push heroku master\n\nThis usually works. All my changes are pushed.\nBut sometimes I have a file that I change but when I push to Heroku the changes are not there for THAT ONE FILE... but for most of the files the changes are there... \nBut if I do\ngit add .\ngit commit -am \"added a new feature some files changed\"\ngit push heroku master\n\nEverything (all changes) are pushed to Heroku" }, { "role": "assistant", "content": "From the docs:\n\ngit commit -a automatically stage all tracked, modified files before the commit If you think the git add stage of the workflow is\n too cumbersome, Git allows you to skip that part with the -a option.\n This basically tells Git to run git add on any file that is \"tracked\"\n - that is, any file that was in your last commit and has been modified. This allows you to do a more Subversion style workflow if\n you want, simply editing files and then running git commit -a when you\n want to snapshot everything that has been changed. You still need to\n run git add to start tracking new files, though, just like Subversion.\n\nUsing the option -am allows you to add and create a message for the commit in one command." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Find out which remote branch a local branch is tracking\nSee also: \nHow can I see which Git branches are tracking which remote / upstream branch?\n\nHow can I find out which remote branch a local branch is tracking?\nDo I need to parse git config output, or is there a command that would do this for me?" }, { "role": "assistant", "content": "Here is a command that gives you all tracking branches (configured for 'pull'), see:\n$ git branch -vv\n main aaf02f0 [main/master: ahead 25] Some other commit\n* master add0a03 [jdsumsion/master] Some commit\n\nYou have to wade through the SHA and any long-wrapping commit messages, but it's quick to type and I get the tracking branches aligned vertically in the 3rd column.\nIf you need info on both 'pull' and 'push' configuration per branch, see the other answer on git remote show origin.\n\nUpdate\nStarting in git version 1.8.5 you can show the upstream branch with git status and git status -sb" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "gitsubmodules - Mounting one repository inside another" }, { "role": "assistant", "content": "Workflow for an artificially split repo # Enable recursion for relevant commands, such that\n# regular commands recurse into submodules by default\ngit config --global submodule.recurse true # Unlike most other commands below, clone still needs\n# its own recurse flag:\ngit clone --recurse <URL> <directory>\ncd <directory> # Get to know the code:\ngit grep foo\ngit ls-files --recurse-submodules Note git ls-files also requires its own --recurse-submodules flag. # Get new code\ngit fetch\ngit pull --rebase # Change worktree\ngit checkout\ngit reset" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-ls-remote" }, { "role": "assistant", "content": "List references in a remote repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git list all available commands\nIs there command which can show me list of all available commands in GIT? There is git help but it shows:\nusage: git [--version] [--exec-path[=<path>]] [--html-path]\n [-p|--paginate|--no-pager] [--no-replace-objects]\n [--bare] [--git-dir=<path>] [--work-tree=<path>]\n [-c name=value] [--help]\n <command> [<args>]\n\nThe most commonly used git commands are:\n add Add file contents to the index\n bisect Find by binary search the change that introduced a bug\n branch List, create, or delete branches\n checkout Checkout a branch or paths to the working tree\n clone Clone a repository into a new directory\n commit Record changes to the repository\n diff Show changes between commits, commit and working tree, etc\n fetch Download objects and refs from another repository\n grep Print lines matching a pattern\n init Create an empty git repository or reinitialize an existing one\n log Show commit logs\n merge Join two or more development histories together\n mv Move or rename a file, a directory, or a symlink\n pull Fetch from and merge with another repository or a local branch\n push Update remote refs along with associated objects\n rebase Forward-port local commits to the updated upstream head\n reset Reset current HEAD to the specified state\n rm Remove files from the working tree and from the index\n show Show various types of objects\n status Show the working tree status\n tag Create, list, delete or verify a tag object signed with GPG\n\nSee 'git help <command>' for more information on a specific command.\n\nAnd I want just list without description." }, { "role": "assistant", "content": "Try:\ngit help -a" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Is there a way to tell git-status to ignore the effects of .gitignore files?\nI have configured numerous .gitignore files to filter out many different unwanted files from a set of about 6,000 untracked files. I want to do git add . when I've got my filtered list looking the way I want it.\nBut, then I want to disable the .gitignore filters temporarily to see what got left behind, and make sure there was nothing important accidentally filtered.\nI know that git-clean includes an option to ignore .gitignore files. Is there a similar option for git-status?\nI could go through and delete all the .gitignore files, do the check, then restore them, but it seems there should be an easier way?" }, { "role": "assistant", "content": "This option --ignored does the trick:\ngit status --ignored\n\n\n(Update 1) I found the --ignored option alone doesn't work in certain git installations, perhaps it's a git bug. In those cases, an additional -s works for me:\ngit status -s --ignored\n\n(Update 2)\nOne user reported --ignored option is not supported in git version 1.7.0.4. My git version is 1.7.6. Another version 1.7.5.1 is the one that requires -s. You may try \ngit status -h\n\nto see if --ignored is supported." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-grep - Print lines matching a pattern <pathspec>…​" }, { "role": "assistant", "content": "If given, limit the search to paths matching at least one pattern.\nBoth leading paths match and glob(7) patterns are supported. For more details about the <pathspec> syntax, see the pathspec entry\nin gitglossary ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the difference between \"git init\" and \"git init --bare\"?\nWhat is the different between git init and git init --bare? I found that a lot of blog post requires --bare for their Git server?\nFrom the man page, it said:\n\n--bare\n\nCreate a bare repository. If GIT_DIR environment is not set, it is set to the current working directory\n\nBut what does it actually mean? Is it required to have --bare for the Git server setup?" }, { "role": "assistant", "content": "Non-Bare Git Repo\nThis variant creates a repository with a working directory so you can actually work (git clone). After creating it you will see that the directory contains a .git folder where the history and all the git plumbing goes. You work at the level where the .git folder is.\nBare Git Repo\nThe other variant creates a repository without a working directory (git clone --bare). You don't get a directory where you can work. Everything in the directory is now what was contained in the .git folder in the above case.\nWhy You Would Use One vs. the Other\nThe need for git repos without a working directory is the fact that you can push branches to it and it doesn't manage what someone is working on. You still can push to a repository that's not bare, but you will get rejected as you can potentially move a branch that someone is working on in that working directory.\nSo in a project with no working folder, you can only see the objects as git stores them. They are compressed and serialized and stored under the SHA1 (a hash) of their contents. In order to get an object in a bare repository, you need to git show and then specify the sha1 of the object you want to see. You won't see a structure like what your project looks like.\nBare repositories are usually central repositories where everyone moves their work to. There is no need to manipulate the actual work. It's a way to synchronize efforts between multiple people. You will not be able to directly see your project files.\nYou may not have the need for any bare repositories if you are the only one working on the project or you don't want/need a \"logically central\" repository. One would prefer git pull from the other repositories in that case. This avoids the objections that git has when pushing to non-bare repositories." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs %(decorate[:<options>])" }, { "role": "assistant", "content": "ref names with custom decorations. The decorate string may be followed by a\ncolon and zero or more comma-separated options. Option values may contain\nliteral formatting codes. These must be used for commas ( %x2C ) and closing\nparentheses ( %x29 ), due to their role in the option syntax. prefix=<value> : Shown before the list of ref names. Defaults to \" ( \". suffix=<value> : Shown after the list of ref names. Defaults to \" ) \". separator=<value> : Shown between ref names. Defaults to \" , \". pointer=<value> : Shown between HEAD and the branch it points to, if any.\nDefaults to \" -> \". tag=<value> : Shown before tag names. Defaults to \" tag: \"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options log.showRoot" }, { "role": "assistant", "content": "If true, the initial commit will be shown as a big creation event.\nThis is equivalent to a diff against an empty tree.\nTools like git-log or git-whatchanged , which\nnormally hide the root commit will now show it. True by default." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Using GitLab API, how do I get a list of active users?\n\nGitlab-CE v8.14.3\nI'm reading the GitLAB API docs, and am trying to get the list of active users. I'm an admin and created a personal token. I do this\n$ curl -XGET \"Private-Token: kfjakjfkjkd\" https://company.domain.com/api/v3/users?active=true\n\nand keep getting 401 (Unauthorized) error. Like I said, I'm an admin. What gives?" }, { "role": "assistant", "content": "You must specify the header using the -H option as noted in Bertrand Martel's answer. That will retrieve up to 20 users.\nAbove 20 users, you must get fancier. The JSON output is paginated, and each query is limited to 100 users per page. So to get 300 users, you must get three pages, 100 users at a time:\ncurl -H \"Private-Token: kfjakjfkjkd\" \"https://company.domain.com/api/v4/users?active=true&per_page=100&page=1\" > gitlabusers1.json\ncurl -H \"Private-Token: kfjakjfkjkd\" \"https://company.domain.com/api/v4/users?active=true&per_page=100&page=2\" > gitlabusers2.json \ncurl -H \"Private-Token: kfjakjfkjkd\" \"https://company.domain.com/api/v4/users?active=true&per_page=100&page=3\" > gitlabusers3.json" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitHub satanically messing with Markdown - changes 666 to DCLXVI\n\nMy GitHub repository has nothing but a readme in it. In this readme, locally I wrote this:\nFactoids:\n - There are about six different ways to do everything in Forked.\n - There are actually six different ways to enter loops.\n - There are six directionals and six I/O commands.\n - 666. ha.\n\nEmphasis on the last line.\nWhat GitHub decided to show was not 666.\n\nDCLXVI is the Roman Numeral number for 666.\nThis really creeped me out. My local file and the raw file both show 666.\nWhat is GitHub doing, and why is the indentation on the un-numbered list messed up? Is this an easter egg, or some satanic bug?" }, { "role": "assistant", "content": "This seems to be followed by github/markup issue 991, where on ordered sub-list, decimal numerals automatically turns into roman numerals.\n\nI have found the cause of problem. It is CSS\n\nThis is the expected way for nested ordered lists to render in HTML.\n\nThis is not expected in HTML. https://jsfiddle.net/tf5jtv8s\n\nWe don't make any modifications to the default HTML behavior.\n\nol ol,ul ol{list-style-type:lower-roman}\n\nI don't know CSS but my understanding is that this is the cause of problem. I can get expected result by disabling CSS. (I am from my mobile so I can't use browser inspector)\n\nAs mentioned in \"A formal spec for GitHub Flavored Markdown\", GitHub markdown spec GFM: GitHub Flavored Markdown Spec is built on top of the CommonMark Spec.\nAnd as Tommi Kaikkonen mentioned in his answer, the ordered list is because of the dot following 666. See GFM Spec section 5.2.\nAs mentioned in section 6.1, any ASCII punctuation character may be backslash-escaped, to avoid this issue.\nThat means:\n- 666\\. ha.\n\n(as explicitly shown in ForNeVeR's answer)\nThat is why that 666 number is changed to roman numerals in a GitHub README markdown.\n\nMike Lippert commented:\n\nthe 1st element in that list so it should show as i not dclxvi.\nMarkdown ordered lists ignore the actual number used and number sequentially, and I haven't seen a way to change that.\n\nHowever, no: it shows dclxvi, because the generated html code is <ol start=\"666\">, which is consistent with the GFM specs:\n\nIf the list item is ordered, then it is also assigned a start number, based on the ordered list marker\"\n\n(here, '666' is the ordered list marker)\nMike adds:\n\n\n@VonC For anyone else here's another useful excerpt from VonC's doc link:\n\n\"The start number of an ordered list is determined by the list number of its initial list item. The numbers of subsequent list items are disregarded.\"\n\n\n\nAlso, why is the spacing messed up? I didn't catch that in your answer\n\nYou get an ordered list <ol> within an un-ordered list item <li>:\n<ul>\n <li>\n <ol start=\"666\">\n <li>ha.</li>\n </ol>\n </li>\n</ul>\n\nGitHub CSS rules include:\n.markdown-body ol {\n padding-left: 2em;\n}\n\nIf you put 3em, you would get\n\ninstead of" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Github actions actions/checkout@v2 lfs: true flag not converting pointers to actual files\nThis is my github actions yml file:\nname: CI\n\non: [pull_request]\n\njobs:\n build_ios:\n name: Set up\n runs-on: ${{ matrix.os }}\n\n strategy:\n matrix:\n os: [self-hosted]\n node-version: [10.x]\n\n steps:\n - name: Checkout github repo (+ download lfs dependencies)\n uses: actions/checkout@v2\n with:\n lfs: true\n\nAfter it runs I expect all the git lfs files to be downloaded, checked out and ready to use, but instead the content of the file is this:\nversion https://git-lfs.github.com/spec/v1\noid sha256:f23e4c2b1244bc93085dbccf17c447e54sca44650294648df128d58303e4eff\nsize 58951008\n\nBelow I attach the actual github actions log in case it's helpful:\nRun actions/checkout@v2\n with:\n lfs: true\n repository: SudoPlz/test-project-mobile\n token: ***\n ssh-strict: true\n persist-credentials: true\n clean: true\n fetch-depth: 1\n submodules: false\nSyncing repository: SudoPlz/test-project-mobile\nGetting Git version info\n Working directory is '/Users/sudoplz/Development/tmp/actions-runner/_work/test-project-mobile/test-project-mobile'\n /usr/bin/git version\n git version 2.24.1 (Apple Git-126)\n /usr/bin/git lfs version\n git-lfs/2.8.0 (GitHub; darwin amd64; go 1.12.7)\n/usr/bin/git config --local --get remote.origin.url\nhttps://github.com/SudoPlz/test-project-mobile\nRemoving previously created refs, to avoid conflicts\n /usr/bin/git rev-parse --symbolic-full-name --verify --quiet HEAD\n HEAD\n /usr/bin/git rev-parse --symbolic-full-name --branches\n /usr/bin/git rev-parse --symbolic-full-name --remotes=origin\nCleaning the repository\n /usr/bin/git clean -ffdx\n Removing .jest/\n Removing node_modules/\n Removing patchLog.txt\n /usr/bin/git reset --hard HEAD\n HEAD is now at 21bea25da Merge ab95479fd7dce51551520250ac521532d0079f94 into c70ec18b35029c581b0c0e06566228f69e091d3d\nDisabling automatic garbage collection\n /usr/bin/git config --local gc.auto 0\nSetting up auth\n /usr/bin/git config --local --name-only --get-regexp core\\.sshCommand\n /usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :\n /usr/bin/git config --local --name-only --get-regexp http\\.https\\:\\/\\/github\\.com\\/\\.extraheader\n /usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\\.https\\:\\/\\/github\\.com\\/\\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :\n /usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***\n/usr/bin/git lfs install --local\nUpdated git hooks.\nGit LFS initialized.\nFetching the repository\n /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +d4be6d58e6a72e54b0b03be61fc508dcee8d7bec:refs/remotes/pull/44/merge\n remote: Enumerating objects: 10, done. \n remote: Counting objects: 10% (1/10) \n remote: Counting objects: 20% (2/10) \n remote: Counting objects: 30% (3/10) \n remote: Counting objects: 40% (4/10) \n remote: Counting objects: 50% (5/10) \n remote: Counting objects: 60% (6/10) \n remote: Counting objects: 70% (7/10) \n remote: Counting objects: 80% (8/10) \n remote: Counting objects: 90% (9/10) \n remote: Counting objects: 100% (10/10) \n remote: Counting objects: 100% (10/10), done. \n remote: Compressing objects: 33% (1/3) \n remote: Compressing objects: 66% (2/3) \n remote: Compressing objects: 100% (3/3) \n remote: Compressing objects: 100% (3/3), done. \n remote: Total 5 (delta 2), reused 2 (delta 0), pack-reused 0 \n From https://github.com/SudoPlz/test-project-mobile\n + 21bea25da...d4be6d58e d4be6d58e6a72e54b0b03be61fc508dcee8d7bec -> pull/44/merge (forced update)\nDetermining the checkout info\nFetching LFS objects\n /usr/bin/git lfs fetch origin refs/remotes/pull/44/merge\n fetch: Fetching reference refs/remotes/pull/44/merge\nChecking out the ref\n /usr/bin/git checkout --progress --force refs/remotes/pull/44/merge\n Warning: you are leaving 1 commit behind, not connected to\n any of your branches:\n\n 21bea25da Merge ab95479fd7dce51551520250ac521532d0079f94 into c70ec18b35029c581b0c0e06566228f69e091d3d\n\n If you want to keep it by creating a new branch, this may be a good time\n to do so with:\n\n git branch <new-branch-name> 21bea25da\n\n HEAD is now at d4be6d58e Merge 8d05f53305eaef70a2d4635767b39dbfbe663b5a into c70ec18b35029c581b0c0e06566228f69e091d3d\n/usr/bin/git log -1\ncommit d4be6d58e6a72e54b0b03be61fc508dcee8d7bec\nAuthor: SudoPlz <*@*.*>\nDate: Fri Apr 24 18:38:50 2020 +0000\n\n Merge 8d05f53305eaef70a2d4635767b39dbfbe663b5a into c70ec18b35029c581b0c0e06566228f69e091d3d" }, { "role": "assistant", "content": "The LFS objects seem to be only fetched based on the log. You need to checkout the LFS files inorder for the pointer files to be replaced with their LFS counterparts. Here's an attempt at a modified actions.yml based on a search on GitHub Actions (never used it before) :\nname: CI\n\non: [pull_request]\n\njobs:\n build_ios:\n name: Set up\n runs-on: ${{ matrix.os }}\n\n strategy:\n matrix:\n os: [self-hosted]\n node-version: [10.x]\n\n steps:\n - name: Checkout github repo (+ download lfs dependencies)\n uses: actions/checkout@v2\n with:\n lfs: true\n - name: Checkout LFS objects\n run: git lfs checkout\n\nIf the LFS objects have not been fetched, then you can replace git lfs checkout with git lfs pull. \nRelevant issues : Cache for LFS" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Change github diff to be side by side comparison?\nFor github web browsing, it is not shown as side by side as lots of diff tool does. Can I change the diff mode to side by side? I mean on the github web." }, { "role": "assistant", "content": "2023: It is hidden behind the cog wheel ⚙ symbol (right to \"Conversations\").\n\n2014:\nYes, it is possible since Sept. 3rd 2014: see \"Introducing split diffs\":\n\n\nDiffs now come in two flavors, unified and split.\nSwitch between them on pull request, commit, and compare pages using the toggle in the top right of the page.\nThe mode you last used will become your preferred default.\n\n\nNote: since Sept. 4th 2014, it also support word diff highlights.\nSee \"Does Github have a view that shows diffs between file versions?\".\n\nSince 2014, and the introduction of dark theme(!) in 2020, the UI is now:\n\nfrom Unified:\n\n\n\nTo split diff:\n\n\nusing: \nNote: adding \"&diff=split\" at the end of the URL will give you the same result: a split diff." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters --show-toplevel" }, { "role": "assistant", "content": "Show the (by default, absolute) path of the top-level directory\nof the working tree. If there is no working tree, report an error." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options resolveConflict" }, { "role": "assistant", "content": "Shown by various commands when conflicts\nprevent the operation from being performed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-rev-parse - Pick out and massage parameters <arg>…​" }, { "role": "assistant", "content": "Flags and parameters to be parsed." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-send-email - Send a collection of patches as emails sendemail.aliasFileType" }, { "role": "assistant", "content": "Format of the file(s) specified in sendemail.aliasesFile. Must be\none of mutt , mailrc , pine , elm , gnus , or sendmail . What an alias file in each format looks like can be found in\nthe documentation of the email program of the same name. The\ndifferences and limitations from the standard formats are\ndescribed below: sendmail Quoted aliases and quoted addresses are not supported: lines that\ncontain a \" symbol are ignored. Redirection to a file ( /path/name ) or pipe ( |command ) is not\nsupported. File inclusion ( :include: /path/name ) is not supported. Warnings are printed on the standard error output for any\nexplicitly unsupported constructs, and any other lines that are not\nrecognized by the parser." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git checkout master error: the following untracked working tree files would be overwritten by checkout\nI have a git repository. It has A B C D E ... commits. Now I want to checkout D as a new branch named Dbranch. So I excute:git checkout D -b Dbranch. And now I want to delete this branch. Firstly I need to switch to master branch , and then use git branch -d Dbranch to delete it. But when I excute git checkout master, it gives me the error. \nerror: The following untracked working tree files would be overwritten by checkout:\n source/a/foo.c\n ...... (too many lines)\nPlease move or remove them before you can switch branches.\nAborting\n\nHow to delete the Dbranch?" }, { "role": "assistant", "content": "Try git checkout -f master.\n-f or --force\nSource: https://www.kernel.org/pub/software/scm/git/docs/git-checkout.html\n\nWhen switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes.\nWhen checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker GIT_TRACE_PACKET" }, { "role": "assistant", "content": "Enables trace messages for all packets coming in or out of a\ngiven program. This can help with debugging object negotiation\nor other protocol issues. Tracing is turned off at a packet\nstarting with \"PACK\" (but see GIT_TRACE_PACKFILE below).\nSee GIT_TRACE for available trace output options." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-tag - Create, list, delete or verify a tag object signed with GPG --format=<format>" }, { "role": "assistant", "content": "A string that interpolates %(fieldname) from a tag ref being shown\nand the object it points at. The format is the same as\nthat of git-for-each-ref . When unspecified,\ndefaults to %(refname:strip=2) ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git pull fails with bad pack header error\ngit pull fails with following error\nremote: Counting objects: 146, done.\nremote: fatal: unable to create thread: Resource temporarily unavailable\nerror: git upload-pack: git-pack-objects died with error.\nfatal: git upload-pack: aborting due to possible repository corruption on the remote side.\nremote: aborting due to possible repository corruption on the remote side.\nfatal: protocol error: bad pack header\n\nAny Ideas how to pull successfully ?" }, { "role": "assistant", "content": "The lines beginning with remote are output from git running on the remote system. The error:\nfatal: unable to create thread: Resource temporarily unavailable\n\n... strongly suggests that you've run out of memory on the server, which can happen if you have either:\n\nA repository with lots of large files, which can cause re-packing to take a lot of memory.\nLimited virtual memory - either in general, or just for that account due to the ulimit setting\n\nA suggestion here is to limit the amount of memory that packing may take by logging into the remote system (as the user that git runs as) and doing:\ngit config --global pack.windowMemory \"100m\"\ngit config --global pack.packSizeLimit \"100m\"\ngit config --global pack.threads \"1\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc --no-color-moved" }, { "role": "assistant", "content": "Turn off move detection. This can be used to override configuration\nsettings. It is the same as --color-moved=no ." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-show - Show various types of objects --find-object=<object-id>" }, { "role": "assistant", "content": "Look for differences that change the number of occurrences of\nthe specified object. Similar to -S , just the argument is different\nin that it doesn’t search for a specific string but for a specific\nobject id. The object can be a blob or a submodule commit. It implies the -t option in git-log to also find trees." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-log - Show commit logs --minimal" }, { "role": "assistant", "content": "Spend extra time to make sure the smallest possible\ndiff is produced." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I update or sync a forked repository on GitHub?\nI forked a project, made changes, and created a pull request which was accepted. New commits were later added to the repository. How do I get those commits into my fork?" }, { "role": "assistant", "content": "In your local clone of your forked repository, you can add the original GitHub repository as a \"remote\". (\"Remotes\" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:\n# Add the remote, call it \"upstream\":\n\ngit remote add upstream https://github.com/whoever/whatever.git\n\n# Fetch all the branches of that remote into remote-tracking branches\n\ngit fetch upstream\n\n# Make sure that you're on your main branch:\n\ngit checkout main\n\n# Rewrite your main branch so that any commits of yours that\n# aren't already in upstream/main are replayed on top of that\n# other branch:\n\ngit rebase upstream/main\n\nIf you don't want to rewrite the history of your main branch, (for example because other people may have cloned it) then you should replace the last command with git merge upstream/main. However, for making further pull requests that are as clean as possible, it's probably better to rebase.\n\nIf you've rebased your branch onto upstream/main you may need to force the push in order to push it to your own forked repository on GitHub. You'd do that with:\ngit push -f origin main\n\nYou only need to use the -f the first time after you've rebased." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "GitLab git user password\nI have just installed GitLab.\nI created a project called project-x.\nI have created few users and assigned it to the project.\nNow I tried to clone:\n git clone [email protected]:project-x.git\n\nIt prompted me for a password.\nWhat password should I use?" }, { "role": "assistant", "content": "Not strictly related to the current scenario. Sometimes when you are prompted for password, it is because you added the wrong* origin format (HTTPS instead of SSH)\nHTTP(S) protocol is commonly used for public repos with strong username+pass\nSSH authentication is more common for internal projects where you can authenticate with a ssh-key-file and simple pass-phrase\nGitLab users are more likely to use the SSH protocol\nView your remote info with \ngit remote -v\n\nIf you see HTTP(S) address, this is the command to change it to SSH:\ngit remote set-url origin [email protected]_domain.com/example-project.git" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to inject a commit between some two arbitrary commits in the past?\nSuppose I have the following commit history on my local-only branch:\nA -- B -- C\n\nHow do I insert a new commit between A and B?" }, { "role": "assistant", "content": "It's even easier than in OP's answer.\n\ngit rebase -i <any earlier commit>. This displays a list of commits in your configured text editor.\nFind the commit you want to insert after (let's assume it's a1b2c3d). In your editor, for that line, change pick to edit.\nBegin the rebase by closing your text editor (save your changes). This leaves you at a command prompt with the commit you chose earlier (a1b2c3d) as if it has just been committed.\nMake your changes and git commit (NOT amending, unlike most edits). This creates new a commit after the one you chose.\ngit rebase --continue. This replays the successive commits, leaving your new commit inserted in the correct place.\n\nBeware that this will rewrite history, and break anyone else who tries to pull." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options remote.<name>.proxy" }, { "role": "assistant", "content": "For remotes that require curl (http, https and ftp), the URL to\nthe proxy to use for that remote. Set to the empty string to\ndisable proxying for that remote." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --commit-url <URL>" }, { "role": "assistant", "content": "Commit to this SVN URL (the full path). This is intended to\nallow existing git svn repositories created with one transport\nmethod (e.g. svn:// or http:// for anonymous read) to be\nreused if a user is later given access to an alternate transport\nmethod (e.g. svn+ssh:// or https:// ) for commit. config key: svn-remote.<name>.commiturl\nconfig key: svn.commiturl (overwrites all svn-remote.<name>.commiturl options) Note that the SVN URL of the commiturl config key includes the SVN branch.\nIf you rather want to set the commit URL for an entire SVN repository use\nsvn-remote.<name>.pushurl instead. Using this option for any other purpose (don’t ask) is very strongly\ndiscouraged." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Pull-Request for only certain files/commits\nI have a repository that is forked from GitHub that has a few modifications made to it. However, in a certain commit, a few files were changed that I want to submit a pull-request for, leaving the other modified files out of the request.\nDo pull requests merge all commits, or do I need to do something special to isolate this commit?" }, { "role": "assistant", "content": "A pull request being made of whole commits, you need to split this commit into two separate commits one containing the change to put in the pull request, and the other holding the other changes. To do this you need git rebase -i, see for example How can I split up a Git commit buried in history? for a good explanation on how to do it.\nOnce you have split the commit, move the ones you want to include into a topic branch, see for example How to move certain commits to another branch in git?, but it depends if the commits that make your pull request are sequential.\nThen finally you can push to Github and create the pull request from your topic branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-commit" }, { "role": "assistant", "content": "Record changes to the repository" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to set an (environment) variable in the build script in Gitlab CI?\n\nI have a dummy build script in the Gitlab CI:\npwd\nci_app_path=$(pwd)\necho \"INFO: current directory: $ci_app_path\"\n\nand I get this output when the system start the build process:\npwd\n/home/kai/gitlab-runners/gitlab-ci-runner/tmp/builds/project-1\n\nci_app_path=$(pwd)\n\necho \"INFO: current directory: $ci_app_path\"\nINFO: current directory:\n\nso the variable was not set (or was set only for that line: as I know each line executed separately)\nI heard about push/pop mechanism to reach the functionality I desired, but could not find any details, how to implement that. \nUpdate:\nas I thought, each line is going executed separately. So the variable scope is only one line, where it is defined:\nscript:\npwd\nci_app_path=$(pwd) && echo \"INFO: current directory: $ci_app_path\"\n\noutput:\npwd\n/home/devuser/gitlab-runners/gitlab-ci-runner/tmp/builds/project-1\n\nci_app_path=$(pwd) && echo \"INFO: current directory: $ci_app_path\"\nINFO: current directory: /home/kai/gitlab-runners/gitlab-ci-runner/tmp/builds/project-1\n\nI don't think that writing the whole script as a one-liner is a good idea/practice.\nHow to get the variables set while executing the build script?\nP.S.\nactually I wonder why the whole build script must contain no empty lines?, otherwise it returns:\nNo such file or directory\n\nand a build fails on this place" }, { "role": "assistant", "content": "Gitlab CI just plays shell commands so do what you do in *sh:\nexport ci_app_path=$(pwd)\necho \"INFO: current directory: $ci_app_path\"" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fsck - Verifies the connectivity and validity of the objects in the database gitmodulesPath" }, { "role": "assistant", "content": "(ERROR) .gitmodules path is invalid." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "how to discard git local branch changes?\nhow to discard git local branch changes? \neg, local branch with version: A->B->C\nNow I am on version A, and it has some changes conflict with latest version C.\nI want to discard local changes and pull the latest version C.\n$ git pull\n\nI will meet some error. and there are many files, so I don't need to do many times $ git co files\nIs there any better way?" }, { "role": "assistant", "content": "If you have uncommitted changes that you want to discard, use this:\n$ git reset --hard\n\nwhich is equivalent to\n$ git reset --hard HEAD\n\nThis removes all the local uncommitted changes. If you want to remove some offending commits from your local branch, try rewinding it:\n$ git reset --hard HEAD^ #moves HEAD back by one commit\n\nor e.g.\n$ git reset --hard HEAD~3 #moves HEAD back by 3 commits\n\nUse these with caution, as you won't be able to undo these operations. Once you're done cleaning up your local branch, use git pull to get the latest code." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-merge - Join two or more development histories together --abort" }, { "role": "assistant", "content": "Abort the current conflict resolution process, and\ntry to reconstruct the pre-merge state. If an autostash entry is\npresent, apply it to the worktree. If there were uncommitted worktree changes present when the merge\nstarted, git merge --abort will in some cases be unable to\nreconstruct these changes. It is therefore recommended to always\ncommit or stash your changes before running git merge . git merge --abort is equivalent to git reset --merge when MERGE_HEAD is present unless MERGE_AUTOSTASH is also present in\nwhich case git merge --abort applies the stash entry to the worktree\nwhereas git reset --merge will save the stashed changes in the stash\nlist." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Differences between git pull origin master & git pull origin/master\nWhat is the difference between git pull origin master and git pull origin/master ?" }, { "role": "assistant", "content": "git pull origin master will pull changes from the origin remote, master branch and merge them to the local checked-out branch.\ngit pull origin/master will pull changes from the locally stored branch origin/master and merge that to the local checked-out branch. The origin/master branch is essentially a \"cached copy\" of what was last pulled from origin, which is why it's called a remote branch in git parlance. This might be somewhat confusing.\nYou can see what branches are available with git branch and git branch -r to see the \"remote branches\"." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-svn - Bidirectional operation between a Subversion repository and Git --authors-prog=<filename>" }, { "role": "assistant", "content": "If this option is specified, for each SVN committer name that\ndoes not exist in the authors file, the given file is executed\nwith the committer name as the first argument. The program is\nexpected to return a single line of the form \"Name <email>\" or\n\"Name <>\", which will be treated as if included in the authors\nfile. Due to historical reasons a relative filename is first searched\nrelative to the current directory for init and clone and relative\nto the root of the working tree for fetch . If filename is\nnot found, it is searched like any other command in $PATH . config key: svn.authorsProg" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I remove all stale branches from Github?\n\nWe have a lot of branches that are inactive (the newest is 7 months old, the oldest is two years ago).\nI'd like to remove all of those branches in bulk from the remote if no PR is still open for them.\nShould I be using Github's API? Should I be using git using snippets like those provided in this StackOverflow question?\nIs there some Github functionality I'm not familiar with that can help organize our repository?" }, { "role": "assistant", "content": "You can right click on the browser after opening https://github.com/someowner/someproject/branches/stale and run this in the browser java script console.\nTo delete all the stale branches. i.e) this script automatically clicks to the next page and proceeds to delete stale branches in the next page.\nasync function deleteStaleBranches(delay=500) { \n var stale_branches = document.querySelectorAll('[aria-label=\"Delete branch\"]');\n for (var i = 0; i < stale_branches.length; i++) { \n stale_branches.item(i).click();\n await new Promise(r => setTimeout(r, delay)); \n } \n const next = document.querySelector('[aria-label=\"Next Page\"]');\n if(next) { \n next.click();\n setTimeout(() => deleteStaleBranches(500), 500);\n } \n} (() => { deleteStaleBranches(500); })();\n\nTo delete the stale branches that is present in the current page only:\nasync function deleteStaleBranches(delay=500) { \n var stale_branches = document.querySelectorAll('[aria-label=\"Delete branch\"]');\n for (var i = 0; i < stale_branches.length; i++) { \n stale_branches.item(i).click();\n await new Promise(r => setTimeout(r, delay)); \n } \n \n} (() => { deleteStaleBranches(500); })();" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to test a merge without actually merging first\nIs there any way of simulating a git merge between two branches, the current working branch and the master, but without making any changes?\nI often have conflicts when I have to make a git merge. Is there any way of simulating the merge first?" }, { "role": "assistant", "content": "You can use git merge --no-commit to prevent the merge from actually being committed, and if you don't like how the merge works out, just reset to the original head.\nIf you definitely don't want to finalize the merge, even if it's a fast-forward (and thus has no conflicts, by definition), you could add --no-ff as well." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git: Show index diff in commit message as comment\nWhen git commit open the message editor is shows a brief status, something like this:\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n# On branch master\n# Your branch is ahead of 'origin/master' by 26 commits.\n#\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# modified: Showcase/src/com/gigantt/BorderArea.mxml\n# modified: Showcase/src/com/gigantt/Client.mxml\n# modified: Showcase/src/com/gigantt/GraphItem.mxml\n#\n\nHow can I tweak git to show also the diff to be committed?\nI'm aware that it may be a long diff, but still.. so useful." }, { "role": "assistant", "content": "The --verbose (or -v) flag for git commit will display the diff of what would be committed:\ngit commit --verbose" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Undo git stash pop that results in merge conflict\nI began making changes to my codebase, not realizing I was on an old topic branch. To transfer them, I wanted to stash them and then apply them to a new branch off of master. I used git stash pop to transfer work-in-progress changes to this new branch, forgetting that I hadn't pulled new changes into master before creating the new branch. This resulted in a bunch of merge conflicts and loss of a clean stash of my changes (since I used pop).\nOnce I recreate the new branch correctly, how I can I recover my stashed changes to apply them properly?" }, { "role": "assistant", "content": "As it turns out, Git is smart enough not to drop a stash if it doesn't apply cleanly. I was able to get to the desired state with the following steps:\n\nTo unstage the merge conflicts: git reset HEAD . (note the trailing dot)\nTo save the conflicted merge (just in case): git stash\nTo return to master: git checkout master\nTo pull latest changes: git fetch upstream; git merge upstream/master\nTo correct my new branch: git checkout new-branch; git rebase master\nTo apply the correct stashed changes (now 2nd on the stack): git stash apply stash@{1}" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Push branches to Git\n\nI have a local repository I'm working on and its remote is hosted on GitHub. I recently created a branch and started working on it, making several commits and now wish to push the branch to GitHub and be able to pull it to another cloned repository. How do I do this?" }, { "role": "assistant", "content": "git push origin <local-branch-name>:<remote-branch-name>\n\nSubstitute for <local-branch-name> and <remote-branch-name>. They may be same or different, as you wish." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I run git rebase --interactive in non-interactive manner?\nIs it possible to do following?\n\nMake git rebase --interactive to just output standard boilerplate to a file, instead to outputting to a file and opening it in editor.\nLet the user edit the file.\nLet user re-run git rebase with the name of edited file.\nGo on with the usual rebase process.\n\nUsecase: scripted rebasing of course. See how to re-order commits in Git non-interactively for example." }, { "role": "assistant", "content": "After some thinking and research, the answer turned out to be trivial: git rebase -i takes the editor name from the well-known EDITOR/VISUAL environment variables, so overriding that to point to a non-interactive script does the job. \nHowever, EDITOR/VISUAL applies indifferently to the list of commits, commit messages when rewording and anything else. So, since http://git.kernel.org/?p=git/git.git;a=commit;h=821881d88d3012a64a52ece9a8c2571ca00c35cd , there's a special environment variable GIT_SEQUENCE_EDITOR which applies only to the commit list.\nSo, the recipe to re-order or flatten commits is:\nRun: GIT_SEQUENCE_EDITOR=<script> git rebase -i <params>.\nYour <script> should accept a single argument: the path to the file containing the standard rebase commit list. It should rewrite it in-place and exit. Usual rebase processing happens after that." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git Post-Receive Hook for Website Staging\nI'm trying to set up Git for staging my website so that I can git pull to get the current version to work on locally and then git push to push the changes to the remote server. I've got it set up so that it works the way I want it to, but after I push, I have to manually run git checkout -f or git reset --hard HEAD on the remote server.\nI've tried putting these into a shell script as the post-receive hook on the server, but it just doesn't seem to have any effect. I know that the script is running because I'm seeing \"Changes pushed to server\" after I push. Here's the post-receive hook:\n#!/bin/sh\ngit reset --hard HEAD\necho \"Changes pushed to server.\"" }, { "role": "assistant", "content": "The answer to your question is here: http://toroid.org/ams/git-website-howto\nIn short, what you want to do is add a \"detached work tree\" to the bare repository. Normally you think of your work tree as containing the .git directory. Bare repositories do not have a work tree by definition, but you can create one as long as it's in a different directory than the bare repo.\nThe post-receive hook is just a simple git checkout -f to replicate the repository's HEAD into the work directory. Apache uses that as its document root, and you're all set. Any time you push to the bare repository, Apache will immediately start serving it.\nI generally use this to automatically push to a staging server to see if the \"real\" environment will puke on my changes. Deploying to the live server is a completely different story. :-)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "lost git stash changes\nSo here's what happened:\nI was on a branch 'A' and did a Git stash on that branch. Then I switched to another branch 'B'. I navigated back to Branch 'A' but did not do a Git stash pop. I switched to the master branch and then back to branch 'A'. I am trying to go a git stash pop now but cant seem to get my changes back.. I need to recover that code but whenever I do a git stash pop, my file changes are not listed. I did not commit any code.\nIs there a way to recover the changes that I made? would really appreciate any help in this regards." }, { "role": "assistant", "content": "Stashes should be viewable via\ngit stash list\n\nor\ngitk --all\n\nalso, git stash does not stash untracked files. If you did this and subsequently did a git checkout --force of another branch to overwrite untracked files with tracked ones in another branch, you have lost that content. The recommended way to stash is with\ngit stash -u\n\nThis will prevent losses of this type." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Git merge branch of another remote\nNowadays, I see a lot of commits from Linus Torvalds and/or Gitster that look like so:\nMerge branch 'maint' of git://github.com/git-l10n/git-po into maint …\n* 'maint' of git://github.com/git-l10n/git-po:\n l10n: de.po: fix a few minor typos\n\nor:\nMerge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upst… …\n…ream-linus\n\nPull MIPS update from Ralf Baechle:\n...\n* 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus: (22 commits)\n MIPS: SNI: Switch RM400 serial to SCCNXP driver\n...\n\nI have no idea how would one do that, although, I know about the git remote and git checkout and git merge that I use to merge forks (or \"pull requests\") but it does not generate such message, why? and how would someone do that (provide examples please)?\nP.S: I'm a fan of Linus Torvalds commits etc, like how detailed the description of his merges look ;P\nP.S: This is how I used to merge stuff:\ngit remote add anotherremoot\ngit checkout -b anotherbranch\ngit pull remoteshortcut\n...do tests...\ngit checkout master\ngit merge anotherbranch\ngit push\n\nThe above example I learned from: http://viget.com/extend/i-have-a-pull-request-on-github-now-what" }, { "role": "assistant", "content": "Just use git pull to pull the remote branch into master:\ngit remote add something git://host.example.com/path/to/repo.git\ngit checkout master\ngit pull something master\n\nOr do it without adding a remote:\ngit pull git://host.example.com/path/to/repo.git\n\ngit pull fetches the remote branch, and merges it into the local branch. If possible, it does a fast-forward merge, which just means that it updates the current master to the latest commit without generating a merge commit. But if there are changes on both sides, it will do a merge, like the ones you see Linus and Junio doing, with the remote URL included.\nIf you want to guarantee that you get a merge commit, even if it could fast forward, do git pull -no-ff. If you want to make sure that pull never creates a merge commit (so fails if there are changes on both sides), do git pull --ff-only.\nIf you want to include a more detailed message, like the full log that Linus provides, do git pull --log. If you want to edit the message, instead of just using the automatically created message, use git pull --edit. See documentation for git pull for more options." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What does UserA committed with UserB 13 days ago on github mean?\n\nI am interested in knowing which one of the two users made the file changes when github lists both. The git record contains only UserA however." }, { "role": "assistant", "content": "UserA is the one who actually made the changes. UserB is the one who committed those changes to this branch. i.e if UserA commits his changes to branch1, UserB comes, commits a couple changes to branch2, rebases branch1 with branch2. Now, topmost commits in branch1 will show that UserA has committed these changes with UserB. \nEdit: This mainly happens during rebasing and cherry-picking, since authors and committers can be different in these processes." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-tree - List the contents of a tree object [<path>…​]" }, { "role": "assistant", "content": "When paths are given, show them (note that this isn’t really raw\npathnames, but rather a list of patterns to match). Otherwise\nimplicitly uses the root level of the tree as the sole path argument." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Import a Python library from Github\nI'm new to Python so this may sound silly.\nI want to use a Python library I've found on Github, lets say on https://github.com/praw-dev/praw, and I want to be able to do git pull in the future to pull the latest commits.\nQuestion: Should I git clone <git url> in the project directory and delete everything except the praw directory, then in my python script do a import praw? \nIn iPython,\nimport praw\n\ngives the error ImportError: No module named praw\n\nDirectory Structure\n~\\myProject\\\n praw\\\n myNotebook.ipynb" }, { "role": "assistant", "content": "Actually, if given package is not on PyPI (or you want a specific branch) you can still install it through pip from GitHub with:\npip install git+https://github.com/[repo owner]/[repo]@[branch name]\n\nAnd for your problem it would be (although @pandita's answer is correct for normal usage case):\npip install git+https://github.com/praw-dev/praw.git\n\nFor more information check this answer." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to remove selected commit log entries from a Git repository while keeping their changes?\nI would like to remove selected commit log entries from a linear commit tree, so that the entries do not show in the commit log.\nMy commit tree looks something like:\nR--A--B--C--D--E--HEAD\n\nI would like to remove the B and C entries so that they do not show in the commit log, but changes from A to D should be preserved. Maybe by introducing a single commit, so that B and C become BC and the tree looks like.\nR--A--BC--D--E--HEAD\n\nOr, ideally, after A comes D directly. D' representing changes from A to B, B to C and C to D.\nR--A--D'--E--HEAD\n\nIs this possible? if yes, how?\nThis is a fairly new project so has no branches as of now, hence no merges as well." }, { "role": "assistant", "content": "git-rebase(1) does exactly that. \n$ git rebase -i HEAD~5\n\ngit awsome-ness [git rebase --interactive] contains an example.\n\nDon't use git-rebase on public (remote) commits.\nMake sure your working directory is clean (commit or stash your current changes).\nRun the above command. It launches your $EDITOR.\nReplace pick before C and D by squash. It will meld C and D into B. If you want to delete a commit then just delete its line.\n\nIf you are lost, type:\n$ git rebase --abort" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git stuck on Unpacking Objects phase\nI'm trying to do a git pull from a remote repository in github into a local machine...\nbut git gets stuck on 70% into the \"Unpacking objects\" phase, with no sign of going anywhere.. (left it for several hours now with no change)\nAny suggestion on how to fix this issue?\nIs it possible to instruct git to only download the latest commit/version from the remote repository without all the Intermediate states?" }, { "role": "assistant", "content": "I had the same problem when I git pull a repository on github.com. I found there were some large files and the connection to github was slow. So maybe you just have to wait patiently before git pulls the whole repository." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-config - Get and set repository or global options branch.<name>.mergeOptions" }, { "role": "assistant", "content": "Sets default options for merging into branch <name>. The syntax and\nsupported options are the same as those of git-merge , but\noption values containing whitespace characters are currently not\nsupported." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-update-ref - Update the object name stored in a ref safely abort" }, { "role": "assistant", "content": "Abort the transaction, releasing all locks if the transaction is in\nprepared state." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker git-check-ignore" }, { "role": "assistant", "content": "Debug gitignore / exclude files" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-diff - Show changes between commits, commit and working tree, etc diff.mnemonicPrefix" }, { "role": "assistant", "content": "If set, git diff uses a prefix pair that is different from the\nstandard \"a/\" and \"b/\" depending on what is being compared. When\nthis configuration is in effect, reverse diff output also swaps\nthe order of the prefixes: git diff compares the (i)ndex and the (w)ork tree; git diff HEAD compares a (c)ommit and the (w)ork tree; git diff --cached compares a (c)ommit and the (i)ndex; git diff HEAD:file1 file2 compares an (o)bject and a (w)ork tree entity; git diff --no-index a b compares two non-git things (1) and (2)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-pull - Fetch from and integrate with another repository or a local branch octopus" }, { "role": "assistant", "content": "This resolves cases with more than two heads, but refuses to do\na complex merge that needs manual resolution. It is\nprimarily meant to be used for bundling topic branch\nheads together. This is the default merge strategy when\npulling or merging more than one branch." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to PR and merge again after reverting PR using Github Revert Button\nBasically I used Github revert button to revert a previous PR for a feature branch into master, then I decided to merge the same feature branch that I reverted earlier, but I was not able to do so. Steps as follow:\n\nPR to merge feature branch to master\nRevert PR merge from (master)\nTried to create new PR to merge feature branch to master again.\nGot this message:\n\n\nThere isn't anything to compare.\nmaster is up to date with all commits from feature-branch. Try switching the base for your comparison.\n\nAny suggestions on how can I merge feature branch again into master" }, { "role": "assistant", "content": "Just revert the revert. So by clicking the revert button you will have created a new PR (your step 2). Once this is merged, you will have the option to revert this, which will create a new branch with all your changes back in. You can then pull this, make changes to it (if needed) and create a new PR. You will lose all the commit messages on Github, but all file changes will still be around. Good to refer to your original branch and reverts in the new PR.\nAnything to avoid a complicated rebase or force pushing to master." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-ls-files - Show information about files in the index and the working tree objectname" }, { "role": "assistant", "content": "The name of the file which is recorded in the index." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker EMAIL" }, { "role": "assistant", "content": "The email address used in the author and committer identities if no other\nrelevant environment variable or configuration setting has been set." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Running PowerShell scripts as git hooks\nIs it possible to run PowerShell scripts as git hooks?\nI am running git in a PowerShell prompt, which shouldn't make any difference, but I can't seem to get them to work, as the hooks are named without extensions, and PowerShell needs (AFAIK) the .ps1 extension. I am not sure if that is the issue, or something else." }, { "role": "assistant", "content": "Since powershell 7.2 the script must have .ps1 extension on Windows. So this answer will not work.\n\nYou can embed PowerShell script directly inside the hook file. Here is an example of a pre-commit hook I've used:\n#!/usr/bin/env pwsh\n\n# Verify user's Git config has appropriate email address\nif ($env:GIT_AUTHOR_EMAIL -notmatch '@(non\\.)?acme\\.com$') {\n Write-Warning \"Your Git email address '$env:GIT_AUTHOR_EMAIL' is not configured correctly.\"\n Write-Warning \"It should end with '@acme.com' or '@non.acme.com'.\"\n Write-Warning \"Use the command: 'git config --global user.email <[email protected]>' to set it correctly.\"\n exit 1\n}\n\nexit 0\n\nThis example requires PowerShell Core but as a result it will run cross-platform (assuming this file has been chmod +x on Linux/macOS)." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to Abort Git Bisect\nI started my git bisect by specifying good and bad revisions but I don't think they registered. Additionally, as I am attempting to specify git bisect good and bad, I don't think git is doing anything. I would like to abort the entire bisect so that I can re-initiate the operation. git bisect reset seems to be what I am looking for, but I want to double check before potentially messing anything up." }, { "role": "assistant", "content": "git bisect reset is the correct command. From the documentation:\n\nAfter a bisect session, to clean up the bisection state and return to the original HEAD, issue the following command:\n$ git bisect reset\n\nBy default, this will return your tree to the commit that was checked out before git bisect start. (A new git bisect start will also do that, as it cleans up the old bisection state.)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git - the stupid content tracker <tree-ish>" }, { "role": "assistant", "content": "Indicates a tree, commit or tag object name. A\ncommand that takes a <tree-ish> argument ultimately wants to\noperate on a <tree> object but automatically dereferences\n<commit> and <tag> objects that point at a <tree>." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How to have a \"cache per package.json\" file in GitLab CI?\n\nI have a Vue web application that is built, tested and deployed using GitLab CI. \nGitLab CI has a \"Cache\" feature where specific products of a Job can be cached so that future runs of the Job in the same Pipeline can be avoided and the cached products be used instead.\nI'd like to improve my workflow's performance by caching the node_modules directory so it can be shared across Pipelines.\nGitLab Docs suggests using ${CI_COMMIT_REF_SLUG} as the cache key to achieve this. However, this means \"caching per-branch\" and I would like to improve on that.\nI would like to have a cache \"per package.json\". That is, only if there is a change in the contents of package.json will the cache key change and npm install will be run.\nI was thinking of using a hash of the contents of the package.json file as the cache key. Is this possible with GitLab CI? If so, how?" }, { "role": "assistant", "content": "This is now possible as of Gilab Runner v12.5\ncache:\n key:\n files:\n - Gemfile.lock\n - package-lock.json // or yarn.lock\n paths:\n - vendor/ruby\n - node_modules\n\nIt means cache key will be a SHA checksum computed from the most recent commits (up to two, if two files are listed) that changed the given files. Whenever one of these files changes, a new cache key is computed and a new cache is created. Any future job runs using the same Gemfile.lock and package.json with cache:key:files will use the new cache, instead of rebuilding the dependencies.\nMore info: https://docs.gitlab.com/ee/ci/yaml/#cachekeyfiles\nAlso make sure to use always --frozen-lockfile flag in your CI jobs. (or npm ci) Regular npm install or yarn install / yarn commands generate new lock files and you wouldn't usually notice it until you install packages again. Thus makes your build artifacts and caches inconsistent." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "How do I configure git to ignore some files locally?\nCan I ignore files locally without polluting the global git config for everyone else? I have untracked files that are spam in my git status but I don't want to commit git config changes for every single little random untracked file I have in my local branches." }, { "role": "assistant", "content": "From the relevant Git documentation:\n\nPatterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.\n\nThe .git/info/exclude file has the same format as any .gitignore file. Another option is to set core.excludesFile to the name of a file containing global patterns.\nNote, if you already have unstaged changes you must run the following after editing your ignore-patterns:\ngit update-index --assume-unchanged <file-list>\n\nNote on $GIT_DIR: This is a notation used all over the git manual simply to indicate the path to the git repository. If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.\n\nEdit: Another way is to use:\ngit update-index --skip-worktree <file-list>\n\nReverse it by:\ngit update-index --no-skip-worktree <file-list>" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Revert a merge after being pushed\nSteps I performed:\nI have two branches branch1 and branch2,\n$git branch --Initial state\n$branch1\n\n$git checkout branch2\n$git pull origin branch1 --Step1\n\nI resolve the conflicts and did a\n$git commit -m \"Merge resolved\"\n\nthen\n$git checkout branch1\n$git merge branch2\n$git push origin branch1\n\nNow I realised that while being at step1, the auto merging removed some code and the change code was pushed. Now I want to go back to my initial state in order to revert any changes. Looking for some immediate help?" }, { "role": "assistant", "content": "You can revert the merge following the official guide, however this leaves Git with the erroneous belief that the merged commits are still on the target branch.\nBasically you have to : \ngit revert -m 1 (Commit id of the merge commit)" } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Updating file permissions with git-bash on Windows 7\nHow do I update file permissions with git-bash on Windows 7?\nI've tried the following without success:\n$ ls -al scripts/script.sh\n-rw-r--r-- 1 myUid Administ 70 Sep 8 11:24 scripts/script.sh\n\n$ git update-index --chmod=+x scripts/script.sh\n\n$ ls -al scripts/script.sh\n-rw-r--r-- 1 myUid Administ 70 Sep 8 11:24 scripts/script.sh\n\n$ chmod +x scripts/script.sh\n\n$ ls -al scripts/script.sh\n-rw-r--r-- 1 myUid Administ 70 Sep 8 11:24 scripts/script.sh" }, { "role": "assistant", "content": "You are probably using NTFS or FAT32 on Windows, and those filesystems do not support the executable permission. Instead, cygwin looks at the file name and contents to determine whether it's executable:\n\nFiles are considered to be executable if the filename ends with .bat, .com or .exe, or if its content starts with #!.\n\nSo you should make sure that the bash file starts with a shebang (e.g. #!/bin/bash). Then, you should be able to just execute the file, disregarding the permission output of ls." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "warning: refname 'xxx' is ambiguous when using git-svn\nI am using git as a frontend to Subversion (via git svn).\nSo, for every svn trunk/branch I have remote branch in git named \"remotes/xxx\". For example \"remotes/trunk\", \"remotes/coolfeature\".\nNow I want have one \"default\" local branch for every remote branch, to use it for dcommit. The problem is that I want such branches to be named after Subversion branches, like \"trunk\", \"coolfeature\", so I have the following branches in git:\ntrunk\ncoolfeature\nremotes/trunk\nremotes/coolfeature\n\nThe problem is that every time I reference \"trunk\" or \"coolfeature\" git complains branch name is ambiguous. Not a big deal, but I feel uncomfortable.\nThe question is, how can I deal with that warning, assuming that simply renaming branches is not what I want to do. What are the best practices for such cases?" }, { "role": "assistant", "content": "If you pass the --prefix=svn/ flag to the git svn clone command, then all of the Subversion branches would be named like remotes/svn/branchname. If this is acceptable to you, it fixes the \"refname is ambiguous\" warning. It also gives you a nice way of referring to the remote svn branches, as in for instance if you want to create a local tracking branch it would be something like:\n$ git checkout -b branchname svn/branchname\nThe local branch then has the same name as the remote svn branch, and no ambiguous refname problem." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-fast-import - Backend for fast Git data importers Inline data format" }, { "role": "assistant", "content": "The data content for the note has not been supplied yet.\nThe frontend wants to supply it as part of this modify\ncommand. 'N' SP 'inline' SP <commit-ish> LF\n\tdata See below for a detailed description of the data command." } ]
[ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "git-blame - Show what revision and author last modified each line of a file blame.showRoot" }, { "role": "assistant", "content": "Do not treat root commits as boundaries in git-blame .\nThis option defaults to false." } ]