messages listlengths 3 3 |
|---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitfaq - Frequently asked questions about using Git"
},
{
"role": "assistant",
"content": "NAME gitfaq - Frequently asked questions about using Git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git / gerrit, push remote rejected no changes made\nMade changes to a commit, performed commit amend. Do a push and I get the error:\n! [remote rejected] master -> refs/for/master (no changes made)\n\nChecked the change ID in the commit message and its still a valid commit.\nI've tried changing a file, checking it shows up as an alteration and then added to staging area and done another commit amend. Try the push again and getting the same issue. No idea on this one.\nEdit: This is pushing to gerrit, not git directly.\nI'm running:\ngit push origin master:refs/for/master\n\nAnd the result of getting the details of origin are (with company details edited out):\n$ git remote show origin\n* remote origin\n Fetch URL: ssh://[email protected]:29418/myrepo\n Push URL: ssh://[email protected]:29418/myrepo\n HEAD branch: master\n Remote branch:\n master tracked\n Local branch configured for 'git pull':\n master rebases onto remote master\n Local ref configured for 'git push':\n master pushes to master (up to date)"
},
{
"role": "assistant",
"content": "This issue is due to the actions I'd performed previously. I was trying to push a new change, on top of a change which was still up for review, who's parent also was up for review.\n Trunk ------ Parent A ----- Parent B ----- New change\n(merged) (unmerged) (unmerged)\n\nI had used cherry-pick to obtain these two changes locally (Parent A and Parent B), and then a third cherry-pick to get my change from a local branch before attempting to push. That is what caused the issue, because my personal change was essentially trying to re-write history.\nThe correct process would be to only pull Parent B when at trunk. This automatically pulls up any commits between trunk and it (in this case just Parent A). Then cherry-pick my new change on top of that and push will work fine."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch"
},
{
"role": "assistant",
"content": "SECURITY The fetch and push protocols are not designed to prevent one side from\nstealing data from the other repository that was not intended to be\nshared. If you have private data that you need to protect from a malicious\npeer, your best option is to store it in another repository. This applies\nto both clients and servers. In particular, namespaces on a server are not\neffective for read access control; you should only grant read access to a\nnamespace to clients that you would trust with read access to the entire\nrepository. The known attack vectors are as follows: The victim sends \"have\" lines advertising the IDs of objects it has that\nare not explicitly intended to be shared but can be used to optimize the\ntransfer if the peer also has them. The attacker chooses an object ID X\nto steal and sends a ref to X, but isn’t required to send the content of\nX because the victim already has it. Now the victim believes that the\nattacker has X, and it sends the content of X back to the attacker\nlater. (This attack is most straightforward for a client to perform on a\nserver, by creating a ref to X in the namespace the client has access\nto and then fetching it. The most likely way for a server to perform it\non a client is to \"merge\" X into a public branch and hope that the user\ndoes additional work on this branch and pushes it back to the server\nwithout noticing the merge.) As in #1, the attacker chooses an object ID X to steal. The victim sends\nan object Y that the attacker already has, and the attacker falsely\nclaims to have X and not Y, so the victim sends Y as a delta against X.\nThe delta reveals regions of X that are similar to Y to the attacker."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options filename"
},
{
"role": "assistant",
"content": "filename prefix (when not using -h )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Atlassian \"logo\" after pushing to bitbucket\nThis question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.\n \n \n\n\n\n\n\n\nHaving pushed to bitbucket I got this \"image\". What is this?"
},
{
"role": "assistant",
"content": "Locked. Comments on this answer have been disabled, but it is still accepting other interactions. Learn more.\n \n \n\n\n\n\n\n\nWhen you push to a Git server, it can send arbitrary text back that is displayed on your terminal. This is frequently used for error messages, information on the server you are pushing to, or the like.\nIn this case, it is the Atlassian Logo, as Atlassian are the owners of Bitbucket, colored using ANSI escape sequences as a rainbow, likely to celebrate today's Supreme Court's decision to strike down laws against gay marriage in the US. It is also being applied each year, on or around the anniversary of this decision.\n\nMany sites around the internet have switched to rainbow colored version of their logo for similar reasons, including StackOverflow. Of course, as a US decision, this is probably going to be puzzling to some of those outside of the US.\nYou can disable these kind of messages on Bitbucket by going to your account settings and unchecking the “Enable console messages” setting."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-get-tar-commit-id"
},
{
"role": "assistant",
"content": "Extract commit ID from an archive created using git-archive"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options gpg.ssh.allowedSignersFile"
},
{
"role": "assistant",
"content": "A file containing ssh public keys which you are willing to trust.\nThe file consists of one or more lines of principals followed by an ssh\npublic key.\ne.g.: user1@example.com,user2@example.com ssh-rsa AAAAX1... See ssh-keygen(1) \"ALLOWED SIGNERS\" for details.\nThe principal is only used to identify the key and is available when\nverifying a signature. SSH has no concept of trust levels like gpg does. To be able to differentiate\nbetween valid signatures and trusted signatures the trust level of a signature\nverification is set to fully when the public key is present in the allowedSignersFile.\nOtherwise the trust level is undefined and git verify-commit/tag will fail. This file can be set to a location outside of the repository and every developer\nmaintains their own trust store. A central repository server could generate this\nfile automatically from ssh keys with push access to verify the code against.\nIn a corporate setting this file is probably generated at a global location\nfrom automation that already handles developer ssh keys. A repository that only allows signed commits can store the file\nin the repository itself using a path relative to the top-level of the working tree.\nThis way only committers with an already valid key can add or change keys in the keyring. Since OpensSSH 8.8 this file allows specifying a key lifetime using valid-after &\nvalid-before options. Git will mark signatures as valid if the signing key was\nvalid at the time of the signature’s creation. This allows users to change a\nsigning key without invalidating all previously made signatures. Using a SSH CA key with the cert-authority option\n(see ssh-keygen(1) \"CERTIFICATES\") is also valid."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "When to delete branches in Git?\n\nSuppose we have an application that's stable. \nTomorrow, someone reports a big ol' bug that we decide to hotfix right away. So we create a branch for that hotfix off of \"master\", we name it \"2011_Hotfix\", and we push it up so that all of the developers can collaborate on fixing it.\nWe fix the bug, and merge \"2011_Hotfix\" into \"master\" as well as into the current development branch. And push \"master.\"\nWhat do we do with \"2011_Hotfix\" now? Should it just sit out there as a branch forever until the end of time or should we now delete it, since it has served its purpose? It seems unclean to just leave branches lying around everywhere, as the list of branches will likely become very long, most of which aren't even necessary anymore.\nIn the event that it should be deleted, what will happen to its history? Will that be maintained, even though the actual branch is no longer available? Also, how would I remove a remote branch?"
},
{
"role": "assistant",
"content": "You can safely remove a branch with git branch -d yourbranch. If it contains unmerged changes (ie, you would lose commits by deleting the branch), git will tell you and won't delete it.\nSo, deleting a merged branch is cheap and won't make you lose any history.\nTo delete a remote branch, use git push origin :mybranch, assuming your remote name is origin and the remote branch you want do delete is named mybranch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "hint: after resolving the conflicts, mark the corrected paths\ngit sometimes gives me this message on a conflict (during a revert or cherry pick)\nhint: after resolving the conflicts, mark the corrected paths\n\nWhat does this mean?"
},
{
"role": "assistant",
"content": "This means that you need to explicitly tell Git that you've resolved a conflict at each file or folder (that is path).\n1. Look at the list of files with yet unresolved conflicts\ngit status\n\n2. Mark each file as resolved\nOnce you have resolved conflicts in a file, add it to mark that conflicts are resolved:\ngit add file-which-had-conflicts\n\nIf you would like to remove the file instead of resolving conflicts, do it with git rm. However, it's a rare case.\ngit rm file-which-had-conflicts\n\n3. Proceed with rebase/merge/whatever\ngit rebase --continue\ngit merge --continue\ngit cherry-pick --continue"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitworkflows - An overview of recommended workflows with Git"
},
{
"role": "assistant",
"content": "DISTRIBUTED WORKFLOWS After the last section, you should know how to manage topics. In\ngeneral, you will not be the only person working on the project, so\nyou will have to share your work. Roughly speaking, there are two important workflows: merge and patch.\nThe important difference is that the merge workflow can propagate full\nhistory, including merges, while patches cannot. Both workflows can\nbe used in parallel: in git.git , only subsystem maintainers use\nthe merge workflow, while everyone else sends patches. Note that the maintainer(s) may impose restrictions, such as\n\"Signed-off-by\" requirements, that all commits/patches submitted for\ninclusion must adhere to. Consult your project’s documentation for\nmore information. Merge workflow The merge workflow works by copying branches between upstream and\ndownstream. Upstream can merge contributions into the official\nhistory; downstream base their work on the official history. There are three main tools that can be used for this: git-push copies your branches to a remote repository,\nusually to one that can be read by all involved parties; git-fetch that copies remote branches to your repository;\nand git-pull that does fetch and merge in one go. Note the last point. Do not use git pull unless you actually want\nto merge the remote branch. Getting changes out is easy: Recipe: Push/pull: Publishing branches/topics git push <remote> <branch> and tell everyone where they can fetch\nfrom. You will still have to tell people by other means, such as mail. (Git\nprovides the git-request-pull to send preformatted pull\nrequests to upstream maintainers to simplify this task.) If you just want to get the newest copies of the integration branches,\nstaying up to date is easy too: Recipe: Push/pull: Staying up to date Use git fetch <remote> or git remote update to stay up to date. Then simply fork your topic branches from the stable remotes as\nexplained earlier. If you are a maintainer and would like to merge other people’s topic\nbranches to the integration branches, they will typically send a\nrequest to do so by mail. Such a request looks like Please pull from\n <URL> <branch> In that case, git pull can do the fetch and merge in one go, as\nfollows. Recipe: Push/pull: Merging remote topics git pull <URL> <branch> Occasionally, the maintainer may get merge conflicts when they try to\npull changes from downstream. In this case, they can ask downstream to\ndo the merge and resolve the conflicts themselves (perhaps they will\nknow better how to resolve them). It is one of the rare cases where\ndownstream should merge from upstream. Patch workflow If you are a contributor that sends changes upstream in the form of\nemails, you should use topic branches as usual (see above). Then use git-format-patch to generate the corresponding emails\n(highly recommended over manually formatting them because it makes the\nmaintainer’s life easier). Recipe: format-patch/am: Publishing branches/topics git format-patch -M upstream..topic to turn them into preformatted\npatch files git send-email --to=<recipient> <patches> See the git-format-patch and git-send-email manpages for further usage notes. If the maintainer tells you that your patch no longer applies to the\ncurrent upstream, you will have to rebase your topic (you cannot use a\nmerge because you cannot format-patch merges): Recipe: format-patch/am: Keeping topics up to date git pull --rebase <URL> <branch> You can then fix the conflicts during the rebase. Presumably you have\nnot published your topic other than by mail, so rebasing it is not a\nproblem. If you receive such a patch series (as maintainer, or perhaps as a\nreader of the mailing list it was sent to), save the mails to files,\ncreate a new topic branch and use git am to import the commits: Recipe: format-patch/am: Importing patches git am < patch One feature worth pointing out is the three-way merge, which can help\nif you get conflicts: git am -3 will use index information contained\nin patches to figure out the merge base. See git-am for\nother options."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does the argument @{u} mean in Git?\nIn the book \"Git: Version Control for Everyone. Beginner's Guide\" on page 69 there is a suggestion: \"As an alternative to git pull, we can also use git fetch followed by git merge @{u}\".\nWhat does @{u} mean here?\nA search in Google for git merge @{u} provides a link to this page https://mislav.net/2013/02/merge-vs-rebase/ where @{u} can also be found."
},
{
"role": "assistant",
"content": "It is a shortcut to refer to the upstream branch which the current branch is tracking. So for instance if you're on branch topic/fix_blub which is tracking origin/topic/fix_blub then git merge @{u} does the same thing as git merge origin/topic/fix_blub.\n@{u} is part of Git's mini-language for locating revisions, which is described in detail here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: change origin of cloned submodule\nI created a project submodule and put it up on Github.\nI created another project, supermodule, and then did this:\ncd supermodule\ngit init\nmkdir lib\ngit clone git://github.com/tandu/submodule lib/submodule\ngit submodule add ./lib/submodule lib/submodule\n\nThis worked fine, but on the website, it can't find the link to the submodule when viewing the files (in fact it just says \"Loading Commit data\" forever). The submodule folder itself has the correct origin.\nApparently, what I should have done was\n...\nmkdir lib\ngit submodule add git://github.com/tandu/submodule lib\n\n...but it's too late for that now. How can I have the submodule in this project correctly point to origin?"
},
{
"role": "assistant",
"content": "This apparently is very much dependent on the version of git you are using.\n\nIf present, change the url entry in the [submodule \"<dirname>\"] section of the .gitmodules file.\nIf present, change the url entry in the [submodule \"<dirname>\"] section of the .git/config file.\nChange the url in the configuration of the submodule itself. The location of the config file is version dependent. Older versions had it in <dirname>/.git/config, newer ones in .git/modules/<dirname>/config. However, you can always use below command:\n\ncd <dirname>\ngit config remote.origin.url <new_url>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab CI/CD runner : mvn command not found\n\nMaven is well installed on my gitlab-runner server. When executing mvn clean directly on my repo it works, when running my pipeline using Gitlab UI got this error :\n\nbash: line 60: mvn: command not found\nERROR: Job failed: exit status 1\n\nI notice that I tried to fix the problem by adding the before_script section in the .gitlab-ci.yml file :\nbefore_script: \n- export MAVEN_HOME=/usr/local/apache-maven\n\nI add also the line :\nenvironment = [\"MAVEN_HOME=/usr/local/apache-maven\"]\n\non the config.toml file.\nthe problem still persist, my executor is : shell.\nAny advice!"
},
{
"role": "assistant",
"content": "Just add the maven docker image, add below line as first line:\nimage: maven:latest or image: maven:3-jdk-10 or image: maven:3-jdk-9\n\nrefer: https://docs.gitlab.com/ee/ci/examples/artifactory_and_gitlab/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "When should I use git pull --rebase?\nI know of some people who use git pull --rebase by default and others who insist never to use it. I believe I understand the difference between merging and rebasing, but I'm trying to put this in the context of git pull. Is it just about not wanting to see lots of merge commit messages, or are there other issues?"
},
{
"role": "assistant",
"content": "I would like to provide a different perspective on what git pull --rebase actually means, because it seems to get lost sometimes.\nIf you've ever used Subversion (or CVS), you may be used to the behavior of svn update. If you have changes to commit and the commit fails because changes have been made upstream, you svn update. Subversion proceeds by merging upstream changes with yours, potentially resulting in conflicts.\nWhat Subversion just did, was essentially git pull --rebase. The act of re-formulating your local changes to be relative to the newer version is the \"rebasing\" part of it. If you had done svn diff prior to the failed commit attempt, and compare the resulting diff with the output of svn diff afterwards, the difference between the two diffs is what the rebasing operation did.\nThe major difference between Git and Subversion in this case is that in Subversion, \"your\" changes only exist as non-committed changes in your working copy, while in Git you have actual commits locally. In other words, in Git you have forked the history; your history and the upstream history has diverged, but you have a common ancestor.\nIn my opinion, in the normal case of having your local branch simply reflecting the upstream branch and doing continuous development on it, the right thing to do is always --rebase, because that is what you are semantically actually doing. You and others are hacking away at the intended linear history of a branch. The fact that someone else happened to push slightly prior to your attempted push is irrelevant, and it seems counter-productive for each such accident of timing to result in merges in the history.\nIf you actually feel the need for something to be a branch for whatever reason, that is a different concern in my opinion. But unless you have a specific and active desire to represent your changes in the form of a merge, the default behavior should, in my opinion, be git pull --rebase.\nPlease consider other people that need to observe and understand the history of your project. Do you want the history littered with hundreds of merges all over the place, or do you want only the select few merges that represent real merges of intentional divergent development efforts?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rm - Remove files from the working tree and from the index -f --force"
},
{
"role": "assistant",
"content": "Override the up-to-date check."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab: team member project access levels\n\nGitLab offers the project access levels:\n\n\"Guest\"\n\"Reporter\"\n\"Developer\"\n\"Master\"\n\nfor \"team members\" co-operating with a specific project.\n\"Master\" and \"Guest\" are self-explanatory, but the others aren't quite clear to me, in their extents as well as in their granularity.\nWhat is the difference between these levels?"
},
{
"role": "assistant",
"content": "2013: The project_security_spec.rb test each profile capabilities, which are listed in ability.rb:\n(2017 GitLab 10.x: this would be more likely in app/policies/project_policy.rb)\nSee also, as noted in jdhao's answer: \"Project members permissions\"\nThose rules are quite explicit:\ndef public_project_rules\n [\n :download_code,\n :fork_project,\n :read_project,\n :read_wiki,\n :read_issue,\n :read_milestone,\n :read_project_snippet,\n :read_team_member,\n :read_merge_request,\n :read_note,\n :write_issue,\n :write_note\n ]\nend\n\ndef project_guest_rules\n [\n :read_project,\n :read_wiki,\n :read_issue,\n :read_milestone,\n :read_project_snippet,\n :read_team_member,\n :read_merge_request,\n :read_note,\n :write_project,\n :write_issue,\n :write_note\n ]\nend\n\ndef project_report_rules\n project_guest_rules + [\n :download_code,\n :fork_project,\n :write_project_snippet\n ]\nend\n\ndef project_dev_rules\n project_report_rules + [\n :write_merge_request,\n :write_wiki,\n :push_code\n ]\nend\n\nThat means:\n\na reporter is a guest who can also:\n\ndownload code,\nfork a project,\nwrite project snippet\n\n\na developer is a reporter who can also:\n\nwrite merge request,\nwrite wiki pages,\npush code\n\n\n\n\nNote: with GitLab 15.0 (May 2022):\n\nUsers with the Reporter role can manage iterations and milestones\nWe’ve changed the permissions necessary to create, edit, and delete milestones and iterations from the Developer to Reporter role.\nThis change better reflects the typical day-to-day Reporter responsibilities of managing and tracking planning timeboxes.\nSee Documentation and Issue.\n\n\nAnd GitLab 17.0 (May 2024) adds, still for the Reporter role:\n\nDesign Management features extended to Product teams\nGitLab is expanding collaboration by updating our permissions. Now, users with the Reporter role can access Design Management features, enabling product teams to engage more directly in the design process. This change simplifies workflows and accelerates innovation by inviting broader participation from across your organization.\nSee Documentation and Issue.\n\nAnd, still with GitLab 17.0 (May 2024)\n\nGuests in groups can link issues\nWe reduced the minimum role required to relate issues and tasks from Reporter to Guest, giving you more flexibility to organize work across your GitLab instance while maintaining permissions.\nSee Documentation and Epic."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I add Git version control (Bitbucket) to an existing source code folder?\nHow can I add the contents of an existing folder to Git version control?\nThe tutorial here covers the case of making a directory and then adding source contents to it. I have some source code in a folder that is path dependent and don't want to move it.\nSo, how can I just go into my folder and make it a repository?"
},
{
"role": "assistant",
"content": "Final working solution\nusing @Arrigo response and @Samitha Chathuranga comment, I'll put all together to build a full response for this question:\n\nSuppose you have your project folder on PC;\nCreate a new repository on bitbucket:\n\nPress on I have an existing project:\n\nOpen Git CMD console and type command 1 from second picture(go to your project folder on your PC)\nType command git init\nType command git add --all\nType command 2 from second picture (git remote add origin YOUR_LINK_TO_REPO)\nType command git commit -m \"my first commit\"\nType command git push -u origin master\n\nNote: if you get error unable to detect email or name, just type following commands after 5th step:\n git config --global user.email \"yourEmail\" #your email at Bitbucket\n git config --global user.name \"yourName\" #your name at Bitbucket"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options gpg.format"
},
{
"role": "assistant",
"content": "Specifies which key format to use when signing with --gpg-sign .\nDefault is \"openpgp\". Other possible values are \"x509\", \"ssh\". See gitformat-signature for the signature format, which differs\nbased on the selected gpg.format ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git sign off previous commits?\nI was wondering how to sign(-s) off previous commits that I have made in the past in git?\nCLARIFICATION: Git has confusingly similarly named concepts\ngit commit -s, --signoff (lower case -s) and git commit -S, --gpg-sign (upper case -S).\nThis question is about signoff(lower case -s).\nHowever some answers here are about gpg-sign(upper case -S), that better discussed in dedicated questions on superUser Can you GPG sign old commits?\nand stackoverflow Is there a way to gpg sign all previous commits?"
},
{
"role": "assistant",
"content": "To signoff the previous commit, use amend option:\ngit commit --amend --signoff\n\nSince Git 2.13, you can use the --signoff rebase option to specify range of commits to signoff (credits to @sschuberth). Example to signoff last two commits:\ngit rebase --signoff HEAD~2\n\nTo signoff multiple commits using Git prior to version 2.13, use filter-branch and interpret-trailers as suggested by @vonc et. al. Here is what worked for me.\nFirst, configure git to replace the token sign by Signed-off-by. This has to be done only once and is needed in the next step.\ngit config trailer.sign.key \"Signed-off-by\"\n\nThe command git filter-branch with the switch --msg-filter will eval the filter once for each commit. The filter can be any shell command that receives the commit message on stdin and outputs on stdout. You can write your own filter, or use git interpret-trailers, which is indepotent. Here is an example that will signoff the latest two commits of the current branch using the current user and email:\nexport SIGNOFF=\"sign: $(git config --get user.name) <$(git config --get user.email)>\"\ngit filter-branch -f --msg-filter \\\n \"git interpret-trailers --trailer \\\"$SIGNOFF\\\"\" \\\n HEAD~2..HEAD\n\nNote 1) Modifying commit messages change the commit id, which means pushing over already published branches will have to be forced either with --force or better --force-with-lease.\nNote 2) if you intend to write your custom script, beware that git filter-branch changes the current directory to <repo>/.git-rewrite/t. Using a relative path to the script won't usually work. Instead, the script should be in your $PATH or provided as an absolute path."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-send-email - Send a collection of patches as emails"
},
{
"role": "assistant",
"content": "SYNOPSIS git send-email [<options>] (<file>|<directory>)… git send-email [<options>] <format-patch-options> git send-email --dump-aliases"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git rebase and git push: non-fast forward, why use?\nI have a branch that should be available to other contributors and that should constantly stay up to date with the master.\nUnfortunately, every time I do 'git rebase' and then try to push, it results in 'non-fast forward' message and abortion of pushing. The only way to push here is to use --force. Does that mean I should use 'git merge' instead of rebasing if my branch went public and others are working on it?"
},
{
"role": "assistant",
"content": "A few notes on how git works (non technical):\nWhen you rebase, git takes the commits in question, and \"recommits\" them on top of a clean history. This is to prevent the history from showing:\nDescription: tree -> mywork -> merge -> mywork -> merge -> mywork -> merge\nCommit SHA1: aaaa -> bbbb -> cccc -> dddd -> eeee -> ffff -> gggg\n\nAfter a rebase, it may look like this (or similar):\nDescription: tree -> rebase\nCommit SHA1: aaaa -> hhhh\n\nThe issue is that the new commit you are attempting to push out there is NOT a descendant of the commit on the tip of the branch you are pushing to.\nNow, you know that the same info is in the commits, but git is being responsible by not just overwriting those commits out there (bbbb-gggg in the example above).\n\nShared Repo Model\nIf you are using a shared repository, then things like this can get mighty confusing. Let me explain why. Say another developer pulled down the branch, and they have commits aaaa -> gggg in their branch. Then they make a commit iiii\nIn the meanwhile, you rebased and forced a push, causing the tree to look like this:\nDescription: tree -> rebase\nCommit SHA1: aaaa -> hhhh\n\nWhen the other developer tries to push, he gets a \"non-fast forward\" message. When he does a merge, then both histories are RELINKED together, and you end up with a mess\nSomething like this (messy):\nDescription: tree -> rebase -> mywork -> merge -> mywork -> merge -> mywork -> merge -> devwork -> merge \nCommit SHA1: aaaa -> hhhh -> bbbb -> cccc -> dddd -> eeee -> ffff -> gggg -> iiii -> jjjj\n\nIN other words, if others are pulling AND pushing, it's better that you stick with git merge, or AVOID PUSHING until after the rebase (and only rebase your work).\n\nPublicly Visible Repository Model\nPerhaps you are using a different (more gittish) model where you just want people to be able to pull from your repo. In this case, git push --force isn't too bad, because then they can deal with keeping up with it. They can rebase their changes to be on top of your changes before giving their patches to you. It prevents your repo from getting all messed up.\nHowever, there may be a better way for you. git push --mirror\nFrom http://www.kernel.org/pub/software/scm/git/docs/git-push.html\n\nInstead of naming each ref to push, specifies that all refs under\n $GIT_DIR/refs/ (which includes but is\n not limited to refs/heads/,\n refs/remotes/, and refs/tags/) be\n mirrored to the remote repository.\n Newly created local refs will be\n pushed to the remote end, locally\n updated refs will be force updated on\n the remote end, and deleted refs will\n be removed from the remote end. This\n is the default if the configuration\n option remote..mirror is set.\n\n\nOne of the great things about git is that it is very flexible and allows for many different kind of workflows. But it's real strength lies in the fact that it is a distributed model, so I believe that the most ROI can be reaped by using it that way."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc"
},
{
"role": "assistant",
"content": "SYNOPSIS git diff [<options>] [<commit>] [--] [<path>…] git diff [<options>] --cached [--merge-base] [<commit>] [--] [<path>…] git diff [<options>] [--merge-base] <commit> [<commit>…] <commit> [--] [<path>…] git diff [<options>] <commit>…<commit> [--] [<path>…] git diff [<options>] <blob> <blob> git diff [<options>] --no-index [--] <path> <path>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git commit to common submodule (master branch)\nI've two or more projects (let's call them ProjectFoo and ProjectBar) having some common code that I put in a submodule.\nMy understanding is that if I commit changes to a submodule from within ProjectFoo it'll be in a detached head that only all ProjectFoo clones can see:\n(master) $ cd ProjectFooBarCommoneSubmodule/\n(master) $ git commit -am \"Common code fix.\"\n(56f21fb0...) $ git push\nEverything up-to-date\n\nThat's probably because the master branch hasn't changed. I could probably do something like git checkout master && git merge Everything up-to-date but that seem pretty ugly. May be a git reset --hard master would do the same but it seems even uglier.\nHow to have a common code shared by project, updated from within those projects using it? In other words, committing to that submodule should update all various repositories (repositories, not just clones) that use this same submodule.\n---- EDIT ----\nVisibly my checked-out repository was messed up and broken. It should have worked right from the start like that (on ProjectFoo in this example):\n(master) $ cd ProjectFooBarCommoneSubmodule/\n(master) $ git commit -am \"Common code fix.\"\n(master) $ git push\n....\n fbfdd71..0acce63 master -> master\n(master) $ cd ..\n(master) $ git add ProjectFooBarCommoneSubmodule\n(master) $ git commit -m \"Submodule update.\"\n\nThen to get that change from on other projects, like ProjectBar:\n(master) $ cd ProjectFooBarCommoneSubmodule/\n(master) $ git pull\n\nWould update to the latest common code. A git checkout master may be required if it's on a detached head."
},
{
"role": "assistant",
"content": "Short answer: \ncd ProjectFooBarCommoneSubmodule\ngit checkout master\n<Do your editing>\ngit commit --all -m \"Lots of fixes\"\ngit push submodule_origin master\ncd ..\n\ngit add ProjectFooBarCommoneSubmodule\ngit commit -m \"Bumped up the revision of ProjectFooBarCommoneSubmodule\"\ngit push origin master\n\nThe longer one: \nGit submodules are a dependency mechanism, where the main project (say A) defines a specified revision in a subproject (say B), which will be used in building project A. In order for the tool to be useful the behavior has to be predictable from A:s point of view. Dependencies cannot change, unless somebody decides to incorporate the change to project A. All kinds of nasty things could happen, were project B:s changes automatically imported, of which compile errors are probably the best ones, as A would notice the failures immediately. This is why B:s head is kept in detached state. \nThe state of B is store in A (check out git submodule status), and a revision change has to be done and committed in A, in order for it to have any effect. This is what happens in the example above, A changes the revision number stored in the repo, and bumps up the version to the latest one. The process will have to be repeated in the other main repo as well, so no automatic \"use master\" switch AFAIK.\nBTW. The Git book chapter on submodules and the submodule man page contain lots of useful info about submodules, as normal usage and typical pitfalls as well. Worth checking out.\n\nEDIT: I'll try to explain this better\nI took the liberty to create example projects on my github account. The commits are meaningless and contain junk, but the setup should be fine. Please check it out to follow.\nBoth ProjectFoo and ProjectBar share the code in the common submodule. \nProjectFooBarCommoneSubmodule:master is 6850e4e4c1fac49de398\nIn ProjectFoo: \ngit submodule status\n\n-6850e4e4c1fac49de39890703f21486ca04b87a0 common\nIn ProjectBar:\ngit submodule status\n\n-6850e4e4c1fac49de39890703f21486ca04b87a0 common\nSo both point to the same revision, right? The trick here is to see, that ProjectFoo and ProjectBar point to the revision (6850e4e4c1fac49de39890703f21486ca04b87a0) not the branch (master), although they are the same thing. The first one is a detached head, and the other a named branch.\nIf you want to do some fixing on ProjectFooBarCommoneSubmodule, you can go to the subdir in e.g. ProjectFoo, and choose the branch instead of the revision:\ngit checkout master \n<Do your coding and pushing here>\n\nThen go one directory up, and check git submodule status. It should tell you, that you are now out of sync. E.g\ngit submodule status\n\n+e24bd2bf45d52171a63b67ac05cd4be0ac965f60 common (heads/master-1-ge24bd2b)\nNow you can do a git add, to set the reference to this particular commit(ge24bd...), do a commit, and after this the submodule reference points to this revision, which also happens to be master on ProjectFooBarCommoneSubmodule. \nNow you need to update the reference in ProjectBar as well. Go to ProjectBar/common, and do git fetch origin (this is a fast forward merge), do \ngit checkout master \ncd ..\ngit add common\ngit commit -m \"Bumped up the revision\"\ngit push origin master # to publish the revision bump to everybody else\n\nSo, as with any git repository, you don't need to work on a detached head. You can either work on master, or create a named branch. Either way, make sure that upstream contains the ProjectFooBarCommoneSubmodule changes, or you will break both ProjectFoo and ProjectBar, if they reference something that doesn't exist. Hope this explained it better"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github \"Branch name pattern\" negation\n\nOn Github, when you go to branch settings and create a \"Branch protection rule\", how do I specify any branch other than 'master'? I've tried a bunch of regex-like expressions, but none seem to work :("
},
{
"role": "assistant",
"content": "GitHub uses fnmatch to match against any pattern provided to find out the branches to which the rule applies for branch protection.\nThere isn't an exact fnmatch pattern for GitHub yet which can resolve to precisely anything other than master, but the pattern closest to it would be:\n*[!master]*\n\nBut this would also exclude branches with only m,a,s,t,e,r or branches with only a combination of those letters.\nCheck out more details on the above on GitHub help and the fnmatch documentation"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index apply.whitespace"
},
{
"role": "assistant",
"content": "Tells git apply how to handle whitespace, in the same way\nas the --whitespace option. See git-apply ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to push changes to github after jenkins build completes?\n\nI have a jenkins job that clones the repository from github, then runs the powershell script that increments the version number in the file. I'm now trying to publish that update file back to the original repository on github, so when developer pulls the changes he gets the latest version number.\nI tried using Git Publisher in the post build events, and I can publish tags with no issues, but it doesn't seem to publish any files."
},
{
"role": "assistant",
"content": "The git checkout master of the answer by Woland isn't needed. Instead use the \"Checkout to specific local branch\" in the \"Additional Behaviors\" section to set the \"Branch name\" to master.\nThe git commit -am \"blah\" is still needed.\nNow you can use the \"Git Publisher\" under \"Post-build Actions\" to push the changes. Be sure to specify the \"Branches\" to push (\"Branch to push\" = master, \"Target remote name\" = origin).\n\"Merge Results\" isn't needed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options imap.user"
},
{
"role": "assistant",
"content": "The username to use when logging in to the server."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I fetch an unmerged pull request for a branch I don't own?\n\nI need to pull in a specific pull request (that hasn't been processed into the main stream yet) in the NServiceBus repo:\nhttps://github.com/johnsimons/NServiceBus/commit/d8524d53094e8181716e771c1023e968132abc15\nIt's obviously not my repo, but I need the changes that exist in that pull request.\nWhat is the best way to do this?"
},
{
"role": "assistant",
"content": "git pull origin pull/28/head\n\nOr\ngit fetch origin pull/28/head:28\ngit checkout 28\n\nCan I pull a not-yet-merged pull request?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: programmatically know by how much the branch is ahead/behind a remote branch\nI would like to extract the information that is printed after a git status, which looks like:\n# On branch master\n# Your branch is ahead of 'origin/master' by 2 commits.\n\nOf course I can parse the output of git status but this is not recommended since this human readable output is liable to change.\nThere are two problems:\n\nHow to know the remote tracked branch? It is often origin/branch but need not be.\nHow to get the numbers? How to know whether it is ahead/behind? By how many commits? And what about the diverged branch case?"
},
{
"role": "assistant",
"content": "git rev-list origin..HEAD will show the commits that are in your current branch, but not origin -- i.e., whether you're ahead of origin and by which commits. \ngit rev-list HEAD..origin will show the opposite. \nIf both commands show commits, then you have diverged branches."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "'cannot open git-upload-pack' error in Eclipse when cloning or pushing git repository\nI am not able to clone or push to a git repository at Bitbucket in Eclipse:\n\nIt's weird, because a day before I didn't have any problem. I have downloaded the sts 3 times with no luck. This error keeps showing. Also I have installed SourceTree and it says 'This is not a valid source path / URL':\n\nIf I use git commands to import the project, it works, but I wan't to use EGit for this task, since I am a newbie with git. \nI don't know if this has to do with it, but in the same directory I have the android-adt-bundle. This one works pretty well, but the project lies on GitHub and not Bitbucket. Also, I'm working with another person and he is able to fetch and push data from and to the Bitbucket repository. I have read lots of posts but none of them have helped me out. \nI'm using Windows 7 btw."
},
{
"role": "assistant",
"content": "Might also be bad SSL cert, fix the server\nIf you have a GIT server with an outdated or self-signed SSL cert fix the server, afterwards everything should run fine. \nInsecure Hotfix: Let the client accept any certificate\nThe following solution is just a mere hotfix on client side and should be avoided as it compromises security of your credentials and content. There is a detailed explanation for this in \"How can I make git accept a self signed certificate?\" which offers more complex and more secure solutions you can try out if the following works in general.\nIn my case it was Eclipse using a different storage for the git config as the command line does and thus not having the option \ngit config http.sslVerify false\n\nset (which I set using command line for the repo for working with invalid/untrusted SSL cert).\nAdding the option insides Eclipse immediately resolves the issue. To add the option \n\nopen preferences via application menu Window => Preferences (or on OSX Eclipse => Settings).\nNavigate to Team => Git => Configuration \nclick Add entry..., then put http.sslVerify in the key box and false in the value box.\n\nSeems to be a valid solution for Eclipse 4.4 (Luna), 4.5.x (Mars) and 4.6.x (Neon) on different Operating systems."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to run a gitlab-ci.yml job only on a tagged branch?\n\nHow do I run a .gitlab-ci.yml job only on a tagged Master branch?\njob:\n script:\n - echo \"Do something\"\n only:\n - master\n - tags\n\nThe above code will run if either condition exists: a Master branch or a tagged commit. \nMy goal is to have this run for a production deploy, but it would require that it be on the Master branch and that it be tagged (with a version). Otherwise, I'll have another job that will push to staging if its missing a tag."
},
{
"role": "assistant",
"content": "This behavior will be introduced in version 12.\nOpen issue was recently update:\n\nJason Lenny @jlenny changed title from {-Update .gitlab-ci.yml to\nsupport conjunction logic for build conditions-} to Conjunction logic\nfor build conditions MVC · 2 days ago\nJason Lenny @jlenny changed milestone to 12.0 · 2 days ago\n\n(fingers crossed)\nA solution is to use the except keyword to exclude all the branches, in conjunction with only to run on tags, in this way you run your pipeline only on tag in master branch:\n only:\n - tags\n except:\n - branches\n\nI'm using version 11.3.4"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitsubmodules - Mounting one repository inside another"
},
{
"role": "assistant",
"content": "DESCRIPTION A submodule is a repository embedded inside another repository.\nThe submodule has its own history; the repository it is embedded\nin is called a superproject. On the filesystem, a submodule usually (but not always - see FORMS below)\nconsists of (i) a Git directory located under the $GIT_DIR/modules/ directory of its superproject, (ii) a working directory inside the\nsuperproject’s working directory, and a .git file at the root of\nthe submodule’s working directory pointing to (i). Assuming the submodule has a Git directory at $GIT_DIR/modules/foo/ and a working directory at path/to/bar/ , the superproject tracks the\nsubmodule via a gitlink entry in the tree at path/to/bar and an entry\nin its .gitmodules file (see gitmodules ) of the form submodule.foo.path = path/to/bar . The gitlink entry contains the object name of the commit that the\nsuperproject expects the submodule’s working directory to be at. The section submodule.foo.* in the .gitmodules file gives additional\nhints to Git’s porcelain layer. For example, the submodule.foo.url setting specifies where to obtain the submodule. Submodules can be used for at least two different use cases: Using another project while maintaining independent history.\nSubmodules allow you to contain the working tree of another project\nwithin your own working tree while keeping the history of both\nprojects separate. Also, since submodules are fixed to an arbitrary\nversion, the other project can be independently developed without\naffecting the superproject, allowing the superproject project to\nfix itself to new versions only when desired. Splitting a (logically single) project into multiple\nrepositories and tying them back together. This can be used to\novercome current limitations of Git’s implementation to have\nfiner grained access: Size of the Git repository:\nIn its current form Git scales up poorly for large repositories containing\ncontent that is not compressed by delta computation between trees.\nFor example, you can use submodules to hold large binary assets\nand these repositories can be shallowly cloned such that you do not\nhave a large history locally. Transfer size:\nIn its current form Git requires the whole working tree present. It\ndoes not allow partial trees to be transferred in fetch or clone.\nIf the project you work on consists of multiple repositories tied\ntogether as submodules in a superproject, you can avoid fetching the\nworking trees of the repositories you are not interested in. Access control:\nBy restricting user access to submodules, this can be used to implement\nread/write policies for different users."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc plain"
},
{
"role": "assistant",
"content": "Any line that is added in one location and was removed\nin another location will be colored with color.diff.newMoved .\nSimilarly color.diff.oldMoved will be used for removed lines\nthat are added somewhere else in the diff. This mode picks up any\nmoved line, but it is not very useful in a review to determine\nif a block of code was moved without permutation."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clone - Clone a repository into a new directory"
},
{
"role": "assistant",
"content": "DESCRIPTION Clones a repository into a newly created directory, creates\nremote-tracking branches for each branch in the cloned repository\n(visible using git branch --remotes ), and creates and checks out an\ninitial branch that is forked from the cloned repository’s\ncurrently active branch. After the clone, a plain git fetch without arguments will update\nall the remote-tracking branches, and a git pull without\narguments will in addition merge the remote master branch into the\ncurrent master branch, if any (this is untrue when --single-branch is given; see below). This default configuration is achieved by creating references to\nthe remote branch heads under refs/remotes/origin and\nby initializing remote.origin.url and remote.origin.fetch configuration variables."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to undo a git restore to get back changes\nHere is my situation, I'm still new to git and while I was working on a project I didn't constantly commit. \nI finished the project and added everything other than the index.html file and committed them. I pushed the changes to my repository. I then checked my git status and saw that index.html was still listed which I thought was a mistake and maybe I just did a little edit by accident or something so I did a git restore index.html.\nI almost immediately realized what I did and checked the file to see that the file had been reverted to its original form. Please tell me there is a way to get my changes back. I just want to emphasize that the command I used was git restore index.html"
},
{
"role": "assistant",
"content": "If the file you accidentally restored is currently open in your Text Editor or IDE, a simply Undo operation would do the trick and get you your changes back.\nI accidentally typed git restore . while I only wanted to restore one file. Luckily for me, all the files that had been restored by the command were still open in VSCode, where I made the changes, so executing an Undo in each of those files did the trick for me and I got my changes back."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker --exec-path[=<path>]"
},
{
"role": "assistant",
"content": "Path to wherever your core Git programs are installed.\nThis can also be controlled by setting the GIT_EXEC_PATH\nenvironment variable. If no path is given, git will print\nthe current setting and then exit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git gui: how to clone and push?\nI think I am stupid. I don't understand how Git works with the command lines so I am using Git Gui.\nI got it install and the Gui can be launched successfully, but when I come to clone the file from the files which is shared by another programmer with me, I keep getting this error message,\nLocation C:/.... already exists.\non the Gui interface, it has two input fields to fill in only -\n'Source Location' : https://[email protected]/remote-programmer/project-1.git (for instance)\n'Target Directory' : C:/wamp/www/project-1-folder (for instance)\n\nany visual guides available that I can avoid the command lines?\nthanks!"
},
{
"role": "assistant",
"content": "You need to clone into a new directory, that is, that \"Target Directory\" that you specify should not already exist."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitmodules"
},
{
"role": "assistant",
"content": "Defining submodule properties"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git remove directory\nI've got a repository on GitHub (http://github.com/hrickards/PHP-Crypto) for a little project me and a couple of others are working on. My development environment is Aptana Studio, and I use the EGit plugin as Aptana is basically Eclipse underneath. Today the designer sent the HTML and CSS for the website with the images in a folder named img. Previously the images were in a folder called images. Thinking nothing of it and being too lazy to update the CSS and HTML, I simply kept the images in the img directory and commited to Git. However, the GitHub web interface shows both the img and images directories, with the images directory being empty. I've tried deleting the images directory with git rm -r images and git rm images, and even mkdir images; git add images; git rm -r images but whatever I try I get the same result:\nfatal: pathspec 'images' did not match any files.\nHas anyone got any advice on how to remove images, or am I misunderstanding Git or something?"
},
{
"role": "assistant",
"content": "This is what I use, and I think you'll want to as well. It's close to the other answers, but instructs git to NOT change the local files. \ngit rm -r -f --cached DirectoryName\n\n\n-r : recursive\n-f : force\n--cached : apply ONLY to index (staging area). Git leaves the local copies alone."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --tags[=<pattern>]"
},
{
"role": "assistant",
"content": "Pretend as if all the refs in refs/tags are listed\non the command line as <commit> . If <pattern> is given, limit\ntags to ones matching given shell glob. If pattern lacks ? , * ,\nor [ , /* at the end is implied."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index --build-fake-ancestor=<file>"
},
{
"role": "assistant",
"content": "Newer git diff output has embedded index information for each blob to help identify the original version that\nthe patch applies to. When this flag is given, and if\nthe original versions of the blobs are available locally,\nbuilds a temporary index containing those blobs. When a pure mode change is encountered (which has no index information),\nthe information is read from the current index instead."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index"
},
{
"role": "assistant",
"content": "diff format for merges \"git-diff-tree\", \"git-diff-files\" and \"git-diff --raw\"\ncan take -c or --cc option\nto generate diff output also for merge commits. The output differs\nfrom the format described above in the following way: there is a colon for each parent there are more \"src\" modes and \"src\" sha1 status is concatenated status characters for each parent no optional \"score\" number tab-separated pathname(s) of the file For -c and --cc , only the destination or final path is shown even\nif the file was renamed on any side of history. With --combined-all-paths , the name of the path in each parent is shown\nfollowed by the name of the path in the merge commit. Examples for -c and --cc without --combined-all-paths : ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM\tdesc.c\n::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM\tbar.sh\n::100644 100644 100644 e07d6c5 9042e82 ee91881 RR\tphooey.c Examples when --combined-all-paths added to either -c or --cc : ::100644 100644 100644 fabadb8 cc95eb0 4866510 MM\tdesc.c\tdesc.c\tdesc.c\n::100755 100755 100755 52b7a2d 6d1ac04 d2ac7d7 RM\tfoo.sh\tbar.sh\tbar.sh\n::100644 100644 100644 e07d6c5 9042e82 ee91881 RR\tfooey.c\tfuey.c\tphooey.c Note that combined diff lists only files which were modified from\nall parents."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Merge development branch with master\nI have two branches namely master and development in a GitHub Repository. I am doing all my development in development branch as shown.\ngit branch development\ngit add *\ngit commit -m \"My initial commit message\"\ngit push -u origin development\n\nNow I want to merge all the changes on the development branch into the master. My current approach is:\ngit checkout master \ngit merge development\ngit push -u origin master \n\nPlease let me know if the procedure I am following is correct."
},
{
"role": "assistant",
"content": "I generally like to merge master into the development first so that if there are any conflicts, I can resolve in the development branch itself and my master remains clean.\n(on branch development)$ git merge master\n(resolve any merge conflicts if there are any)\ngit checkout master\ngit merge development (there won't be any conflicts now)\n\nThere isn't much of a difference in the two approaches, but I have noticed sometimes that I don't want to merge the branch into master yet, after merging them, or that there is still more work to be done before these can be merged, so I tend to leave master untouched until final stuff.\nEDIT: From comments\nIf you want to keep track of who did the merge and when, you can use --no-ff flag while merging to do so. This is generally useful only when merging development into the master (last step), because you might need to merge master into development (first step) multiple times in your workflow, and creating a commit node for these might not be very useful.\ngit merge --no-ff development"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git fetch --unshallow gives :\"fatal: --unshallow on a complete repository does not make sense\" error\n\nI am unable to git clone a remote repository using plain\ngit clone path \n\nI get the error \"The remote end hung up unexpectedly\".\nThe complete msg I get is :\nCloning into 'xyzabc'...\nremote: Counting objects: 4328, done.\nremote: Compressing objects: 100% (3861/3861), done.\nselect: Not enough memory2192/4328), 123.71 MiB | 164.00 KiB/s\nffatal: The remote end hung up unexpectedly\natal: early EOF\nfatal: index-pack failed\n\nI search online for a solution and after trying every other solution landed on solution of doing :\ngit clone --depth=1 path\n\nfollowed by\ngit fetch --unshallow\n\nNow the clone is completing fully. But, when I try to run git fetch --unshallow to recieve the complete project, I get the error :\nfatal: --unshallow on a complete repository does not make sense\n\nI dont know what to do please guide"
},
{
"role": "assistant",
"content": "I too found the same message. Looks like it's not allowing to unshallow a shallow clone. You might want to try. \ngit fetch --depth=10000\n\nassuming there are 10000 depths in your clone."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Not asking password in my gitlab Repository\n\nPS E:\\Angular> git clone https://gitlab.com/souravgolui/MatDash.git <br>\nCloning into 'MatDash'...\nremote: HTTP Basic: Access denied<br>\nfatal: Authentication failed for 'https://gitlab.com/souravgolui/MatDash.git/'\n\nThis error will show in command prompt. please help.\nI entered wrong password , but not asking password 2nd time."
},
{
"role": "assistant",
"content": "If password not asking(prompt popup), and saying authentication failed then follow below steps:\n\nclick on start\nType : Credential Manager\nSee the Windows (Manager shortcut or Credential Manager shortcut) and double-click it to open the application\nOnce the app is open, click on the (\"Windows Credentials\" or \"Generic Credentials\") tab where git:https://...\nselect edit and modify your update pwd then save it.***\n\nNow enjoy your work :)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "ssh_exchange_identification: Connection closed by remote host under Git bash [closed]\nClosed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.\n\n\nClosed 2 years ago.\n\n\nThe community reviewed whether to reopen this question 1 year ago and left it closed:\n\nOriginal close reason(s) were not resolved\n\n\n\n\n\n\n Improve this question\n \n\n\n\nI work at win7 and set up git server with sshd.\nI git --bare init myapp.git, and clone ssh://git@localhost/home/git/myapp.git in Cywgin correctly. But I need config git of Cygwin again, I want to git clone in Git Bash. I run git clone ssh://git@localhost/home/git/myapp.git and get following message\nssh_exchange_identification: Connection closed by remote host\n\nthen I run ssh -vvv git@localhost in Git Bash and get message\ndebug2: ssh_connect: needpriv 0\ndebug1: Connecting to localhost [127.0.0.1] port 22.\ndebug1: Connection established.\ndebug1: identity file /c/Users/MoreFreeze/.ssh/identity type -1\ndebug3: Not a RSA1 key file /c/Users/MoreFreeze/.ssh/id_rsa.\ndebug2: key_type_from_name: unknown key type '-----BEGIN'\ndebug3: key_read: missing keytype\ndebug3: key_read: missing whitespace \n// above it repeats 24 times\ndebug2: key_type_from_name: unknown key type '-----END'\ndebug3: key_read: missing keytype\ndebug1: identity file /c/Users/MoreFreeze/.ssh/id_rsa type 1\ndebug1: identity file /c/Users/MoreFreeze/.ssh/id_dsa type -1\nssh_exchange_identification: Connection closed by remote host\n\nit seems my private keys has wrong format? And I find that there are exactly 25 line in private keys without BEGIN and END.\nI'm confused why it said NOT RSA1 key, I totally ensure it is RSA 2 key.\nAny advises are welcome.\nbtw, I have read first 3 pages on google about this problem."
},
{
"role": "assistant",
"content": "I had this problem today and I realize that I was connected to 2 differente networks (LAN and WLAN), I solved it just disconnecting the cable from my Ethernet adapter. I suppose that the problem is caused because the ssh key is tied with the MAC address of my wireless adapter. I hope this helps you."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs -p -u --patch"
},
{
"role": "assistant",
"content": "Generate patch (see Generating patch text with -p )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-archive - Create an archive of files from a named tree git archive --format=tar --prefix=git-1.4.0/ v1.4.0 | gzip >git-1.4.0.tar.gz"
},
{
"role": "assistant",
"content": "Create a compressed tarball for v1.4.0 release."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I prevent 'git diff' from using a pager?\nIs there a command line switch to pass to git diff and other commands that use the less pager by default? I know these methods exist:\n\ngit diff | cat... removes all syntax highlighting\ngit config --global core.pager cat sets the pager in the global .gitconfig to cat\nexport GIT_PAGER=cat\n\nBut I would prefer a command line switch."
},
{
"role": "assistant",
"content": "--no-pager to Git will tell it to not use a pager. Passing the option -F to less will tell it to not page if the output fits in a single screen.\nMake sure that you add --no-pager or -P before your command, as in git --no-pager log....\nUsage:\ngit --no-pager diff\n\nOther options from the comments include:\n# Set an evaporating environment variable to use 'cat' for your pager\nGIT_PAGER=cat git diff\n\n# Tells 'less' not to paginate if less than a page\nexport LESS=\"-F -X $LESS\"\n# ...then Git as usual\ngit diff\n\n# short option alternative\ngit -P diff"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git rebase --continue and --stepback?\nIs there a way to step back a commit during an interactive rebase?"
},
{
"role": "assistant",
"content": "Yes there is. How to step back during an interactive rebase:\n\nGet the commit hash of your current HEAD, for example with git rev-parse HEAD\nrun git rebase --edit-todo\ninsert a pick with that hash to the top of that file pick <hash from step 1>\nrun git reset --hard HEAD^ (this is a hard reset so if you have done anything you want to keep make sure to store it somewhere e.g. git stash before you run the command)\n\nNow you are still in the rebase but one commit back and you are free to continue rebasing with\n\ngit rebase --continue.\n\nIf you don't want the undone commit to be picked straight up without edits you can add edit <HASH> instead of pick <HASH> to the todo list (step 3).\nIdea from: http://arigrant.com/blog/2014/5/4/git-rebase-stepping-forward-and-back\nAddendum 3: If you are worried of missing a hash in the rebase, you can compare your todo file (.git/rebase-merge/git-rebase-todo) with the original one (.git/rebase-merge/git-rebase-todo.backup) as per comment from @Andrew Keeton .\nAddendum 1 and 2: You can remember more hashes, reset to an even earlier point and add multiple picks to redo more than one commit. When you edit the todo list it also contains a large comment about the different commands available:\npick 8f8b9645c1c python: remove declare_namespace\n\n# Rebase 803c25a8314..8f8b9645c1c onto 803c25a8314 (1 command)\n#\n# Commands:\n# p, pick <commit> = use commit\n# r, reword <commit> = use commit, but edit the commit message\n# e, edit <commit> = use commit, but stop for amending\n# s, squash <commit> = use commit, but meld into previous commit\n# f, fixup [-C | -c] <commit> = like \"squash\" but keep only the previous\n# commit's log message, unless -C is used, in which case\n# keep only this commit's message; -c is same as -C but\n# opens the editor\n# x, exec <command> = run command (the rest of the line) using shell\n# b, break = stop here (continue rebase later with 'git rebase --continue')\n# d, drop <commit> = remove commit\n# l, label <label> = label current HEAD with a name\n# t, reset <label> = reset HEAD to a label\n# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]\n# . create a merge commit using the original merge commit's\n# . message (or the oneline, if no original merge commit was\n# . specified); use -c <commit> to reword the commit message\n#\n# These lines can be re-ordered; they are executed from top to bottom.\n#\n# If you remove a line here THAT COMMIT WILL BE LOST.\n#\n# However, if you remove everything, the rebase will be aborted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-reflog - Manage reflog information"
},
{
"role": "assistant",
"content": "DESCRIPTION This command manages the information recorded in the reflogs. Reference logs, or \"reflogs\", record when the tips of branches and\nother references were updated in the local repository. Reflogs are\nuseful in various Git commands, to specify the old value of a\nreference. For example, HEAD@{2} means \"where HEAD used to be two\nmoves ago\", master@{one.week.ago} means \"where master used to point\nto one week ago in this local repository\", and so on. See gitrevisions for more details. The command takes various subcommands, and different options\ndepending on the subcommand: The \"show\" subcommand (which is also the default, in the absence of\nany subcommands) shows the log of the reference provided in the\ncommand-line (or HEAD , by default). The reflog covers all recent\nactions, and in addition the HEAD reflog records branch switching. git reflog show is an alias for git log -g --abbrev-commit\n--pretty=oneline ; see git-log for more information. The \"list\" subcommand lists all refs which have a corresponding reflog. The \"expire\" subcommand prunes older reflog entries. Entries older\nthan expire time, or entries older than expire-unreachable time\nand not reachable from the current tip, are removed from the reflog.\nThis is typically not used directly by end users — instead, see git-gc . The \"delete\" subcommand deletes single entries from the reflog. Its\nargument must be an exact entry (e.g. \" git reflog delete\nmaster@{2} \"). This subcommand is also typically not used directly by\nend users. The \"exists\" subcommand checks whether a ref has a reflog. It exits\nwith zero status if the reflog exists, and non-zero status if it does\nnot."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --encoding=<encoding>"
},
{
"role": "assistant",
"content": "Commit objects record the character encoding used for the log message\nin their encoding header; this option can be used to tell the\ncommand to re-code the commit log message in the encoding\npreferred by the user. For non plumbing commands this\ndefaults to UTF-8. Note that if an object claims to be encoded\nin X and we are outputting in X , we will output the object\nverbatim; this means that invalid sequences in the original\ncommit may be copied to the output. Likewise, if iconv(3) fails\nto convert the commit, we will quietly output the original\nobject verbatim."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to ignore certain files in Git\nI have a repository with a file, Hello.java. When I compile it, an additional Hello.class file is generated.\nI created an entry for Hello.class in a .gitignore file. However, the file still appears to be tracked.\nHow can I make Git ignore Hello.class?"
},
{
"role": "assistant",
"content": "The problem is that .gitignore ignores just files that weren't tracked before (by git add). Run git reset name_of_file to unstage the file and keep it. In case you want to also remove the given file from the repository (after pushing), use git rm --cached name_of_file."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to diff ansible vault changes?\nI'd like to see the actual git commit changes in the ansible vault file.\nIs there an easy way how to achieve this?"
},
{
"role": "assistant",
"content": "You can do this very neatly, so that the normal git tools like git log and git diff can see inside the vaulted files, using a custom git diff driver and .gitattributes.\n\nMake sure that your vault password is in .vault_password and that that file is not committed - you should also add it to .gitignore.\nAdd a .gitattributes file that matches any files in your repository that are encrypted with ansible-vault and give them the attribute diff=ansible-vault. For example, I have:\nenv_vars/production.yml diff=ansible-vault merge=binary\nenv_vars/staging.yml diff=ansible-vault merge=binary\n\nYou can also use wildcarded patterns - the first element of each line, the pattern, follows the same rules as .gitignore files. The merge=binary option tells git not to attempt to do a three-way merge of these files.\nThen you have to set the diff driver for files with attribute diff=ansible-vault to ansible-vault view:\ngit config --global diff.ansible-vault.textconv \"ansible-vault view\"\n\n\nAnd that should be it - when git is calculating diffs of the files your pattern matches, it'll decrypt them first."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-verify-commit"
},
{
"role": "assistant",
"content": "Check the GPG signature of commits"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --full-diff"
},
{
"role": "assistant",
"content": "Without this flag, git log -p <path>... shows commits that\ntouch the specified paths, and diffs about the same specified\npaths. With this, the full diff is shown for commits that touch\nthe specified paths; this means that \"<path>…\" limits only\ncommits, and doesn’t limit diff for those commits. Note that this affects all diff-based output types, e.g. those\nproduced by --stat , etc."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab - Project cannot be transferred, because tags are present in its container registry\n\nProject cannot be transferred, because tags are present in its container registry\n\nI am encountering the above error when I try to transfer my git repository to a group.\nI have checked in Repository/Tags but there are none. I have also checked in CI/CD tabs and there's nothing outstanding there either. So I'm wondering what tags is it referring to.\nI am currently using Netlify for my frontend hosting and Heroku for my backend hosting.\nCould either of these be applying some tags that I can't see/find?\nIs my only option to export the project?"
},
{
"role": "assistant",
"content": "Issue 33301 mentions:\n\nthe only way to move a project with containers in the registry is to first delete them all.\n\nMeaning delete the container tags in the registry (not the repository or CI/CD)\n\nNavigate to sidebar menu Package->Container Registry on a project where Container registry is enabled\nClick on the button \"Remove Tag\"\n\n(since GitLab 12.3, Sept. 2019, you can delete the tags you want)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git: list of all changed files including those in submodules\nI would like to get a list of all files, which have changed betweet two commits including those in submodules.\nI know I can do this:\ngit diff --name-only --diff-filter=ACMR ${revision} HEAD\n\nIt returns a list of files, including the submodule-path, but not the files within.\nExample:\nI've updated a submodule. I commited the super-project. Now I want to get a list of all files which have been modified.\nDo you know a way to get this done?"
},
{
"role": "assistant",
"content": "Update 2017: as I mentioned in \"see diff of commit on submodule in gitlab\", \n\nGit 2.11 (Nov. 2016) introduces\ngit diff --submodule=diff\n\nGit 2.14 (Q3 2017) will improve that by recursing into nested submodules.\nSee commit 5a52214 (04 May 2017) by Stefan Beller (stefanbeller).\n(Merged by Junio C Hamano -- gitster -- in commit a531ecf, 29 May 2017) \n\n\nOriginal 2012 answer (pre 2017 Git 2.14)\nMaybe a simple line would be enough:\ngit submodule foreach --recursive git diff --name-status\n\nThat would actually list files in submodules within submodules.\n(The --recursive option comes from git1.7.3+)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I rebase a Git branch without modifying my working copy?\nSuppose I have my \"master\" branch checked out. I've committed some production changes to \"master\", and now I want to rebase my \"experimental\" branch onto the latest master. But, I want to do this without modifying any files in my working copy. Essentially, I want all the magic to happen inside the .git directory, without touching the working copy.\nIf not for the \"don't modify my working copy\" requirement, this would just be a matter of doing:\n# current branch is master\ngit checkout experimental\ngit rebase master\ngit checkout master\n\nMy real problem is that this modifies timestamps in my working copy, even though I'm ending by checking out the exact same content I started with. As soon as I run \"git checkout experimental\", any files that contain changes in the experimental branch will get their mtime set to the current time -- and so will any files that were changed in master since the last time I rebased experimental. Because the mtimes have changed, things like build tools get the idea that there's work they need to do again, even though, by the time I'm done, the files' contents haven't actually changed. (In my case, it's that if a project file's timestamp changes, Visual Studio thinks it needs to spend a lot of time unloading and reloading the project.) I want to avoid that.\nIs there a way to do all of the above in one step, without ever modifying anything in the working copy (assuming there are no conflicts during the rebase)?\n(If there are conflicts, my preference would be to show the error and then abort the entire operation, without ever modifying any timestamps. But that's just my preference, not a hard requirement -- I don't know what all is possible.)\nOf course I can write a script to capture the mtimes, run git, and then reset the mtimes; but it seems likely that Git would already have a way to do things like rebase without bothering the working copy, since the rebase is really about the deltas, not the files' actual contents."
},
{
"role": "assistant",
"content": "Since git 2.5, an even better solution is to use a second worktree. \n\nA git repository can support multiple working trees, allowing you to check out more than one branch at a time.\n\n$ git worktree add ../second-copy experimental\n$ cd ../second-copy/\n$ git rebase master experimental\n\nAnd that's it. Afterwards, you can rm -rf second-copy if you want, or keep it for more rebases in the future.\n$ git rebase master experimental"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to locate the git config file in Mac [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nWhere do the settings in my Git configuration come from?\n\n (10 answers)\n \n\nClosed 8 years ago.\n\n\n\nAs title reads, how to locate the git config file in Mac? Not sure how to find it. Need to set \ngit config --global http.postBuffer 524288000\n\nNeed some guidance on finding it.."
},
{
"role": "assistant",
"content": "You don't need to find the file.\nOnly write this instruction on terminal:\ngit config --global --edit"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options core.excludesFile"
},
{
"role": "assistant",
"content": "Specifies the pathname to the file that contains patterns to\ndescribe paths that are not meant to be tracked, in addition\nto .gitignore (per-directory) and .git/info/exclude .\nDefaults to $XDG_CONFIG_HOME/git/ignore .\nIf $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead. See gitignore ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -a --text"
},
{
"role": "assistant",
"content": "Treat all files as text."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs combined, c"
},
{
"role": "assistant",
"content": "Show differences from each of the parents to the merge\nresult simultaneously instead of showing pairwise diff between\na parent and the result one at a time. Furthermore, it lists\nonly files which were modified from all parents."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Are merges in Git symmetric?\nLets say we have two branches (B and C) that have diverged from a common ancestor A. Will merging from B to C produce the same result as merging from C to B?\n A\n |\n / \\\nB C\n\nTo clarify- I'm assuming that any manual merge conflict resolutions will occur in both directions. But will any automatic merges that occur result in the same code being chosen? This is what I'm assuming, since the commit dates are identical in both directions.\nTo further clarify - I know that the actual merging results in \"mirror images\" of each other based on the direction. I'm just asking about the automatically resolved conflicts."
},
{
"role": "assistant",
"content": "The answer is yes for default merges. A three-way merge finds a common ancestor and then applies the differences from both sides, an operation that isn't order dependent. The topic of merge-ordering and commutativity generated a fascinating discussion on the git list (if you're into that kind of thing, that is). Note B into C and C into B should be symmetric, but the same cannot necessarily be said for (B into C) into A versus B into (C into A).\n[Editing note, April 2020: If you add options like -X ours or -X theirs, the answer becomes \"no\", and see twalberg's answer and the others for additional caveats.]\n\nTo elaborate a bit more, based on Vince's comment below and seh's comment on the question, there will be two noticeable differences between B into C and C into B, neither of which affect the automatic merge resolution referenced in the question.\nFirst, history will be different. The merge commit's parents will change depending on the merge order. For these examples, I'm going to use \"first_branch\" and \"second_branch\", so I can reserve letters to represent commits.\ngit checkout first_branch && git merge second_branch\n\nE <- merge commit\n|\\\n| D <- second_branch's tip\n| |\n| C <- another commit on second_branch \n| |\n| B <- and another\n|/\nA <- first_branch's tip before the merge\n\nIn this case, the \"first parent\" of E, E^1, is first_branch's tip before the merge. second_branch is the \"second parent\" of the merge commit, aka E^2. Now consider the reverse:\ngit checkout second_branch && git merge first_branch\n\nE <- merge commit\n|\\\n| D <- first_branch's tip\n| |\n| C <- another commit on first_branch \n| |\n| B <- and another\n|/\nA <- second_branch's tip before the merge\n\nThe parents are reversed. E^1 is the tip of second_branch before the merge. E^2 is the tip of first_branch.\nSecond, the display order of conflicts will reverse. In the first case, a conflict might look like this:\n<<<<<<< HEAD\nThis line was added from the first_branch branch.\n=======\nThis line was added from the second_branch branch.\n>>>>>>> second_branch\n\nIn the second case, the same conflict would look like this:\n<<<<<<< HEAD\nThis line was added from the second_branch branch.\n=======\nThis line was added from the first_branch branch.\n>>>>>>> first_branch\n\nNeither of these differences affect automatic merge resolution, but they do appear when you reverse three-way merge order."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker -P --no-pager"
},
{
"role": "assistant",
"content": "Do not pipe Git output into a pager."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Saving ssh key fails\n\ni just started a Git tutorial and I get to a deadend: I try to generate a rsa key part and it fails.\nI did this, in git bash:\nssh-keygen -t rsa -C \"[email protected]\"\n\nAnd i got this:\nGenerating public/private rsa key pair.\nEnter file in which to save the key (/c/Users/Eva/.ssh/id_rsa):\nenter passphrase:\nenter same passphrase again:\nopen /c/Users/Eva/.ssh/id_rsa failed: no such file or directory.\nSaving the key failed:/c/Users/Eva/.ssh/id_rsa.\n\nI tried to save in a different folder and it went OK. but now i do the command ssh -T [email protected] and it gives me the error permisson denied (publickey)."
},
{
"role": "assistant",
"content": "If you're using Windows, the unix-style default path of ssh-keygen is at fault.\nIn Line 2 it says Enter file in which to save the key (/c/Users/Eva/.ssh/id_rsa):.\nThat full filename in the parantheses is the default, obviously Windows cannot access a file like that. If you type the Windows equivalent (c:\\Users\\Eva\\.ssh\\id_rsa), it should work.\nBefore running this, you also need to create the folder. You can do this by running mkdir c:\\Users\\Eva\\.ssh, or by created the folder \".ssh.\" from File Explorer (note the second dot at the end, which will get removed automatically, and is required to create a folder that has a dot at the beginning).\nc:\\Users\\Administrator\\.ssh>ssh-keygen -t rsa -C \"[email protected]\"\nGenerating public/private rsa key pair.\nEnter file in which to save the key (/home/Administrator/.ssh/id_rsa): C:\\Users\\Administrator\\.ssh\\id_rsa\nEnter passphrase (empty for no passphrase):\nEnter same passphrase again:\nYour identification has been saved in C:\\Users\\Administrator\\.ssh\\id_rsa.\nYour public key has been saved in C:\\Users\\Administrator\\.ssh\\id_rsa.pub.\nThe key fingerprint is:\n... [email protected]\nThe key's randomart image is:...`\n\nI know this is an old thread, but I thought the answer might help others."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-worktree - Manage multiple working trees -z"
},
{
"role": "assistant",
"content": "Terminate each line with a NUL rather than a newline when --porcelain is specified with list . This makes it possible\nto parse the output when a worktree path contains a newline\ncharacter."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-tree - List the contents of a tree object --object-only"
},
{
"role": "assistant",
"content": "List only names of the objects, one per line. Cannot be combined\nwith --name-only or --name-status .\nThis is equivalent to specifying --format='%(objectname)' , but\nfor both this option and that exact format the command takes a\nhand-optimized codepath instead of going through the generic\nformatting mechanism."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Pull vs Git Rebase\nI'm a noob in Git, and trying to learn the difference between git pull vs git rebase. Can someone provide an example when to use which option since I feel that both serve the same purpose."
},
{
"role": "assistant",
"content": "git pull and git rebase are not interchangeable, but they are closely connected.\ngit pull fetches the latest changes of the current branch from a remote and applies those changes to your local copy of the branch. Generally this is done by merging, i.e. the local changes are merged into the remote changes. So git pull is similar to git fetch & git merge.\nRebasing is an alternative to merging. Instead of creating a new commit that combines the two branches, it moves the commits of one of the branches on top of the other. \nYou can pull using rebase instead of merge (git pull --rebase). The local changes you made will be rebased on top of the remote changes, instead of being merged with the remote changes.\nAtlassian has some excellent documentation on merging vs. rebasing."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Do collaborators have commit access on GitHub?\n\nOne thing I noticed: Using the GitHub UI, I added a collaborator to a repository. I saw that they committed changes without any authority / approval from me. It was a private repository.\nWith private repositories, how do I give someone read access versus write access?"
},
{
"role": "assistant",
"content": "With private repositories, how do I give someone read access versus write access?\n\nThis kind of permission is not available for simple accounts. When you add an user as a collaborator, he gains read/write permissions.\nThe story changes if you own an Organization. Organizations contains teams and each team can have different level of access, including read-only.\nYou can assign users to a specific read-only group, and they will only have pull access to the repositories."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %t"
},
{
"role": "assistant",
"content": "abbreviated tree hash"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-filter-branch - Rewrite branches --state-branch <branch>"
},
{
"role": "assistant",
"content": "This option will cause the mapping from old to new objects to\nbe loaded from named branch upon startup and saved as a new\ncommit to that branch upon exit, enabling incremental of large\ntrees. If <branch> does not exist it will be created."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitlab-ci.yml only on master branch\n\nI have a gitlab-ci.yml file like this, and want to run it only on Branch Master. If there is a push into develop branch the Pipeline should NOT start.\nI tried with 'only' keyword, but it shows an Error.\nstages:\n - info\n - build\n - test\n - review\n - cleanup\n - deploy-dev\n - integration-test\n - deploy-test\n - system-test\n - deploy-production\n\nonly:\n refs:\n - master"
},
{
"role": "assistant",
"content": "To define a trigger rule for every stage you can use the workflow keyword, like this:\n workflow:\n rules:\n - if: $CI_COMMIT_TAG\n when: never\n - if: $CI_COMMIT_BRANCH == 'master'\n\nThis has to be on the \"root\" of your yaml, as it is not part of any job in particular.\nIn the example above, I am telling the pipeline to avoid running when a repository tag is pushed and to run only when a commit is done in the master branch.\nYou can use this as a base and add other conditions to trigger the stages in the pipeline, the complete documentation on this matters can be found here: https://docs.gitlab.com/ee/ci/yaml/#workflow"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-tag - Create, list, delete or verify a tag object signed with GPG"
},
{
"role": "assistant",
"content": "DESCRIPTION Add a tag reference in refs/tags/ , unless -d/-l/-v is given\nto delete, list or verify tags. Unless -f is given, the named tag must not yet exist. If one of -a , -s , or -u <key-id> is passed, the command\ncreates a tag object, and requires a tag message. Unless -m <msg> or -F <file> is given, an editor is started for the user to type\nin the tag message. If -m <msg> or -F <file> is given and -a , -s , and -u <key-id> are absent, -a is implied. Otherwise, a tag reference that points directly at the given object\n(i.e., a lightweight tag) is created. A GnuPG signed tag object will be created when -s or -u\n<key-id> is used. When -u <key-id> is not used, the\ncommitter identity for the current user is used to find the\nGnuPG key for signing. \tThe configuration variable gpg.program is used to specify custom GnuPG binary. Tag objects (created with -a , -s , or -u ) are called \"annotated\"\ntags; they contain a creation date, the tagger name and e-mail, a\ntagging message, and an optional GnuPG signature. Whereas a\n\"lightweight\" tag is simply a name for an object (usually a commit\nobject). Annotated tags are meant for release while lightweight tags are meant\nfor private or temporary object labels. For this reason, some git\ncommands for naming objects (like git describe ) will ignore\nlightweight tags by default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --no-ext-diff"
},
{
"role": "assistant",
"content": "Disallow external diff drivers."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "More than one value for the key user.name Git\n\nFor some reason I'm getting the error that \"More than one value for the key user.name\" when I try to set the user.name for my git account. How can I set it to a single name?"
},
{
"role": "assistant",
"content": "If you just want to reset all of them:\ngit config --global --replace-all user.email \"[email protected]\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files git checkout [<branch>]"
},
{
"role": "assistant",
"content": "To prepare for working on <branch> , switch to it by updating\nthe index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the\nworking tree are kept, so that they can be committed to the <branch> . If <branch> is not found but there does exist a tracking branch in\nexactly one remote (call it <remote> ) with a matching name and --no-guess is not specified, treat as equivalent to $ git checkout -b <branch> --track <remote>/<branch> You could omit <branch> , in which case the command degenerates to\n\"check out the current branch\", which is a glorified no-op with\nrather expensive side-effects to show only the tracking information,\nif it exists, for the current branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitworkflows - An overview of recommended workflows with Git"
},
{
"role": "assistant",
"content": "SYNOPSIS git *"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects push.useForceIfIncludes"
},
{
"role": "assistant",
"content": "If set to \"true\", it is equivalent to specifying --force-if-includes as an option to git-push in the command line. Adding --no-force-if-includes at the\ntime of push overrides this configuration setting."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-notes - Add or inspect object notes -s <strategy> --strategy=<strategy>"
},
{
"role": "assistant",
"content": "When merging notes, resolve notes conflicts using the given\nstrategy. The following strategies are recognized: \"manual\"\n(default), \"ours\", \"theirs\", \"union\" and \"cat_sort_uniq\".\nThis option overrides the \"notes.mergeStrategy\" configuration setting.\nSee the \"NOTES MERGE STRATEGIES\" section below for more\ninformation on each notes merge strategy."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Do I need Git to use Github in JetBrains IntelliJ IDEA?\nJetBrains IntelliJ IDEA has 2 plugins: Git and Github. Do I need to install Git from http://git-scm.com on my local windows machine in order to upload my files to GitHub through IntelliJ IDEA?"
},
{
"role": "assistant",
"content": "I just came up against the same problem.\nIf you choose not to do the full PATH (environment variable) integration when install git (on Windows) you'll need to tell IntelliJ where to find git.cmd; you can do this in\nSettings > Project Settings > Version Control > VCSs > Git\n\nExample in my case it was portable git looks like this on windows\n\nC:\\Users\\user\\AppData\\Local\\GitHub\\PortableGit_d7effa1a4a322478cd29c826b52a0c118ad3db11\\cmd\\git.exe"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch renormalize"
},
{
"role": "assistant",
"content": "This runs a virtual check-out and check-in of all three stages\nof a file when resolving a three-way merge. This option is\nmeant to be used when merging branches with different clean\nfilters or end-of-line normalization rules. See \"Merging\nbranches with differing checkin/checkout attributes\" in gitattributes for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options extensions.refStorage"
},
{
"role": "assistant",
"content": "Specify the ref storage format to use. The acceptable values are: files for loose files with packed-refs. This is the default. reftable for the reftable format. This format is experimental and its\ninternals are subject to change. It is an error to specify this key unless core.repositoryFormatVersion is 1. +\nNote that this setting should only be set by git-init or git-clone . Trying to change it after initialization will not\nwork and will produce hard-to-diagnose issues."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to disable git gpg signing\nI'm using git gpg signing. I want to disable it. I've set .gitconfig\n[user]\n name = NAME\n email = EMAIL\n signingkey = KEY\n...\n[commit]\n gpgsign = false\n\nMy commits are still signing by default. \nPS: I also disabled from Sourcetree Repository/ Repository Settings/Security tab. Both Sourcetree and terminal forces to use gpg."
},
{
"role": "assistant",
"content": "You can disable this by running git config commit.gpgsign false This sets the configuration locally instead of globally.\nPutting this setting in .gitconfig worked for me with what you had, without the [user] configuration:\n[commit]\n gpgsign = false"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What's the difference between `git add .` and `git add -u`?\nI was assuming that both work in the same way. Both add every file onto index. But I seem wrong.\n\nWhat's the difference between git add . and git add -u?"
},
{
"role": "assistant",
"content": "It is one of the git gotchas mentioned here (pre Git 2.0).\ngit add . only adds what is there, not what has been deleted (if tracked).\ngit add .\ngit commit\ngit status\n//hey! why didn't it commit my deletes?, Oh yeah, silly me\ngit add -u .\ngit commit --amend\n\ngit add -A would take care of both steps...\n\nWith Git 2.0, git add -A is default. \n\ngit add <path> is the same as \"git add -A <path>\" now, so that\n \"git add dir/\" will notice paths you removed from the directory and\n record the removal.\n In older versions of Git, \"git add <path>\" used to ignore removals. \nYou can say \"git add --ignore-removal <path>\" to\n add only added or modified paths in <path>, if you really want to.\n\n\nWarning (git1.8.3 April 2013, for upcoming git2.0).\nI have modified my answer to say git add -u ., instead of git add -u.:\n\ngit add -u will operate on the entire tree in Git 2.0 for consistency with \"git commit -a\" and other commands.\n Because there will be no mechanism to make \"git add -u\" behave as \"git add -u .\", it is\n important for those who are used to \"git add -u\" (without pathspec) updating the index only for paths in the current subdirectory to start training their fingers to explicitly say \"git add -u .\" when they mean it before Git 2.0 comes.\n\nAs I mentioned in \"e\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is git doing when it says it is \"resolving deltas\"?\nDuring the first clone of a repository, git first receives the objects, and then spends about the same amount of time \"resolving deltas\". What's actually happening during this phase of the clone?"
},
{
"role": "assistant",
"content": "The stages of git clone are:\n\nReceive a \"pack\" file of all the objects in the repo database\nCreate an index file for the received pack\nCheck out the head revision (for a non-bare repo, obviously)\n\n\"Resolving deltas\" is the message shown for the second stage, indexing the pack file (\"git index-pack\").\nPack files do not have the actual object IDs in them, only the object content. So to determine what the object IDs are, git has to do a decompress+SHA1 of each object in the pack to produce the object ID, which is then written into the index file.\nAn object in a pack file may be stored as a delta i.e. a sequence of changes to make to some other object. In this case, git needs to retrieve the base object, apply the commands and SHA1 the result. The base object itself might have to be derived by applying a sequence of delta commands. (Even though in the case of a clone, the base object will have been encountered already, there is a limit to how many manufactured objects are cached in memory).\nIn summary, the \"resolving deltas\" stage involves decompressing and checksumming the entire repo database, which not surprisingly takes quite a long time. Presumably decompressing and calculating SHA1s actually takes more time than applying the delta commands.\nIn the case of a subsequent fetch, the received pack file may contain references (as delta object bases) to other objects that the receiving git is expected to already have. In this case, the receiving git actually rewrites the received pack file to include any such referenced objects, so that any stored pack file is self-sufficient. This might be where the message \"resolving deltas\" originated."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository ="
},
{
"role": "assistant",
"content": "for a ref that was up to date and did not need fetching."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Given a commit id, how to determine if current branch contains the commit?\nWhat I'm trying to do is a version check. I want to ensure the code stays on top of a minimum version. So I need a way to know if the current branch contains a specified commit."
},
{
"role": "assistant",
"content": "Naïve method\nThere are multiple ways to achieve this result. First naive option is to use git log and search for a specific commit using grep, but that is not always precise\ngit log | grep <commit_id>\n\nThis could result in false positives if git log mentions the commit SHA for other reasons, e.g. it's mentioned in a commit message as the result of a port from another branch.\nInteractive Solution\nYou are better off to use git branch directly to find all branches containing given COMMIT_ID using\ngit branch --contains $COMMIT_ID\n\nScriptable Solution\nThe next step is finding out current branch which can be done since git 1.8.1 using\ngit symbolic-ref --short HEAD\n\nAnd combined together as\ngit branch $(git symbolic-ref --short HEAD) --contains $COMMIT_ID\n\nEven Better Scriptable Solution\nBut the command above doesn't return true or false and there is a shorter version that returns exit code 0 if commit is in current branch OR exit code 1 if not\ngit merge-base --is-ancestor $COMMIT_ID HEAD\n\nExit code is nice, but as you want string true or false as answer you need to add a bit more and then combined with if from bash you get\nif [ 0 -eq $(git merge-base --is-ancestor $COMMIT_ID HEAD) ]; then echo \"true\"; else echo \"false\"; fi"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "VSCode: difference \"create branch\" and \"create branch from\"\nWhen trying to create a new branch, from an existing one, I'm faced with these two options: \n\n+ Create branch...\n+ Create branch from...\n\nI don't really understand the difference between these two options."
},
{
"role": "assistant",
"content": "Both commands are used to create new branches and switch to the branch after successfully created. But \n\n+ Create branch... will create a new branch from the current branch you are working on.\n+ Create branch from... will create a new branch from some other branch in the git repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options diff.dirstat"
},
{
"role": "assistant",
"content": "A comma separated list of --dirstat parameters specifying the\ndefault behavior of the --dirstat option to git-diff and friends. The defaults can be overridden on the command line\n(using --dirstat=<param1,param2,...> ). The fallback defaults\n(when not changed by diff.dirstat ) are changes,noncumulative,3 .\nThe following parameters are available: changes Compute the dirstat numbers by counting the lines that have been\nremoved from the source, or added to the destination. This ignores\nthe amount of pure code movements within a file. In other words,\nrearranging lines in a file is not counted as much as other changes.\nThis is the default behavior when no parameter is given. lines Compute the dirstat numbers by doing the regular line-based diff\nanalysis, and summing the removed/added line counts. (For binary\nfiles, count 64-byte chunks instead, since binary files have no\nnatural concept of lines). This is a more expensive --dirstat behavior than the changes behavior, but it does count rearranged\nlines within a file as much as other changes. The resulting output\nis consistent with what you get from the other --*stat options. files Compute the dirstat numbers by counting the number of files changed.\nEach changed file counts equally in the dirstat analysis. This is\nthe computationally cheapest --dirstat behavior, since it does\nnot have to look at the file contents at all. cumulative Count changes in a child directory for the parent directory as well.\nNote that when using cumulative , the sum of the percentages\nreported may exceed 100%. The default (non-cumulative) behavior can\nbe specified with the noncumulative parameter. <limit> An integer parameter specifies a cut-off percent (3% by default).\nDirectories contributing less than this percentage of the changes\nare not shown in the output. Example: The following will count changed files, while ignoring\ndirectories with less than 10% of the total amount of changed files,\nand accumulating child directory counts in the parent directories: files,10,cumulative ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to view stash date/timestamp next to stash id?\nUsing git stash list shows me the list of stashes with their IDs. Using git stash list --date=local or git stash list --date=relative gives me their times, but I have no idea what their corresponding ID is.\nI want to acquire a stash at a certain time."
},
{
"role": "assistant",
"content": "git stash list simply runs git log with a particular set of options:\nlist_stash () {\n have_stash || return 0\n git log --format=\"%gd: %gs\" -g --first-parent -m \"$@\" $ref_stash --\n}\n\nThe $@ part inserts whatever additional options you've specified (none by default, but --date=relative in this case).1\nWhen you use --date=relative this modifies the output from %gd: instead of a short reflog with an index, you get a short reflog with a relative time stamp:\n$ git stash list\nstash@{0}: ...\n$ git stash list --date=relative\nstash@{4 minutes ago}: ...\n\nThe solution in this case is to use your own explicit format, rather than just letting --date=relative modify how %gd gets displayed. For instance:\n$ git stash list --format='%gd (%cr): %gs'\nstash@{0} (4 minutes ago): ...\n\n(%cr inserts the commit's committer time stamp, in relative format—this makes sense once you know that all git stash does is make a couple of commits for you, with the commits being stored on the special stash ref instead of on a branch).\n\n1On reviewing this answer, I note that the --first-parent and -m arguments (literally present in the git stash code) seem redundant at first, because of the -g argument. The -g argument to git log tells it to look only at the reflog, rather than the commit history, in which case, --first-parent means nothing. Meanwhile -m tells git diff to split a merge commit, but we're looking at commit logs, not diffs, so what is this doing here?\nThe answer is that git log can show a patch, for which it runs git diff, so if you give -p as an argument, the --first-parent -m limits this diff to comparing the commit to which the stash reflog points against its first parent. The stash bag commit to which the reflog entry points is the work-tree commit, whose first parent is the original commit on which the stash-bag hangs. (Its second parent is the index commit and its third parent, if present, is the all or untracked files commit.) So these options are there to make git stash list -p diff the stash's work-tree commit against the commit that was current when the stash itself was made.\nThis is clever, but quite obscure! :-)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to merge two GitHub accounts\nI have two GitHub accounts, one of this was created a long time ago at my work and has an username that refers to the company where I work.\nI have another account which is my personal GitHub account that I can't stop using. \nCould I merge the two accounts so I can work in only one of these?"
},
{
"role": "assistant",
"content": "Merging 2 accounts is not possible at github, you can transfer ownership to your personal account.\ngoto >> Setting >>Transfer ownership \n\nFor more details : https://help.github.com/articles/merging-multiple-user-accounts/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "This compilation unit is not on the build path of a Java project\nWhen I try to use ctrl+space this error is shown: \nThis compilation unit is not on the build path of a Java project.\n\nI see that there are similar topics but my work environment is Eclipse and i pull my project from Git (I import project as general project) and i use Apache Ant. Can anyone help me?"
},
{
"role": "assistant",
"content": "Since you imported the project as a General Project, it does not have the java nature and that is the problem.\nAdd the below lines in the .project file of your workspace and refresh.\n<natures>\n <nature>org.eclipse.jdt.core.javanature</nature>\n</natures>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects --patch-with-stat"
},
{
"role": "assistant",
"content": "Synonym for -p --stat ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %aN"
},
{
"role": "assistant",
"content": "author name (respecting .mailmap, see git-shortlog or git-blame )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_TRACE_REDACT"
},
{
"role": "assistant",
"content": "By default, when tracing is activated, Git redacts the values of\ncookies, the \"Authorization:\" header, the \"Proxy-Authorization:\"\nheader and packfile URIs. Set this Boolean environment variable to false to prevent this\nredaction."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I search Git branches for a file or directory?\nIn Git, how could I search for a file or directory by path across a number of branches?\nI've written something in a branch, but I don't remember which one. Now I need to find it.\nClarification: I'm looking for a file which I created on one of my branches. I'd like to find it by path, and not by its contents, as I don't remember what the contents are."
},
{
"role": "assistant",
"content": "git log + git branch will find it for you:\n% git log --all -- somefile\n\ncommit 55d2069a092e07c56a6b4d321509ba7620664c63\nAuthor: Dustin Sallings <[email protected]>\nDate: Tue Dec 16 14:16:22 2008 -0800\n\n added somefile\n\n\n% git branch -a --contains 55d2069\n otherbranch\n\nSupports globbing, too:\n% git log --all -- '**/my_file.png'\n\nThe single quotes are necessary (at least if using the Bash shell) so the shell passes the glob pattern to git unchanged, instead of expanding it (just like with Unix find)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443\nSince a few days I got an issue with Mac OS High Sierra 10.13.3 :\nWhen I run a git clone like git clone github.com/xxx.git failed\nit print:\n\nLibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443\n\nSame issue with npm i command\nEven when I try to install brew like so:\n/usr/bin/ruby -e \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)\"\n\nI also tried the alternative setup: same."
},
{
"role": "assistant",
"content": "I had this similar error when using wget ..., and after much unfruitful searching in the Internet, I discovered that it was happening when hostnames were being resolved to IPv6 addresses. I discovered this by comparing the outputs of wget ... in two machines, one was resolving to IPv4 and it worked there, the other was resolving to IPv6 and it failed there.\nSo the solution in my case was to run networksetup -setv6off Wi-Fi on macOS High Sierra 10.13.6. (I discovered this command in this page).\nHope this helps you."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %gn"
},
{
"role": "assistant",
"content": "reflog identity name"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remote Git branches not visible\nAfter git pull I've always been able to see all branches by doing a git branch.\nRight now (for some reason) running git branch shows me master and one other branch, that I am actively working on,.\ngit remote show origin shows me all branches. If I do a git checkout on one of them, it pulls the branch down locally and swaps to it. After that it's visible when I run git branch\nQuestion\nHow do I get the remote branches to display again when I run git branch?\nNote: This is only a visual problem - I can still access my remote branches without problems, I'm just wondering why they're not showing up when I do a git branch as they usually do"
},
{
"role": "assistant",
"content": "TL;DR: just use git branch -r or git branch -a (after git fetch to update). It's not at all clear why you've been seeing remote-tracking branches without these flags (perhaps you have been using a GUI that shows them automatically?).\nYou do, however, have at least one small misconception built in to your question—which is not surprising; this particular part of Git is tricky at first.\n\nThere are, in fact, three sets of branch names involved in this question.\n\ngit remote show origin shows me all branches.\n\nNot exactly. Let's back up a bit, and define two sets (or classes, or whatever word you like to group them) of branches. Git provides:\n\nYour regular, ordinary, local branches. These are what git branch shows, when used with no arguments and flags.\n$ git branch\n diff-merge-base\n* master\n precious\n stash-exp\n\nThe word \"branch\" often means one of these: a name that, when fed to git rev-parse, resolves to a commit ID:\n$ git rev-parse diff-merge-base\n2d0cc5001c1a88995727521d4ef77f7a4acc4e14\n\nand whose full name starts with refs/heads/:\n$ git rev-parse --symbolic-full-name diff-merge-base\nrefs/heads/diff-merge-base\n\nYour remote-tracking branches. These are what git branch -r shows:\n$ git branch -r\n origin/HEAD -> origin/master\n origin/maint\n origin/master\n origin/next\n origin/pu\n origin/todo\n\n\nThe key difference between these is that your local branches are your names to manipulate however you like, while your remote-tracking branches are your names that Git automatically slaves to something else. It is possible for you to manipulate them yourself, but it's not profitable, as their intent is to remember some other Git's branch names (and corresponding SHA-1 values).\nNote that feeding a remote-tracking branch name to git rev-parse also works, and you can get its symbolic-full-name as well: this simply begins with refs/remotes/, followed by the name of the remote, followed by the local name as seen if you're the Git running on the remote. Hence:\n$ git rev-parse --symbolic-full-name origin/master\nrefs/remotes/origin/master\n\nmeans that my Git's origin/master is my Git's memory of what master meant, on origin, the last time had my Git call up origin and fetch—i.e., update—from them.\ngit remote (sometimes) actually calls up the remote Git\nRemember that there are two (or sometimes even more) Git version-control databases involved any time you fetch or push commits. So you can look at your information, or you can ask your Git to call up their Git, over the Internet-phone, and query them about their information. They, too, may have local branches, and even remote-tracking branches, of their own. (Usually, for situations like this, they have only local branches.)\nFor illustration purposes, let me delete one of my own remote-tracking branches (this is pretty harmless since I will run git fetch in a moment to restore it):\n$ git branch -r -d origin/pu\nDeleted remote-tracking branch origin/pu (was 7c79844).\n\nNow if I run git branch -r I will no longer have an origin/pu: my Git no longer has that as a remote-tracking branch. But their Git, over on origin, still has a local branch named pu, so:\n$ git remote show origin\n* remote origin\n Fetch URL: git://git.kernel.org/pub/scm/git/git.git\n Push URL: git://git.kernel.org/pub/scm/git/git.git\n HEAD branch: master\n Remote branches:\n maint tracked\n master tracked\n next tracked\n pu new (next fetch will store in remotes/origin)\n todo tracked\n Local branches configured for 'git pull':\n master merges with remote master\n stash-exp merges with remote master\n Local ref configured for 'git push':\n master pushes to master (local out of date)\n\nWhen I run git remote show origin, my Git calls up their Git (this happens to be a copy of the Git repository for Git—there's another one on github.com that is probably more appropriate these days) and gets from them a list of all their branches. I already have most of them as my own \"remote-tracking branches\", but I deleted pu, so it shows as \"new\".\nA similar command, git ls-remote, also calls up the other Git and queries it, but shows you more: it shows you the commit hash that goes with each branch (and the object hash for each tag as well). There are a lot of tags, so let me restrict this to just one branch:\n$ git ls-remote origin master\ne05806da9ec4aff8adfed142ab2a2b3b02e33c8c refs/heads/master\n\nIn both these cases, your Git (or my Git) calls up their Git and gets information from them, but it merely displays it, rather than saving it. To save the information, we must run git fetch. I have not run this in a little while, so:\n$ git fetch origin\nremote: Counting objects: 2064, done.\nremote: Compressing objects: 100% (1294/1294), done.\nremote: Total 2064 (delta 1383), reused 1118 (delta 767)\nReceiving objects: 100% (2064/2064), 2.12 MiB | 2.29 MiB/s, done.\nResolving deltas: 100% (1383/1383), done.\nFrom git://git.kernel.org/pub/scm/git/git\n de2efeb..e05806d master -> origin/master\n 3074f94..c69c2f5 next -> origin/next\n * [new branch] pu -> origin/pu\n 1a46792..2135c1c todo -> origin/todo\n\nThis git fetch did the same thing as git remote show and git ls-remote, but then also did more things: it collected the objects I need to complete my repository, then updated my remote-tracking branch names to correspond to the branch names in their repository.\nThis is why I regained origin/pu: they still have a pu, and I discarded mine, so I obtained theirs and now have one again.\nThis is also why I updated all the others except maint: it's been long enough that they have all been updated. My origin/master used to refer to commit de2efeb, but now it refers to e05806d, which is the same ID we saw above when we ran git ls-remote. (This means they did not update their master in the several minutes it took me to type all this in. Imagine that, billions of nanoseconds have gone by without an update! :-) )\n(Note that git remote show -n origin skips the phoning-up of origin, and simply shows you what your Git has recorded. Several other git remote commands also work locally; consult the documentation for specifics.)\nSummary\nTo recap, then, there are three sets of branch names involved here:\n\nYour local branches;\nYour remote-tracking branches; and\nTheir branches (in the remote Git).\n\nThe last set of branch names don't matter, most of the time. Most of the time, you work in your own repository. There's only one Git involved, and it's yours. Their Git, which has its own branches, is right out of the picture.\nBut sometimes—ah, such times!—sometimes, you must connect your Git to another Git. Now their names matter! The really tricky thing here is that your names don't have to match their names at all. There's no hard and fast reason your master must correspond to their master—but your Git will copy their master to your origin/master, so it saves a lot of brain cells if your names and their names do match up. You can work around this (in multiple different ways), but don't do it until you have a situation that really calls for it (with multiple remotes that use conflicting branch names—this almost never happens).\nWhat about git checkout blah?\nYou noted above that:\n\nIf I do a git checkout on one of [their branch names that I don't see in git branch output], it pulls the branch down locally and swaps to it.\n\nLet's say that you have run git branch -r (rather than git remote show origin) and seen a branch named origin/zorg. Let's also say you don't already have a (local) branch named zorg. You run:\n$ git checkout zorg\n\nand your Git says:\nBranch zorg set up to track remote branch zorg from origin.\nSwitched to a new branch 'zorg'\n\nYour Git hasn't \"pulled down\" anything here. What it's done is to create a new local branch name, zorg, pointing to the same commit—the same big ugly SHA-1 hash ID—as origin/zorg. That commit was already in your repository, ready to be checked out any time, and in fact you could have done:\n$ git checkout origin/zorg\n\nto look at it—but that would give you what Git calls a \"detached HEAD\".\nWhat's going on here is that in Git, a branch name is merely a moveable pointer to one specific commit. The git checkout command, when used this way, does two things: check out the one specific commit (into the work-tree), and, switch your Git's notion of the \"current branch name\". When you git checkout an existing, local, ordinary branch name, Git checks out the one commit in question, and puts you \"on the branch\", as git status will say:\n$ git status\nOn branch master\n\nWhen you git checkout any commit by something that's not a simple branch name, Git still checks out the one commit, but takes you off of any branch, i.e., gives you a \"detached HEAD\".\nWe know from the above that origin/master is (now) commit e05806da9ec4aff8adfed142ab2a2b3b02e33c8c, so:\n$ git checkout origin/master\n\nor:\n$ git checkout e05806da9ec4aff8adfed142ab2a2b3b02e33c8c\n\nboth do the same thing. Since origin/master is not a local branch, I end up with:\n$ git status\nHEAD detached at e05806d\n\n(or sometimes HEAD detached at origin/master).\nHence, what git checkout does is attempt to convert the name you gave it to a branch name. If that fails, git checkout has this extra built-in feature: it searches through all your remote-tracking branches to see if there's exactly one that \"mostly matches\" the name. So git checkout zorg checks for a local branch named zorg, fails to find it, then searches all your remote-tracking branches for one that also matches zorg. There is in fact exactly one—origin/zorg—so this triggers the special case code.\nThe special case code simply implements \"create new local branch set up to track corresponding remote-tracking branch\". That is, create a local zorg, with its upstream (as Git now calls these things) set to origin/zorg.\nNote that for this to work, there must be exactly one suitable remote-tracking branch. If I did not have origin/zorg at all, this would fail—and if I had both origin/zorg and thirdrepo/zorg, where thirdrepo is another remote, like origin but pointing to some third Git repository, it would also fail, because Git would not know whether my local zorg should have origin/zorg or thirdrepo/zorg as its upstream.\nMost of the time, you have only one remote, named origin. So, as long as you have all of origin's branches saved as your own Git's remote-tracking branch memories, you can just git checkout those names to get your Git to create them. But sometimes you will find that you must run git fetch first, so as to update your remote-tracking branches."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.