messages listlengths 3 3 |
|---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --no-color-moved-ws"
},
{
"role": "assistant",
"content": "Do not ignore whitespace when performing move detection. This can be\nused to override configuration settings. It is the same as --color-moved-ws=no ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-branch - List, create, or delete branches branch.<name>.merge"
},
{
"role": "assistant",
"content": "Defines, together with branch.<name>.remote, the upstream branch\nfor the given branch. It tells git fetch / git pull / git rebase which\nbranch to merge and can also affect git push (see push.default).\nWhen in branch <name>, it tells git fetch the default\nrefspec to be marked for merging in FETCH_HEAD. The value is\nhandled like the remote part of a refspec, and must match a\nref which is fetched from the remote given by\n\"branch.<name>.remote\".\nThe merge information is used by git pull (which first calls git fetch ) to lookup the default branch for merging. Without\nthis option, git pull defaults to merge the first refspec fetched.\nSpecify multiple values to get an octopus merge.\nIf you wish to setup git pull so that it merges into <name> from\nanother branch in the local repository, you can point\nbranch.<name>.merge to the desired branch, and use the relative path\nsetting . (a period) for branch.<name>.remote."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Cannot enable forking on github repo\n\nI have a private repo. I noticed I cannot fork it. I cannot find any information that says I shouldn't be able to. When I go to Options the ability to fix this is disabled. I am guessing you need to pay or something which is fine, but it doesn't say that anywhere...\n\nCannot click!"
},
{
"role": "assistant",
"content": "I think you are talking about your organisation's private repo, right? As I didn't find this checkbox for personal private repositories.\nIf so, then you need to:\n\ngo to your organisation's settings, Member privileges, and check \"Allow forking of private repositories\" .\n\ngo to your repo and you'll see \"Allow forking\" will be automatically checked after doing step 1,\n.\n\n\nThe process is also described here:\nhttps://docs.github.com/en/organizations/managing-organization-settings/managing-the-forking-policy-for-your-organization"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can't find GitHub invitation to join repo?\n\nI've been invited to join a GitHub repo. I've seen on the team leads computer that I definitely have been invited. However I haven't received an email and I can't see any notifications when I log into GitHub. How can I find my invite and join the repo?"
},
{
"role": "assistant",
"content": "If you got invited to join a GitHub organization (or a team within a organization), then you can see this invite on the following link:\n\nhttps://github.com/orgs/PUT_ORGANIZATION_NAME_HERE/invitation\n\nIf you want to accept a repository invite, then you can use this schema:\n\nhttps://github.com/PUT_ORGANIZATION_NAME_HERE/PUT_REPOSITORY_NAME_HERE/invitations"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-clean"
},
{
"role": "assistant",
"content": "Remove untracked files from the working tree"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules summary [--cached|--files] [(-n|--summary-limit) <n>] [commit] [--] [<path>…]"
},
{
"role": "assistant",
"content": "Show commit summary between the given commit (defaults to HEAD) and\nworking tree/index. For a submodule in question, a series of commits\nin the submodule between the given super project commit and the\nindex or working tree (switched by --cached ) are shown. If the option --files is given, show the series of commits in the submodule between\nthe index of the super project and the working tree of the submodule\n(this option doesn’t allow to use the --cached option or to provide an\nexplicit commit). Using the --submodule=log option with git-diff will provide that\ninformation too."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is Git fast-forwarding?\nIs it OK to assume that fast-forward means all commits are replayed on the target branch and the HEAD is set to the last commit on that branch?"
},
{
"role": "assistant",
"content": "When you try to merge one commit with a commit that can be reached by following the first commit’s history, Git simplifies things by moving the pointer forward, because there isn't any divergent work to merge together—this is called a fast-forward.\nFor more: 3.2 Git Branching - Basic Branching and Merging\nIn another way,\nIf master has not diverged, instead of creating a new commit, Git will just point the master to the latest commit of the feature branch. This is a fast forward.\nThere won't be any merge commit in fast-forwarding merge."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Resize image in the wiki of GitHub using Markdown\n\nI'm writing a wiki page on GitHub, and I'm using Markdown.\nMy problem is that I'm putting a large image (this image is in its own repository) and I need resize it.\nI have tried different solutions, but they do not work:\n\n\n\n\n\n\n[[http://url.to/image.png = 250x]]\n\nIs there a way to get it?\nIt is preferable without HTML."
},
{
"role": "assistant",
"content": "Updated:\nMarkdown syntax for images (external/internal):\n\n\nHTML code for sizing images (internal/external):\n<img src=\"https://github.com/favicon.ico\" width=\"48\">\n\nExample:\n\n\nOld Answer:\nThis should work:\n[[ http://url.to/image.png | height = 100px ]]\nSource: https://guides.github.com/features/mastering-markdown/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Importing a GitHub project into Eclipse\n\nI've imported a GitHub project but how do I setup the project in my Eclipse project workspace?\nDo I need to set the GitHub working directory(c:\\users) to my Eclipse working directory(c:\\Projects) prior to checking out the project ?\n\nEdited : \nMy working directory is now c:\\users\\projectname\\.git\nSo then I try to import the project using the eclipse \"import\" option. When I try to import selecting the option \"Use the new projects wizard\" the source code is not imported, if I import selecting the option \"Import as general project\" the source code is imported but the created project created by Eclipse is not a java project. When selecting the option \"Use the new projects wizard\" and creating a new java project using the wizard should'nt the code be automatically imported ?"
},
{
"role": "assistant",
"content": "As mentioned in Alain Beauvois's answer, and now (Q4 2013) better explained in \n\nEclipse for GitHub\nEGit 3.x manual (section \"Starting from existing Git Repositories\")\nEclipse with GitHub\nEGit tutorial\n\n\nCopy the URL from GitHub and select in Eclipse from the menu the \n\nFile → Import → Git → Projects from Git\n\n\n\nIf the Git repo isn't cloned yet:\nIn> order to checkout a remote project, you will have to clone its repository first.\nOpen the Eclipse Import wizard (e.g. File => Import), select Git => Projects from Git and click Next.\nSelect “URI” and click Next.\nNow you will have to enter the repository’s location and connection data. Entering the URI will automatically fill some fields. Complete any other required fields and hit Next. If you use GitHub, you can copy the URI from the web page.\n\nSelect all branches you wish to clone and hit Next again.\nHit the Clone… button to open another wizard for cloning Git repositories.\n\n\n\nOriginal answer (July 2011)\nFirst, if your \"Working Directory\" is C:\\Users, that is odd, since it would mean you have cloned the GitHub repo directly within C:\\Users (i.e. you have a .git directory in C:\\Users)\nUsually, you would clone a GitHub repo in \"any directory of your choice\\theGitHubRepoName\".\nAs described in the EGit user Manual page:\n\nIn any case (unless you create a \"bare\" Repository, but that's not discussed here), the new Repository is essentially a folder on the local hard disk which contains the \"working directory\" and the metadata folder.\n The metadata folder is a dedicated child folder named \".git\" and often referred to as \".git-folder\". It contains the actual repository (i.e. the Commits, the References, the logs and such).\nThe metadata folder is totally transparent to the Git client, while the working directory is used to expose the currently checked out Repository content as files for tools and editors.\nTypically, if these files are to be used in Eclipse, they must be imported into the Eclipse workspace in one way or another. In order to do so, the easiest way would be to check in .project files from which the \"Import Existing Projects\" wizard can create the projects easily. Thus in most cases, the structure of a Repository containing Eclipse projects would look similar to something like this: \n\nSee also the Using EGit with Github section.\n\n\nMy working directory is now c:\\users\\projectname\\.git \n\nYou should have the content of that repo checked out in c:\\users\\projectname (in other words, you should have more than just the .git).\n\nSo then I try to import the project using the eclipse \"import\" option.\n When I try to import selecting the option \"Use the new projects wizard\", the source code is not imported.\n\nThat is normal.\n\nIf I import selecting the option \"Import as general project\" the source code is imported but the created project created by Eclipse is not a java project. \n\nAgain normal.\n\nWhen selecting the option \"Use the new projects wizard\" and creating a new java project using the wizard should'nt the code be automatically imported ?\n\nNo, that would only create an empty project.\nIf that project is created in c:\\users\\projectname, you can then declare the eisting source directory in that project.\nSince it is defined in the same working directory than the Git repo, that project should then appear as \"versioned\".\nYou could also use the \"Import existing project\" option, if your GitHub repo had versioned the .project and .classpath file, but that may not be the case here."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Simple tool to 'accept theirs' or 'accept mine' on a whole file using git\nI don't want a visual merge tool, and I also don't want to have to vi the conflicted file and manually choose the between HEAD (mine) and the imported change (theirs). Most of the time I either want all of their changes or all of mine. Commonly this is because my change made it upsteam and is coming back to me through a pull, but may be slightly modified in various places.\nIs there a command line tool which will get rid of the conflict markers and choose all one way or another based on my choice? Or a set of git commands which I can alias myself to do each one.\n# accept mine\nalias am=\"some_sequence;of;commands\"\nalias at=\"some_other_sequence;of;commands\"\n\nDoing this is rather annoying.\nFor 'accept mine' I have tried: \nrandy@sabotage ~/linus $ git merge test-branch\nAuto-merging Makefile\nCONFLICT (content): Merge conflict in Makefile\nAutomatic merge failed; fix conflicts and then commit the result.\n\nrandy@sabotage ~/linus $ git checkout Makefile \nerror: path 'Makefile' is unmerged\n\nandy@sabotage ~/linus $ git reset --hard HEAD Makefile \nfatal: Cannot do hard reset with paths.\n\nHow am I supposed to get rid of these change markers?\nI can do: \ngit reset HEAD Makefile; rm Makefile; git checkout Makefile\n\nBut this seems rather round about, there must be a better way. And at this point, I'm not sure if git even thinks the merge happened, so I don't think this necessarily even works.\nGoing the other way, doing 'accept theirs' is equally messy.\nThe only way I can figure it out is do:\ngit show test-branch:Makefile > Makefile; git add Makefile;\n\nThis also gives me a messed up commit message, which has Conflicts: Makefile in it twice.\nCan someone please point out how to do the above two actions in a simpler way? Thanks"
},
{
"role": "assistant",
"content": "The solution is very simple. git checkout <filename> tries to check out file from the index, and therefore fails on merge.\nWhat you need to do is (i.e. checkout a commit):\nTo checkout your own version you can use one of:\ngit checkout HEAD -- <filename>\n\nor\ngit checkout --ours -- <filename>\n\n(Warning!: If you are rebasing --ours and --theirs are swapped.)\nor\ngit show :2:<filename> > <filename> # (stage 2 is ours)\n\nTo checkout the other version you can use one of:\ngit checkout test-branch -- <filename>\n\nor\ngit checkout --theirs -- <filename>\n\nor\ngit show :3:<filename> > <filename> # (stage 3 is theirs)\n\nYou would also need to run 'add' to mark it as resolved:\ngit add <filename>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rm - Remove files from the working tree and from the index"
},
{
"role": "assistant",
"content": "SYNOPSIS git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch]\n\t [--quiet] [--pathspec-from-file=<file> [--pathspec-file-nul]]\n\t [--] [<pathspec>…]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %cL"
},
{
"role": "assistant",
"content": "committer local-part (see %cl ) respecting .mailmap, see git-shortlog or git-blame )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I do basic authentication with RestClient?\n\nDoes anyone know how to do basic authentication with RestClient?\nI need to create a private repository on GitHub through their RESTful API."
},
{
"role": "assistant",
"content": "The easiest way is to embed the details in the URL:\nRestClient.get \"http://username:[email protected]\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database nullSha1"
},
{
"role": "assistant",
"content": "(WARN) Tree contains entries pointing to a null sha1."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to show space and tabs with git-diff\nI have the following output with git-diff.\n- // sort list based on value \n+ // sort list based on value\n\nHow can I easily see the number of removed tabs/spaces at the end of the line ?"
},
{
"role": "assistant",
"content": "Note: Git 2.5+ (Q2 2015) will propose a more specific option for whitespace detection.\nSee commits 0e383e1, 0ad782f, and d55ef3e [26 May 2015] by Junio C Hamano (gitster).\n(Merged by Junio in commit 709cd91, 11 Jun 2015) \n\ndiff.c: --ws-error-highlight=<kind> option\nTraditionally, we only cared about whitespace breakages introduced\n in new lines.\nSome people want to paint whitespace breakages on old\n lines, too. When they see a whitespace breakage on a new line, they\n can spot the same kind of whitespace breakage on the corresponding\n old line and want to say \"Ah, those breakages are there but they\n were inherited from the original, so let's not touch them for now.\"\nIntroduce --ws-error-highlight=<kind> option, that lets them pass\n a comma separated list of old, new, and context to specify\n what lines to highlight whitespace errors on.\n\nThe documentation now includes:\n--ws-error-highlight=<kind>\n\n\nHighlight whitespace errors on lines specified by <kind> in the color specified by color.diff.whitespace.\n<kind> is a comma separated list of old, new, context.\n When this option is not given, only whitespace errors in new lines are highlighted. \nE.g. --ws-error-highlight=new,old highlights whitespace errors on both deleted and added lines.\nall can be used as a short-hand for old,new,context.\n\nFor instance, the old commit had one whitespace error (bbb), but you can focus on the new errors only:\n\n(test done after t/t4015-diff-whitespace.sh)\n\nUpdate Git 2.11+ (Q4 2016, a year and half later) : \ngit config diff.wsErrorHighlight [old,new,context]\n\ngit diff/log --ws-error-highlight=<kind> lacked the corresponding configuration variable to set it by default. That is added in Git 2.11.\nSee commit 0b4b42e, commit 077965f, commit f3f5c7f (04 Oct 2016) by Junio C Hamano (gitster).\n(Merged by Junio C Hamano -- gitster -- in commit e5272d3, 26 Oct 2016)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index --allow-empty"
},
{
"role": "assistant",
"content": "Don’t return an error for patches containing no diff. This includes\nempty patches and patches with commit text only."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show-ref - List references in a local repository -s --hash[=<n>]"
},
{
"role": "assistant",
"content": "Only show the OID, not the reference name. When combined with --dereference , the dereferenced tag will still be shown after the OID."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How does the Android repo manifest repository work?\nThe Android source is a large hierarchy of git repositories. They are managed by a custom script called repo. Repo determines which git repositories to manage using a manifest.xml. The manifest.xml of Android is hosted in a git repository along with all the other git repositories.\nHow is this repository managed in Android? Specifically how are the different branches and the different files hosted in each branch organised?"
},
{
"role": "assistant",
"content": "First, repo init creates the .repo directory, clones the git repository https://android.googlesource.com/tools/repo to .repo/repo, and the git repository specified with the -u option to a bare repository at .repo/manifests.git. After that, it creates the .repo/manifests directory, converts it into a git repository through creating symbolic links from .repo/manifests/.git to .repo/manifests.git. It then checks out the branch specified in -b, and creates a symbolic link .repo/manifest.xml pointing to the specified file (-m option) in .repo/manifests, by default .repo/manifests/default.xml. \nRoughly as follows:\n\n repo init -u $URL -b $BRANCH -m $MANIFEST\n --------------------\n mkdir .repo; cd .repo\n git clone https://android.googlesource.com/tools/repo\n git clone --bare $URL manifests.git\n mkdir -p manifests/.git; cd manifests/.git\n for i in ../../manifests.git/*; do ln -s $ı .; done\n cd ..\n git checkout $BRANCH -- .\n cd ..\n ln -s manifests/$MANIFEST manifest.xml \n\nYou can trace what really happens with repo --trace init ...\nThen, repo sync clones git repositories to .repo/projects for each project in manifest.xml and local_manifest.xml, creates working directories with .git having symlinks to the corresponding bare repository, checks out the branch specified in the manifest, and updates .repo/project.list. The case where the projects are already there is slightly different, essentially performing a git pull --rebase."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab pipeline - reports config contains unknown keys: cobertura\n\nI'm not able run the gitlab pipeline due to this error\nInvalid CI config YAML file\njobs:run tests:artifacts:reports config contains unknown keys: cobertura"
},
{
"role": "assistant",
"content": "Check the latest correct doc here: https://docs.gitlab.com/ee/ci/yaml/artifacts_reports.html#artifactsreportscoverage_report\nSome of the docs are in somewhat of a messy state right now, due to the new release as mentioned.\nThis was the fix for me:\n artifacts:\n expire_in: 2 days\n reports:\n coverage_report:\n coverage_format: cobertura\n path: python_app/coverage.xml"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitlab Request to merge branch-A into develop (3 commits behind) should I worry?\n\nWhen creating a merge request in gitlab I often get a message:\nRequest to merge branch-A into develop ([x] commits behind) \nwhat does gitlab want to tell me?\nshould I worry or do I need to fix something (what)?"
},
{
"role": "assistant",
"content": "After some time a merge request is open in a project it is normal that the version of the branch you are trying to merge into becomes outdated due to other people merging their own changes to it. \nGitlab helps you by showing how much the version of the branch you updated is behind the remote branch. \nBeing behind will not set any hindrance to the act of merging, but it is a common practice to rebase your commits on top of the branch your merging into. This will make your merge request updated by putting your commits chronologically after the ones that already are in that branch. That approach makes the work of the person responsible for the merge easier because the commiter himself has already resolved any conflicts that would have happened.\nTo do a rebase following the scenario you proposed would be like this:\n# Add a remote named `upstream` pointing to the original repository\ngit remote add upstream https://gitlab.example.com/example/your_project.git\n\n# Fetch the latest commmits from `upstream`\ngit fetch upstream\n\n# Checkout our branch-A\ngit checkout branch-A\n\n# Rebase our branch on top of the `upstream/develop` branch\ngit rebase upstream/develop\n\n# If needed fix any conflicts that may have appeared and then `git rebase --continue` \n\n# Push the changes to the branch of your merge request\ngit push --force origin branch-A\n\nNote: The --force flag is necessary when you push because you are rewriting the commit history of origin/branch-A. From git's doc:\n\n[--force] can cause the remote repository to lose commits; use it with care."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc histogram"
},
{
"role": "assistant",
"content": "This algorithm extends the patience algorithm to \"support\nlow-occurrence common elements\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you hide .git project directories?\nNow that I have nginx setup I need to be able to hide my .git directories. What kind of rewrite would I need to stop prying eyes? And where in the server {} or http {} block would it go?"
},
{
"role": "assistant",
"content": "http {\n server {\n location ~ /\\.git {\n deny all;\n }\n }\n}\n\nThis location directive will deny access to any .git directory in any subdirectory.\nNote: This location block must be before your main location block, so that it can be evaluated first."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-difftool - Show changes using common diff tools --[no-]trust-exit-code"
},
{
"role": "assistant",
"content": "Errors reported by the diff tool are ignored by default.\nUse --trust-exit-code to make git-difftool exit when an\ninvoked diff tool returns a non-zero exit code. git-difftool will forward the exit code of the invoked tool when --trust-exit-code is used."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to make an existing directory within a git repository a git submodule\nI'm very confused about git-submodules.\nBasically my problem is that I can't make git understand that ~/main-project/submodule is a submodule.\n\nI have good experience with git submodules:\nin my dotfiles repository I created the .gitmodules file in ~/dotfiles-repo and I added there paths and urls. Since then, If I make changes to the files within the submodules and run git status, I'd get something like like: .vim/bundle/auto-complete (new commits) # in red\nI created the .gitmodules file in ~/main-project but:\n\nIf I make changes to ~/main-project/submodule and even push the changes, I don't get a similar response like <submodule> (new commits) # in red when running git status in ~/main-project. I just get the changes that were made in those directories\nWhen I hit the folders' links at github for these directories it's not directing me to the repositories themselves but I stay in the same repository.\n\nMaybe I'm missing the whole point. What are the main features of submodules?\nWhy does git understands the submodules in the dotfiles repo but not in my other repo?\nIs it because I have already told git to add the files inside ~/main-project/submodule to the index?\n\n\nI've read this question which led me to this answer But I'm not sure I need git-subtree. I don't want to do things that might do changes hard to be revert.\n\nEdit: This suggested duplicate-solution didn't work either, I recieved an error that Updates were rejected because the remote contains work that you do not have locally. It seems that @GabLeRoux practically told me to push <repo-A> to the url of <repo-B>."
},
{
"role": "assistant",
"content": "Use git submodule absorbgitdirs\nThis is what the docs state this command does:\n\nIf a git directory of a submodule is inside the submodule,\nmove the git directory of the submodule into its superprojects\n$GIT_DIR/modules path and then connect the git directory and\nits working directory by setting the core.worktree and adding\na .git file pointing to the git directory embedded in the\nsuperprojects git directory.\n\nSo instead of starting all over as suggested in the previous answers by @DomQ and myself, one can just add run the following:\n\nWithout removing from the index the submodule, Add the submodule's url to .gitmodules and to .git/config with\ngit submodule add <url> <path>\n(Optional but recommended step) Move the submodule's $GIT_DIR directory (.git in regular repositories) to .git/modules/<path> with:\ngit submodule absorbgitdirs <path>\n\nOriginal answer - pre v2.12.0\ngit submodule absorbgitdirs was introduced only in v2.12.0-rc0 (see commit).\nThe Solution is quite simple. It was extracted from here.\n\ngit rm submodule-dir\nThis will delete all the files that git was tracking after in submodule-dir\nrm -rf submoduledir\nThis will delete all the other files that might have been left in submodule-dir because git ignored them.\nNow, we have to commit in order to remove the files from the index:\ngit commit\nAfter the commit, we cleaned the files that git followed and didn't followed in submodul-dir.\nNow it's time to do:\ngit submodule add <remote-path-to-submodule>\nThis will re-add the submodule but as a true submodule.\nAt this point it might be a good idea to check .gitmodules and see if the submodules have been added successfully. In my case I already had an .gitmodules file so I had to modify it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --color-moved[=<mode>]"
},
{
"role": "assistant",
"content": "Moved lines of code are colored differently.\nIt can be changed by the diff.colorMoved configuration setting.\nThe <mode> defaults to no if the option is not given\nand to zebra if the option with no mode is given.\nThe mode must be one of: no Moved lines are not highlighted. default Is a synonym for zebra . This may change to a more sensible mode\nin the future. plain 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. blocks Blocks of moved text of at least 20 alphanumeric characters\nare detected greedily. The detected blocks are\npainted using either the color.diff.{old,new}Moved color.\nAdjacent blocks cannot be told apart. zebra Blocks of moved text are detected as in blocks mode. The blocks\nare painted using either the color.diff.{old,new}Moved color or color.diff.{old,new}MovedAlternative . The change between\nthe two colors indicates that a new block was detected. dimmed-zebra Similar to zebra , but additional dimming of uninteresting parts\nof moved code is performed. The bordering lines of two adjacent\nblocks are considered interesting, the rest is uninteresting. dimmed_zebra is a deprecated synonym."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Updating a local repository with changes from a GitHub repository\n\nI've got a project checked locally from GitHub, and that remote repository has since had changes made to it. What's the correct command to update my local copy with the latest changes?"
},
{
"role": "assistant",
"content": "Probably:\neither: git pull origin master\n\n or: git pull origin main"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git list of staged files\nI staged a lot of files using git add, and now I want to see all the files I have staged, without untracked files or changed, but unstaged files.\nHow do I do that? When using git diff --cached I can see the changes of what I just staged. So then I tried using git status --cached, but that --cached unfortunately doesn't work on git status."
},
{
"role": "assistant",
"content": "The best way to do this is by running the command:\ngit diff --name-only --cached\n\nWhen you check the manual you will likely find the following:\n--name-only\n Show only names of changed files.\n\nAnd on the example part of the manual:\ngit diff --cached\n Changes between the index and your current HEAD.\n\nCombined together, you get the changes between the index and your current HEAD and Show only names of changed files.\n--staged is also available as an alias for --cached above in more recent Git versions.\nNB: This can be combined with --diff-filter to only show (filter) staged files that are added (A), modified (M) etc.\ngit diff --name-only --cached --diff-filter=AM"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub Error - \"ssh: connect to host github.com port 22: Operation timed out fatal: Could not read from remote repository.\"\n\nI want to push a repo from my computer to GitHub. I set the remote origin\ngit remote add origin [email protected]:alicht/tweetanuber.git\n\nand then after when I try pushing to GitHub\ngit push -u origin master\n\nI'm greeted with this error:\nssh: connect to host github.com port 22: Operation timed out\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n\nHow can I resolve this issue and push the repo on my local computer to GitHub?"
},
{
"role": "assistant",
"content": "I have had this same problem the solution was edit ~/.ssh/config and put this lines:\nHost github.com\n Hostname ssh.github.com\n Port 443\n\nIf there is no file config in this folder, simply create one."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules --checkout"
},
{
"role": "assistant",
"content": "This option is only valid for the update command.\nCheckout the commit recorded in the superproject on a detached HEAD\nin the submodule. This is the default behavior, the main use of\nthis option is to override submodule.$name.update when set to\na value other than checkout .\nIf the key submodule.$name.update is either not explicitly set or\nset to checkout , this option is implicit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %cL"
},
{
"role": "assistant",
"content": "committer local-part (see %cl ) respecting .mailmap, see git-shortlog or git-blame )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Cloning a Non-Standard Svn Repository with Git-Svn\nI'm relatively new to Git, but I've found it so easy to work with at home that I'd like to use it at work where our projects are stored in Svn repositories. Unfortunately, the repositories are slightly non-standard and I'm having trouble getting them cloned. Sure, they all have trunk, branches/ and tags/, but branches/ and tags/ have subdirectories before hitting the real project directories:\ntrunk/\nbranches/maintenance/release1\nbranches/maintenance/release2\n...\nbranches/development/feature1\nbranches/development/feature2\n...\ntags/build/build1\ntags/build/build2\n...\ntags/release/release1\ntags/release/release2\n\nAfter cloning:\n$ git svn clone -s --prefix=svn/ https://mydomain.com/svnproject\n$ git branch -r\n development\n development@1340\n maintenance\n maintenance@1340\n tags/build\n tags/build@1340\n tags/release\n tags/release@1340\n trunk\n trunk@1340 \n\nI get none of the actual project branches or tags. I actually need to be able to work on the trunk, one maintenance branch and one development branch. I've tried this approach in addition to several hacks at modifying the config, but nothing is working for me.\nIs there any way I can get the key components of my non-standard Svn project into a local git repository so that I can easily move between them?\nMany thanks.\nUPDATE: I should add that I can't do a wholesale switch to Git (yet). There are other team members involved and an international presence. The logistics of the transition are more than I'm willing to undertake until I'm much more comfortable with Git; as I mentioned, I'm still pretty new. I've barely scratched the surface of its capabilities."
},
{
"role": "assistant",
"content": "Lee B was right. The answer, provided by doener in #git, is to upgrade Git to 1.6.x (I had been using 1.5.x). 1.6.x offers deep cloning so that multiple wildcards can be used with the --branches option:\n$ git svn clone https://svn.myrepos.com/myproject web-self-serve \\ \n --trunk=trunk --branches=branches/*/* --prefix=svn/\n$ git branch -r\n svn/development/sandbox1\n svn/development/feature1\n svn/development/sandbox2\n svn/development/sandbox3\n svn/development/model-associations\n svn/maintenance/version1.0.0\n svn/trunk\n\nExactly what I needed. Thanks for the insight, all."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I remove a big file wrongly committed in git [duplicate]\nThis question already has answers here:\n \n \n\n\n\nClosed 12 years ago.\n\n\n\n\nPossible Duplicate:\nHow to purge a huge file from commits history in Git? \n\nI did a stupid thing. Imagine that I committed a 100MB file. Then I see this and delete this file and commit again. This is a normal procedure to delete a file. \nBut now the side effect is that my history is heavy because it's saved this large file (I believe this is why it is heavy). I am only using local git, so I do not synchronize in any server.\nHow can I definitively remove this file and save disk space?"
},
{
"role": "assistant",
"content": "You can do it using the git filter-branch command, like this :\ngit filter-branch --index-filter \"git rm -rf --cached --ignore-unmatch path_to_file\" HEAD\n\nYou can find more documentation here http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission -U<n> --unified=<n>"
},
{
"role": "assistant",
"content": "Generate diffs with <n> lines of context instead of\nthe usual three."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-apply"
},
{
"role": "assistant",
"content": "Apply a patch to files and/or to the index"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker"
},
{
"role": "assistant",
"content": "GIT COMMANDS We divide Git into high level (\"porcelain\") commands and low level\n(\"plumbing\") commands."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to Merge two different Git repositories?\n\nI have two Github repositories. One repository is on the remote server and another on the local server. Both of them have different commit histories of different files and folders. Now I wanted to merge both of them so that I can have both of them on the remote server as one single repository. Please help!\nI have looked for various solutions suggesting as: reset the head of the local repository and then pull the remote repository on the same directory but it doesn't seem to be working: \ngit reset --soft head ~CommitSHA (First commit of the local repo)\ngit pull ~giturlofremoterepo (Pulling remote repo in the same directory)"
},
{
"role": "assistant",
"content": "In a nutshell you can checkout one repository, add a remote to the second, rebase the second on top of the first and push the result to your new single remote repository:\nClone the first repository and add a remote to the second\ngit clone https://first.repo\ngit remote add second https://second.repo\n\nFetch the second and check its master branch out to a local branch second\ngit fetch second\ngit checkout second/master\ngit checkout -b second\n\nRebase the master branch of the second repository on top of the master branch of the first. Resolve any potential conflict along the way.\ngit rebase master second\n\nPush to a new upstream repository\ngit push -u ...\n\nThis results in the two commit histories being concatenated one after each other."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I resolve git saying \"Commit your changes or stash them before you can merge\"?\nI made some updates on my local machine, pushed them to a remote repository, and now I'm trying to pull the changes to the server and I get the message;\nerror: Your local changes to the following files would be overwritten by merge:\nwp-content/w3tc-config/master.php\nPlease, commit your changes or stash them before you can merge.\n\nSo I ran,\ngit checkout -- wp-content/w3tc-config/master.php\n\nand tried again and I get the same message. I'm assuming that w3tc changed something in the config file on the server. I don't care whether the local copy or remote copy goes on the server (I suppose the remote one is best), I just want to be able to merge the rest of my changes (plugin updates).\nAny ideas?"
},
{
"role": "assistant",
"content": "You can't merge with local modifications. Git protects you from losing potentially important changes.\nYou have three options: \n\nCommit the change using\ngit commit -m \"My message\"\n\nStash it.\nStashing acts as a stack, where you can push changes, and you pop them in reverse order.\nTo stash, type\ngit stash\n\nDo the merge, and then pull the stash:\ngit stash pop\n\nDiscard the local changes\nusing git reset --hard\nor git checkout -t -f remote/branch\nOr: Discard local changes for a specific file\nusing git checkout filename"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to remove an unpushed outgoing commit in Visual Studio?\nI accidentally pushed a staged change in a new branch in Visual Studio 2017 to my local repository. It hasn't been pushed to the remote repository. I want to get rid of it but can't find a way to do this. I rebased from local master branch to the new branch. Then I deleted the new branch. But Outgoing Commits still shows it. How to delete it or revert it?"
},
{
"role": "assistant",
"content": "Open the history tab in Team Explorer from the Branches tile (right-click your branch). Then in the history right-click the commit before the one you don't want to push, choose Reset. That will move the branch back to that commit and should get rid of the extra commit you made. In order to reset before a given commit you thus have to select its parent.\n\nDepending on what you want to do with the changes choose hard, which will get rid of them locally. Or choose soft which will undo the commit but will leave your working directory with the changes in your discarded commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "difference between git merge origin/master and git pull\nI'm working on a local branch \"BDD-local\" and would like to get the changes from other developers. \nThe other developers are using their own branch and once they are happy with the unit tests, they push the changes to remote repo (origin/master).\nI was going through several posts here and getting conflicting information.\nFew people talk about using:\ngit fetch origin\ngit merge origin/master\n\nSome others think, 'git pull' should get the changes.\nOne of our developers asked to use 'git merge origin/master' without the 'git fetch'\nDoes anyone know which of these options is better. I tried 'git pull' on my local branch but it didn't seem to work. But if I do 'git pull' on local master it works fine (however I want it to work for the local branch)"
},
{
"role": "assistant",
"content": "git pull is the same as git fetch + git merge\nThe command\ngit pull <remote> <branch>\n\nis really just the same as\ngit fetch <remote>\ngit merge <remote>/<branch>\n\nSo there is no practical difference between\ngit pull origin master\n\nand \ngit fetch origin\ngit merge origin/master\n\nDocumentation\nAs stated in the official Linux Kernel git pull documentation:\n\nIn its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD.\nMore precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch.\n\nRecommended Reading\n\nPro Git § 2.5 Git Basics - Working with Remotes - Fetching and Pulling from Your Remotes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rebase - Reapply commits on top of another base tip resolve"
},
{
"role": "assistant",
"content": "This can only resolve two heads (i.e. the current branch\nand another branch you pulled from) using a 3-way merge\nalgorithm. It tries to carefully detect criss-cross\nmerge ambiguities. It does not handle renames."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I make a pull request on a gist on GitHub?\n\nCan I make a pull request on some else's gist on GitHub?\nI'm aware of the fork, clone and commit workflow for a gist I own. I'd like to know if I can request to update someone else's gist with my fork."
},
{
"role": "assistant",
"content": "You cannot currently open a pull request on a Gist.\nYou can comment though on the Gist and ask the author to update the Gist from your fork."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --all-match"
},
{
"role": "assistant",
"content": "Limit the commits output to ones that match all given --grep ,\ninstead of ones that match at least one."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does the message \"rewrite ... (90%)\" after a Git commit mean? [duplicate]\nThis question already has an answer here:\n \n \n\n\n\n\nWhat does it mean when Git says 'rewrite' or 'rename' in a commit message?\n\n (1 answer)\n \n\nClosed 7 years ago.\n\n\n\nWhen git does a commit it rewrites binary files with something similar to rewrite foobar.bin (76%). What is that %? Is it percent changed or percent retained from the older file. I know that git uses a binary delta for files, but I just don't know how much of a rewrite the % represents and it doesn't seem to be in the help page for git help commit.\nThanks!"
},
{
"role": "assistant",
"content": "Its a measure of the similarity index. The similarity index is the percentage of unchanged lines. git thinks your file is text."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Change email address in Git\nI have a project hosted in Git stash (now rebranded as Bitbucket Server). It is built using Jenkins.\nNow I made a typo while installing my Git locally.\nLike @ab.example instead of @abc.example\nAfter every build, Jenkins sends email notifications and it picks up my incorrect email address from Git commit and tries to send it.\nEven after I have changed the email address in my local Git, I still see Jenkins sending the emails to the old incorrect address.\nHow can I fix this?"
},
{
"role": "assistant",
"content": "Locally set email-address (separately for each repository)\n\nOpen Git Bash.\n\nChange the current working directory to the local repository in which you want to set your Git config email.\n\nSet your email address with the following command:\n\n\ngit config user.email \"[email protected]\"\n\n\nConfirm that you have set your email address correctly with the following command.\n\ngit config user.email\n\nGlobally set email-address (only used when nothing is set locally)\n\nOpen Git Bash.\n\nSet your email address with the following command:\n\n\ngit config --global user.email \"[email protected]\"\n\n\nConfirm that you have set your email address:\n\ngit config --global user.email\n\nOr using environment variables\n\n[email protected]\n[email protected]\n\nPD: Info from GitHub official guide"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git merge error \"commit is not possible because you have unmerged files\"\nI forgot to git pull my code before editing it; when I committed the new code and tried to push, I got the error \"push is not possible\".\nAt that point I did a git pull which made some files with conflict highlighted. I removed the conflicts but I don't know what to do from here.\nI tried to git commit again but it says the \"commit is not possible because you have unmerged files\":\n\nerror: Committing is not possible because you have unmerged files."
},
{
"role": "assistant",
"content": "If you have fixed the conflicts you need to add the files to the stage with git add [filename], then commit as normal."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Does \"Allow access to this project with a CI_JOB_TOKEN\" in GitLab work between private repositories?\n\nI am part of a private group (our team in our department). All underlying projects and subgroups can only be private (this is how GitLab works) and we all have at least Report-level access to those. Not to be confused with the personal namespace for each user!\nI have created a subgroup with multiple repositories inside for a large Django project I am working on. One of the repositories (main, also includes manage.py as well as the Django project main files that are used by django-admin to configure and run the whole project) is referencing a couple of the others as submodules (Django apps).\nI am trying to create a building job using Kaniko that is configured in the main repo and uses both the repo's own code as well as all the submodules to make the application complete. Sadly, I am encountering an authentication problem.\nEven though I am the owner of the subgroup as well as the repos inside, cloning a submodule apparently still requires username and password. My setup does not allow me to use git config to add the required credentials - an automatically generated CI user and CI_JOB_TOKEN - I decided to look into sharing these credentials among all repos that are in some way linked (main repo + submodules).\nIn the CI/CD section of the Web UI in GitLab I have the following option:\n\nI tried to set the path to the project to my main repo that uses the current repo as a submodule. However, I am getting\nThe target_project that you are attempting to access does not exist or you don't have permission to perform this action\n\nThe project does exist (tried with and without the .git suffix) so the only thing that remains is, yet again a credentials issue.\nI might have missed a hint but the official documentation doesn't say that private repos cannot share a token."
},
{
"role": "assistant",
"content": "I can confirm that is possible to add the permission to a private project. The problem is the confusing gitlab UI that does not accept the entire URL of a repo and requires the user to inform just the final part.\nI had a repo with the following url:\nhttps://gitlab.com/mygroup/mysubgroup/myreponame\n\nI was adding the entire url path to it, I was getting the same error:\nThe target_project that you are attempting to access does not exist or you don't have permission to perform this action\n\nThen I realized that all I needed to do was add just the final part:\nmygroup/mysubgroup/myreponame\n\nAnd it worked."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cherry-pick - Apply the changes introduced by some existing commits --strategy=<strategy>"
},
{
"role": "assistant",
"content": "Use the given merge strategy. Should only be used once.\nSee the MERGE STRATEGIES section in git-merge for details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is it possible to create a remote repo on GitHub from the CLI without opening browser?\n\nI created a new local Git repository:\n~$ mkdir projectname\n~$ cd projectname\n~$ git init\n~$ touch file1\n~$ git add file1\n~$ git commit -m 'first commit'\n\nIs there any git command to create a new remote repo and push my commit to GitHub from here? I know it's no big deal to just fire up a browser and head over to Create a New Repository, but if there is a way to achieve this from the CLI I would be happy.\nI read a vast amount of articles but none that I found mention how to create a remote repo from the CLI using git commands. Tim Lucas's nice article Setting up a new remote git repository is the closest I found, but GitHub does not provide shell access."
},
{
"role": "assistant",
"content": "CLI commands for github API v3 (replace all CAPS keywords):\ncurl -u 'USER' https://api.github.com/user/repos -d '{\"name\":\"REPO\"}'\n# Remember replace USER with your username and REPO with your repository/application name!\ngit remote add origin [email protected]:USER/REPO.git\ngit push origin master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-cvsserver"
},
{
"role": "assistant",
"content": "A CVS server emulator for Git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to ignore all hidden directories/files recursively in a git repository?\nI'd like to have Git ignore all hidden files and directories. \ni.e. \n\n.aptitude\n.ssh/\n.bash_rc\nconfig/.hidden\n\nIs there a simple rule to cover this without specifically adding each entry?"
},
{
"role": "assistant",
"content": "Just add a pattern to .gitignore\n.*\n!/.gitignore\n\nEdit: Added the .gitignore file itself (matters if it is not yet commited)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --word-diff[=<mode>]"
},
{
"role": "assistant",
"content": "Show a word diff, using the <mode> to delimit changed words.\nBy default, words are delimited by whitespace; see --word-diff-regex below. The <mode> defaults to plain , and\nmust be one of: color Highlight changed words using only colors. Implies --color . plain Show words as [-removed-] and {+added+} . Makes no\nattempts to escape the delimiters if they appear in the input,\nso the output may be ambiguous. porcelain Use a special line-based format intended for script\nconsumption. Added/removed/unchanged runs are printed in the\nusual unified diff format, starting with a + / - /` `\ncharacter at the beginning of the line and extending to the\nend of the line. Newlines in the input are represented by a\ntilde ~ on a line of its own. none Disable word diff again. Note that despite the name of the first mode, color is used to\nhighlight the changed parts in all modes if enabled."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a \"git pull --dry-run\" option in Git?\nIs there such a thing as git pull --dry-run to see how stuff will be merged before it messes up my working tree?\nRight now I am doing:\ngit fetch origin && git merge --no-commit --no-ff\n\nI did not see anything in the man page for 'git-pull' related to it.\nTo clarify, I just need it in an Ant script for deployment to see if there are conflicts when doing git pull, then back off exit out of build, fail deployment and leave that directory tree the same it was before git pull."
},
{
"role": "assistant",
"content": "I have always relied on the inherent abilities of Git to get me back if a merge fails.\nTo estimate how the merge might occur, you can start like you did with:\n$ git fetch origin branch # Fetch changes, but don't merge\n$ git diff HEAD..origin/branch # Diff your current head to the fetched commit\n\n... personal judgement of potential merge conflicts ...\n\n$ git merge origin/branch # merge with the fetched commit\n\nIf things did not go as planned, look at your reflog and reset back to your desired state:\n$ git reflog\n...\nabc987 HEAD@{0}: merge activity\nb58aae8 HEAD@{1}: fetch origin/branch\n8f3a362 HEAD@{2}: activity before the fetch\n...\n$ git reset --hard HEAD{2}"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-gui"
},
{
"role": "assistant",
"content": "A portable graphical interface to Git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-quiltimport"
},
{
"role": "assistant",
"content": "Applies a quilt patchset onto the current branch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git, Heroku: pre-receive hook declined\nI am in the process of setting up a git repository and attempting to link it to Heroku. When I run the command\ngit push heroku master\n\nI receive\nCounting objects: 7, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (5/5), done.\nWriting objects: 100% (7/7), 714 bytes, done.\nTotal 7 (delta 1), reused 0 (delta 0)\n\n-----> Heroku receiving push\n\n ! Heroku push rejected due to an unrecognized error.\n ! We've been notified, see http://support.heroku.com if the problem persists.\n\n\nTo [email protected]:morning-stream-3712.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:morning-stream-3712.git'\n\nHow can I get my application pushed to Heroku?"
},
{
"role": "assistant",
"content": "Make sure you are pushing a repo that contains a proper supported app ( Rails, Django etc.) and you are not just pushing some random repo to test it out.\nNewbie in Heroku: Error when push my app to Heroku\nIf that is not the case and you are pushing what you think is a valid app, contact Heroku support and they will fix it for you."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Rolling back local and remote git repository by 1 commit [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nRemove last commit from remote Git repository\n\n (2 answers)\n \n\nClosed 1 year ago.\n\n\n\nI've read the similar posts on this topic, and can't for the life of me figure out how to do this properly.\nI checked in about 1000 files that I don't want, and I'd rather not have to go through 1by1 and remove them all from the repo.\n\nI have a remote master Branch.\nI have the local master Branch.\n\nThey are both at the same revision.\nI want to rollback my remote by 1 commit.\nSay my history on master is A--B--C--D--E.\nI want to rollback my local to D.\nThen push it to remote so my current hash will be D both remote and local. \nI'm having issues doing this.\nI'm using Git Tower but am comfortable with the command line. Any help?\nUPDATE: \nGreat comments below. Using a reset seems to be partially discouraged especially if the repository is shared with other users.\nWhat's the best way to undo the previous commit's changes without using a hard reset? Is there a way?"
},
{
"role": "assistant",
"content": "If nobody has pulled your remote repo yet, you can change your branch HEAD and force push it to said remote repo:\ngit reset --hard HEAD^ \ngit push -f \n\n(or, if you have direct access to the remote repo, you can change its HEAD reference even though it is a bare repo)\nNote, as commented by alien-technology in the comments below, on Windows (CMD session), you would need ^^:\ngit reset --hard HEAD^^\ngit push -f \n\nAnd? as noted in the comments by Jon Schneider:\n\nIf the command with \"HEAD^\" results in error no matches found: HEAD^, see \"git show HEAD^ doesn't seem to be working. Is this normal?\"\n\nUpdate since 2011:\nUsing git push --force-with-lease (that I present here, introduced in 2013 with Git 1.8.5) is safer.\nSee Schwern's answer for illustration.\n\n\nWhat if somebody has already pulled the repo? What would I do then?\n\nThen I would suggest something that doesn't rewrite the history:\n\ngit revert locally your last commit (creating a new commit that reverses what the previous commit did)\npush the 'revert' generated by git revert."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects --relative[=<path>] --no-relative"
},
{
"role": "assistant",
"content": "When run from a subdirectory of the project, it can be\ntold to exclude changes outside the directory and show\npathnames relative to it with this option. When you are\nnot in a subdirectory (e.g. in a bare repository), you\ncan name which subdirectory to make the output relative\nto by giving a <path> as an argument. --no-relative can be used to countermand both diff.relative config\noption and previous --relative ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index --reject"
},
{
"role": "assistant",
"content": "For atomicity, git apply by default fails the whole patch and\ndoes not touch the working tree when some of the hunks\ndo not apply. This option makes it apply\nthe parts of the patch that are applicable, and leave the\nrejected hunks in corresponding *.rej files."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options grep.patternType"
},
{
"role": "assistant",
"content": "Set the default matching behavior. Using a value of basic , extended , fixed , or perl will enable the --basic-regexp , --extended-regexp , --fixed-strings , or --perl-regexp option accordingly, while the\nvalue default will use the grep.extendedRegexp option to choose\nbetween basic and extended ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git push all branches from one remote to another remote\nI have two remote: upstream and origin. upstream is something I can't push to. origin is my own repo. How can I fetch all branches from upstream and then push them to origin?\nI tried:\ngit fetch upstream\ngit push --all origin\n\nBut it doesn't work."
},
{
"role": "assistant",
"content": "I just needed to copy one repository from Bitbucket to GitHub, these are the steps assuming your remote is called origin, all branches and tags will be copied:\ngit remote add neworigin url-to-new-remote\ngit push neworigin --tags \"refs/remotes/origin/*:refs/heads/*\"\n\nGood thing about this is that files in your working copy won't be modified."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects dense-combined, cc"
},
{
"role": "assistant",
"content": "Further compress output produced by --diff-merges=combined by omitting uninteresting hunks whose contents in the parents\nhave only two variants and the merge result picks one of them\nwithout modification."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Where is git-blame in SourceTree\nI'd like to see who contributed which line/change to a file. git-blame does exactly that. So does SourceTree have a git-blame view?"
},
{
"role": "assistant",
"content": "Select a file, whether in the 'working copy' display or in the 'commit' display, and do one of three things:\n\noption-command-B\nmenu bar :: Actions :: Blame Selected...\ncontextual menu :: Blame Selected...\n\nIf the file you want to blame is not in the modified files list, you need to change the view to File Status View (View --> File Status View), then set the Sub menu to \"Show All\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I use Bash on Ubuntu on Windows (WSL) for my VS Code terminal?\nWhile other questions deal with how to use things like git-bash, giving the new WSL a spin as the terminal for VS Code is not the same: it gives you access to bash running on an actual Ubuntu Linux subsystem, instead of the git-bash terminal running on the Windows subsystem.\nSo how do we get it working as the VS Code terminal, and particularly how do we get it working as a functional dev environment terminal?\nUnlike git-bash, this is unfortunately not as simple, because the Ubuntu Linux configuration in WSL can provide some gotchas, such as NPM trying (and failing) to run from your Windows Program Files directory due to the interaction between WSL and Windows itself in terms of pathing, and some packages such as Compass failing for what are not necessarily immediately obvious reasons to someone who is not used to developing on Linux. What's a simple way to have a reliable WSL terminal environment for VS Code where most frequently used tools will run when installed via apt-get or npm?"
},
{
"role": "assistant",
"content": "This answer seeks to help others avoid spending 1-2 hours troubleshooting and slowly finding disparate solutions for common problems when using WSL for the terminal in VS Code. It does not cover installing specific packages, but rather common ones that may not properly install as dependencies when installing things that do rely on their presence, and on fixing related common settings.\nSummary of steps\n\nWSL installed\nVS Code (or other IDE) configured for terminal\nNPM installed & path fix in .profile (may help with other tools)\nbuild-essential installed (helps with any tools that use make/gcc/etc)\nVS Code Tasks using WSL\nExtras\n\nGetting Started & Requirements\n\nYou must have WSL installed. (Which means you must be running 64 bit Windows 10, with the appropriate updates) Follow the install guide if not already installed. This will require some reboots.\n\nVS Code Terminal Configuration\nEither the CTRL+, keyboard shortcut, or File → Preferences → Settings\nIn the top right of the editing window, make sure you are working in the correct context for you: either User Settings or Workspace Settings.\n\nIn the settings search bar, type terminal.integrated.shell.windows (or whatever gets you far enough long)\nFind the setting in the actual settings file, use Edit (mouse over the line, it will be on the left: on a touch screen without a mouse, you should be able to simply tap to the left of the line), and select Replace in Settings\n\nIn the right pane, modify the entry created in the modified json file: replace the previous setting with\n\"C:\\\\WINDOWS\\\\Sysnative\\\\bash.exe\"\n\n\nOther IDEs: IntelliJ\nOpen Settings/Tools/Terminal and set the \"Shell path\" field to \"C:\\Users\\USERNAME\\AppData\\Local\\Microsoft\\WindowsApps\\ubuntu.exe\"\nMaking your WSL Ubuntu Bash Terminal functional for dev\nWhen you use CTRL+` to open the terminal, you should now have a bash terminal.\nIf this is the first time you have run bash.exe, you may be asked about installing Ubuntu. Do so. Once your installation is complete, choose your username and password to be used in WSL Ubuntu. These do not have to coincide with your current Windows account, and it's important to note that they will not change based on changes to your Windows account's password.\nOnce you are done, you will have a bash command prompt in your terminal.\nNote that unlike git-bash on Windows, this is a separate environment. While it can be used to launch Windows software outside of itself, you will need appropriate Ubuntu packages to run them within the actual terminal.\nCurrently, WSL does not come loaded with everything you might expect or be used to having, and some things can conflict with software you have loaded in Windows, based on default profile settings.\nUpdates & git\nNote: I'm going to document these as sudo for people who simply need single pieces of this, but one option at the start is to instead sudo su and simply running the following commands without sudo.\nMake sure your Ubuntu packages are up to date:\nsudo apt-get -y update\nsudo apt-get -y upgrade\nsudo apt-get -y dist-upgrade\nsudo apt autoremove\n\nInstall git:\nsudo apt-get install git\n\nNode.js & NPM\nIf you already have Node or NPM loaded in Windows, running them in Ubuntu can get problematic due to path issues. So, you need to install the Ubuntu native versions and ensure that they are used instead.\nFirst, install node.js with NPM.\n(alternate: install NVM and use it to install node.js)\nAfter installing, running npm commands will probably fail: for example, npm -v will probably give you:\n: not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm:\n: not foundram Files/nodejs/npm: 5: /mnt/c/Program Files/nodejs/npm:\n/mnt/c/Program Files/nodejs/npm: 6: /mnt/c/Program Files/nodejs/npm: Syntax error: word unexpected (expecting \"in\")\n\nThis is due to a pathing issue with a fairly straightforward solution. Using your favorite CLI editor (such as nano, vim, emacs, cat and sed… etc), open your ~/.profile\nnano ~/.profile\n\nNote: do NOT attempt to edit Linux files using Windows tools. (Thanks to @david-c-rankin's comment for the official link with the bold red text explaining this) If you don't want to use a CLI editor for this in the terminal, see the bottom of this post for a link on how to get a GUI one running.\nCurrently, the default bash PATH variable in WSL is\nPATH=\"$HOME/bin:$HOME/.local/bin:$PATH\"\n\nWhich is injecting the windows path after the first two binary directories. Unfortunately, this doesn't result in /usr/bin being used before the windows installed npm, so add that before the final $PATH:\nPATH=\"$HOME/bin:$HOME/.local/bin:/usr/bin:$PATH\"\n\nSave out, and then either reload the terminal or just source the path file\nsource ~/.profile\n\nBuild-essential\nIf you are using anything which requires compiling or otherwise uses make, it's almost guaranteed that you will need these installed; so if you did not install them while installing node.js, do so. It's much easier to simply use the build-essential package rather than try to install everything separately.\nNote that packages such as Compass which rely on Ruby FFI will fail without these. If you are having trouble properly installing and running a tool, making sure you have gcc and make installed can be a good place to start.\nsudo apt-get install -y build-essential\n\nRunning Tasks using Ubuntu\nNote that if you use VS Code's tasks.json to run build tasks, by default it will still run them using the Windows subsystem instead of the Ubuntu one. Sometimes this may be what you want, but if you've just finished installing grunt-cli in Ubuntu and not Windows, it's probably not.\nVS Code recently had the 2017 May update to how Tasks work that allows it to set the task runner as the terminal. This is by far the easiest way to migrate tasks over.\nSimply set\n\"runner\": \"terminal\",\n\nin your tasks.json and you're done (assuming you have all of the appropriate tools you are trying to run now installed in WSL Ubuntu).\nThis is very portable, ideally requiring no changes between systems which do or do not have WSL, or to other OSes, and is the method I would recommend.\nAs of the moment, this method spawns another TERMINAL tab instance (accessed from the drop down). You can still set up appropriate watchers, but it does mean that it's no longer sitting on the OUTPUT tab.\nThe old method is capable of invoking the WSL Ubunutu Bash shell and having it show up in OUTPUT, and involves either calling bash.exe with the -c argument or using a shell script. It unfortunately is not as semantic, since we are making bash our command and passing it what we want to run as an argument instead. This also means it is not as quickly portable to other systems.\nYou can use the same location you gave VS Code earlier for the terminal itself, C:\\\\WINDOWS\\\\Sysnative\\\\bash.exe as the value for command\nSet the first element of the args array as -c and the second as the command you want to run (credit to the second half of this answer).\nAlternatively, you can instead run a shell script as seen here.\nFurther helpful bits\nWant to start VSCode in Windows from the WSL Bash command line?\nWant to have a graphical interface for your WSL Ubuntu? (this will allow you to do things like use a Linux GUI editor for files within the Ubuntu system itself: do not edit them using Windows editing tools, see comments/note in section on npm)\nWant to build (see the above portion on setting up VS Code Tasks properly for WSL) and debug entirely within WSL Ubuntu? (this shows how to do so using gdb, but the pipeTransport concept could be used with other debuggers) (credit to this answer, but the one before it also provides a method using local loopback that could prove useful)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Error \"Your push would publish a private email address\"\n\nI'm very new to GitHub/VCS.\nWhen I try to share my project on GitHub, I get the following error message.\n Can't finish GitHub sharing process\n Successfully created project 'myproject' on GitHub, but initial push failed:\n remote: error: GH007: Your push would publish a private email address.\n failed to push some refs to 'https://github.com/me/myproject.git'\n\nI've googled the error message and got no hits. I've also searched Stack Exchange, but no cigar. How can I solve this issue?"
},
{
"role": "assistant",
"content": "When enabling the “Block command line pushes that expose my email” feature, you’ll also want to configure Git to use your no-reply email address. Don’t worry—this won’t affect your contribution graph. All commits will still be associated with your account.\n\nOpen Terminal.\n\nChange the current working directory to the local repository where you want to configure the email address that you associate with your Git commits.\n\nFind your GitHub noreply address in your GitHub's Personal Settings → Emails. It's mentioned in the description of the Keep my email address private checkbox. Usually, it starts with a unique identifier, plus your username.\n\nSet an email address in Git. Use your GitHub-provided no-reply email address.\n\nSetting your email address for every repository on your computer\n git config --global user.email \"{ID}+{username}@users.noreply.github.com\"\n\n\nSetting your email address for a single repository\n git config user.email \"{ID}+{username}@users.noreply.github.com\"\n\n\n\n\nReset the author information on your last commit:\ngit commit --amend --reset-author --no-edit\n\n\n\nIf you have multiple commits with your private e-mail address, see this answer.\n\nNow you can push the commit with the noreply e-mail address, and future commits will have the noreply e-mail address as well.\ngit push\n\n\n\nOnce you configure Git, commits will use your alternate “noreply” email address, and any pushes that don’t will be rejected."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git error \"fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree\"\nI'm trying to initialize a new Git repository from Debian (actually a VM on VirtualBox, installed and running on Mac OS X):\ncd ~\nmkdir test\ncd test\ngit init\n\nInitialized empty Git repository in /home/david/test/.git/\nfatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions\n\n[david@server-VM-001:test (master #) $]\n\nWhat's the problem?"
},
{
"role": "assistant",
"content": "I usually use Git on my Linux machine, but at work I have to use Windows. I had the same problem when trying to commit the first commit in a Windows environment.\nFor those still facing this problem, I was able to resolve it as follows:\ngit commit --allow-empty -n -m \"Initial commit.\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc git-diff-index --cached <tree-ish>"
},
{
"role": "assistant",
"content": "compares the <tree-ish> and the index."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "NPM: Missing dist and src directories when trying to install directly from a github url\n\nAn npm package I am using has been forked on github with some bug fixes and I now want to use the forked code in my project until the fork is merged.\nIn my package.json I change the reference in dependencies from e.g. \n“cool-package”: \"^0.10.0\"\nto “cool-package“: \"git://github.com/developer-who-forked/cool-package.git\" but this doesn’t work.\nIf I run npm install after updating the package.json and then go in to node_modules/cool-package/ I don’t see any /src folder or any /dist folder (all the other modules installed via normal npm seem to have at least a /dist folder).\nI only see an /example folder and a /test folder alongside a package.json and a README.md. If i’d installed the package by including “cool-package”: \"^0.10.0\" there would be the src/ and dist/ folders.\nThe forked repo, or the original repo it was forked from don’t have a /dist folder - it is actually in the .gitignore file. So I think I am missing some build step that is required to create the /dist files when trying to access github repos directly in the package.json."
},
{
"role": "assistant",
"content": "What worked for me was:\n\ncommiting /dist to gh\nrunning npm install {username}/{repo}.git instead of manually adding the record to package.json"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git squash older commits (not last one)\nI have a very messy git history. I want to squash a bunch of older commits (not including the last one).\nI know how to squash my last n commits. But this is different. Here I have commits consecutively n1 to n2 which I want to squash into one, while after n2 I have a history of commits that I want to preserve up to the last one.\nSo, if my current history looks like this:\n---- n1 --- n2 -------- m\n\nI want to squash n1 to n2 so it ends up looking like this:\n---- n1n2 -------- m\n\nwhere n1n2 is a single commit containing the squashed contents from n1 to n2.\nHow should I do this? What are the consequences on the history from n2 to m? \nThat is, will the hash of every commit from n2 to m change as a consequence of what I want to do?"
},
{
"role": "assistant",
"content": "You can do an interactive rebase, per the docs and this blog post.\n\nStart an interactive rebase:\ngit rebase -i HEAD~n\n\n(where n is how far do you want to go back in history)\nYour default editor will open. At the top, a list of your latest n commits will be displayed, in reverse order. Eg:\npick a5f4a0d commit-1\npick 19aab46 commit-2\npick 1733ea4 commit-3\npick 827a099 commit-4\npick 10c3f38 commit-5\npick d32d526 commit-6\n\nSpecify squash (or the shortcut s) for all commits you want to squash. E.g.:\npick a5f4a0d commit-1\npick 19aab46 commit-2\nsquash 1733ea4 commit-3\nsquash 827a099 commit-4\npick 10c3f38 commit-5\npick d32d526 commit-6\n\nGit applies both that change and the change directly before it and makes you merge the commit messages together.\nSave and exit. \nGit will apply all changes and will open again your editor to merge the three commit messages. You can modify your commit messages or leave it as it is (if so, the commit messages of all commits will be concatenated). \nYou're done! The commits you selected will all be squashed with the previous one."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to add an Android Studio project to GitHub [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do you synchronise projects to GitHub with Android Studio?\n\n (13 answers)\n \n\nClosed 6 years ago.\n\n\n\nI have a project in Android Studio. I want to add that project to a GitHub repository using android studio. How can I do that?"
},
{
"role": "assistant",
"content": "Sign up and create a GitHub account in www.github.com.\nDownload git from https://git-scm.com/downloads and install it in your system.\nOpen the project in android studio and go to File -> Settings -> Version Control -> Git.\nClick on test button to test \"path to Git executables\". If successful message is shown everything is ok, else navigate to git.exe from where you installed git and test again. \nGo to File -> Settings -> Version Control -> GitHub. Enter your email and password used to create GitHub account and click on OK button.\nThen go to VCS -> Import into Version Control -> Share Project on GitHub. Enter Repository name, Description and click Share button.\nIn the next window check all files inorder to add files for initial commit and click OK.\nNow the project will be uploaded to the GitHub repository and when uploading is finished we will get a message in android studio showing \"Successfully shared project on GitHub\". Click on the link provided in that message to go to GitHub repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index no"
},
{
"role": "assistant",
"content": "Moved lines are not highlighted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git commit get fatal error \"fatal: CRLF would be replaced by LF in\"\nI'm using Ubuntu 13.10 x64, and I am working on a project that some developers are using Windows , I recently changed the git config core.eol to \"lf\" and core.autocrlf to \"input\" and core.safecrlf to \"true\". Since then, when I try to commit file into my local repository, I get this error:\nfatal: CRLF would be replaced by LF in ......\nFrom what I understand, if I set core.eol to \"lf\" and core.autocrlf to \"input\", git will automatically convert CRLF to LF, but why this error come out? How can I fix this problem?\nThank you."
},
{
"role": "assistant",
"content": "This is a classic issue:\n\n(picture from Luis Tubes's blog post)\nThe usual fix is to convert those files yourself, with dos2unix or Swiss File Knife.\nI have always preferred to keep core.autocrlf to false, which means:\ngit config --global core.autocrlf false"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_DISCOVERY_ACROSS_FILESYSTEM"
},
{
"role": "assistant",
"content": "When run in a directory that does not have \".git\" repository\ndirectory, Git tries to find such a directory in the parent\ndirectories to find the top of the working tree, but by default it\ndoes not cross filesystem boundaries. This Boolean environment variable\ncan be set to true to tell Git not to stop at filesystem\nboundaries. Like GIT_CEILING_DIRECTORIES , this will not affect\nan explicit repository directory set via GIT_DIR or on the\ncommand line."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --ignore-cr-at-eol"
},
{
"role": "assistant",
"content": "Ignore carriage-return at the end of line when doing a comparison."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary top"
},
{
"role": "assistant",
"content": "The magic word top (magic signature: / ) makes the pattern\nmatch from the root of the working tree, even when you are\nrunning the command from inside a subdirectory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --default <arg>"
},
{
"role": "assistant",
"content": "If there is no parameter given by the user, use <arg> instead."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does the term \"porcelain\" mean in Git?\nThe term \"porcelain\" appears occasionally in the Git documentation. What does it mean?"
},
{
"role": "assistant",
"content": "\"Porcelain\" is the material from which toilets are usually made (and sometimes other fixtures such as washbasins). This is distinct from \"plumbing\" (the actual pipes and drains), where the porcelain provides a more user-friendly interface to the plumbing.\nGit uses this terminology in analogy, to separate the low-level commands that users don't usually need to use directly (the \"plumbing\") from the more user-friendly high level commands (the \"porcelain\")."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-grep - Print lines matching a pattern -c --count"
},
{
"role": "assistant",
"content": "Instead of showing every matched line, show the number of\nlines that match."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together"
},
{
"role": "assistant",
"content": "DESCRIPTION Incorporates changes from the named commits (since the time their\nhistories diverged from the current branch) into the current\nbranch. This command is used by git pull to incorporate changes\nfrom another repository and can be used by hand to merge changes\nfrom one branch into another. Assume the following history exists and the current branch is master : A---B---C topic\n\t /\n D---E---F---G master Then git merge topic will replay the changes made on the topic branch since it diverged from master (i.e., E ) until\nits current commit ( C ) on top of master , and record the result\nin a new commit along with the names of the two parent commits and\na log message from the user describing the changes. Before the operation, ORIG_HEAD is set to the tip of the current branch ( C ). A---B---C topic\n\t / \\\n D---E---F---G---H master A merge stops if there’s a conflict that cannot be resolved\nautomatically or if --no-commit was provided when initiating the\nmerge. At that point you can run git merge --abort or git merge\n--continue . git merge --abort will abort the merge process and try to reconstruct\nthe pre-merge state. However, if there were uncommitted changes when the\nmerge started (and especially if those changes were further modified\nafter the merge was started), git merge --abort will in some cases be\nunable to reconstruct the original (pre-merge) changes. Therefore: Warning : Running git merge with non-trivial uncommitted changes is\ndiscouraged: while possible, it may leave you in a state that is hard to\nback out of in the case of a conflict."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Force bundle install to use https:// instead of git:// for GitHub-based gems\n\nI am trying to build a rails project and because the host I am working on doesn't have access to the Internet for the the git:// protocol (port 9418) I get errors like\nFetching git://github.com/pivotal/jasmine.git\nfatal: unable to connect to github.com:\ngithub.com[0: 192.30.252.130]: errno=Connection refused\n\nwhen running bundle install.\nThe relevant line in the GemFile doesn't specify git:// as a protocol, it just points to GitHub as the source for the gem\ngem 'jasmine', :github => 'pivotal/jasmine-gem'\n\nWhat do I have to do to make bundler to use https:// rather than git:// for pulling gems from GitHub?\nEdit:\nIs there a way other than editing every affected line in the GemFile? I'd prefer to avoid any merging issues down the line if the project's GemFile is updated."
},
{
"role": "assistant",
"content": "Use bundle config github.https true"
}
] |
[
{
"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": "Generating patch text with -p Running git-diff , git-log , git-show , git-diff-index , git-diff-tree , or git-diff-files with the -p option produces patch text.\nYou can customize the creation of patch text via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables\n(see git ), and the diff attribute (see gitattributes ). What the -p option produces is slightly different from the traditional\ndiff format: It is preceded by a \"git diff\" header that looks like this: diff --git a/file1 b/file2 The a/ and b/ filenames are the same unless rename/copy is\ninvolved. Especially, even for a creation or a deletion, /dev/null is not used in place of the a/ or b/ filenames. When a rename/copy is involved, file1 and file2 show the\nname of the source file of the rename/copy and the name of\nthe file that the rename/copy produces, respectively. It is followed by one or more extended header lines: old mode <mode>\nnew mode <mode>\ndeleted file mode <mode>\nnew file mode <mode>\ncopy from <path>\ncopy to <path>\nrename from <path>\nrename to <path>\nsimilarity index <number>\ndissimilarity index <number>\nindex <hash>..<hash> <mode> File modes are printed as 6-digit octal numbers including the file type\nand file permission bits. Path names in extended headers do not include the a/ and b/ prefixes. The similarity index is the percentage of unchanged lines, and\nthe dissimilarity index is the percentage of changed lines. It\nis a rounded down integer, followed by a percent sign. The\nsimilarity index value of 100% is thus reserved for two equal\nfiles, while 100% dissimilarity means that no line from the old\nfile made it into the new one. The index line includes the blob object names before and after the change.\nThe <mode> is included if the file mode does not change; otherwise,\nseparate lines indicate the old and the new mode. Pathnames with \"unusual\" characters are quoted as explained for\nthe configuration variable core.quotePath (see git-config ). All the file1 files in the output refer to files before the\ncommit, and all the file2 files refer to files after the commit.\nIt is incorrect to apply each change to each file sequentially. For\nexample, this patch will swap a and b: diff --git a/a b/b\nrename from a\nrename to b\ndiff --git a/b b/a\nrename from b\nrename to a Hunk headers mention the name of the function to which the hunk\napplies. See \"Defining a custom hunk-header\" in gitattributes for details of how to tailor this to\nspecific languages."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git cancel a revert\nIn git let say I commit A and B\nA---[B]\n\nBut then I revert with\ngit revert HEAD\n\nSo I am there now:\n[A]---B\n\nHow do I cancel my revert so that I can go back to B?"
},
{
"role": "assistant",
"content": "You have two general choices:\n\nRevert the revert commit (creating a second revert commit that takes you back to the original)\nThrow away the revert commit with \n\n\ngit reset --hard HEAD^\n\nThe second option is only appropriate if you have not pushed your changes anywhere else. In fact, if you haven't pushed your first revert commit anywhere yet, you can simply use\n\ngit reset --hard\n\nto roll back without creating any revert commits at all."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Jenkins pipeline for merge request in Gitlab\n\nI've started lately to use Jenkins and i need some help with creating a pipeline.\nI want to create the following pipeline:\nFor each merge request from develop to master in Gitlab, Trigger a Jenkins job that run an end-to-end test, And merge the branches in Gitlab only if the test succeeded.\nI have found the following article that gives me an explanation for most of the things that i need:\nhttps://vetlugin.wordpress.com/2017/01/31/guide-jenkins-pipeline-merge-requests/\nI'm still looking for an answer for one question:\nHow can Jenkins response to Gitlab with the result of the end-to-end test (Success/Fail), So Gitlab will know whether to merge to branches or not?\nPlease advise,\nThanks!"
},
{
"role": "assistant",
"content": "You do not tell us how Gitlab and Jenkins are connected, but I'll assume you use the Jenkins Gitlab plugin https://github.com/jenkinsci/gitlab-plugin. If you're not, maybe you should :)\nWith this plugin, you can 'integrate' more deeply Jenkins and Gitlab, and your Jenkins builds will send back to Gitlab the result of the build. You will see something like this https://raw.githubusercontent.com/teeks99/gitlab-plugin-wiki-images/master/Setup_Example_img/Result_commit.png. Build results are marked near the commit which has been tested.\nIn this case, for each merge request, you can check the \"Merge if build succeed\" button (see https://raw.githubusercontent.com/teeks99/gitlab-plugin-wiki-images/master/Setup_Example_img/Merge_progress.png) to auto merge the code when build is successful.\nLook at the Jenkins Gitlab plugin README for more information and advanced setup, like test in your build the result of the merge, etc."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options http.sslKey"
},
{
"role": "assistant",
"content": "File containing the SSL private key when fetching or pushing\nover HTTPS. Can be overridden by the GIT_SSL_KEY environment\nvariable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Using GitHub Actions to automatically update the repo's submodules\n\nTitle says it all. I tried using a bunch of different git commands like git submodule update --remote --merge and git submodule foreach git pull origin master which work fine on my computer, but not when it's run on GitHub actions.\nI tried adding git status to the workflow and the status just shows \"Up to date with origin/master, nothing to commit\" or something like that."
},
{
"role": "assistant",
"content": "If you need to auto update references to your submodules via GitHub actions:\nCreate a new workflow in your parent repository that will synchronize references:\nname: 'Submodules Sync'\n\non:\n # Allows you to run this workflow manually from the Actions tab or through HTTP API\n workflow_dispatch:\n\njobs:\n sync:\n name: 'Submodules Sync'\n runs-on: ubuntu-latest\n\n # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest\n defaults:\n run:\n shell: bash\n\n steps:\n # Checkout the repository to the GitHub Actions runner\n - name: Checkout\n uses: actions/checkout@v2\n with:\n token: ${{ secrets.CI_TOKEN }}\n submodules: true\n\n # Update references\n - name: Git Submodule Update\n run: |\n git pull --recurse-submodules\n git submodule update --remote --recursive\n\n - name: Commit update\n run: |\n git config --global user.name 'Git bot'\n git config --global user.email '[email protected]'\n git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}\n git commit -am \"Auto updated submodule references\" && git push || echo \"No changes to commit\"\n\nwhere\n\nCI_TOKEN is a security token variable in GitHub that have 'Read-Write' access to the parent repository, and 'Read' access to submodule repositories.\n\n\nIn the child (submodule) GitHub action notify the parent about changes.\nname: 'Submodule Notify Parent'\n\non:\n push:\n branches:\n - main \n\n # Allows you to run this workflow manually from the Actions tab\n workflow_dispatch:\n\njobs:\n notify:\n name: 'Submodule Notify Parent'\n runs-on: ubuntu-latest\n\n # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest\n defaults:\n run:\n shell: bash\n\n steps:\n - name: Github REST API Call\n env:\n CI_TOKEN: ${{ secrets.CI_TOKEN }}\n PARENT_REPO: <my_organization/my-app>\n PARENT_BRANCH: develop\n WORKFLOW_ID: <9999999>\n run: |\n curl -fL --retry 3 -X POST -H \"Accept: application/vnd.github.v3+json\" -H \"Authorization: token ${{ env.CI_TOKEN }}\" https://api.github.com/repos/${{ env.PARENT_REPO }}/actions/workflows/${{ env.WORKFLOW_ID }}/dispatches -d '{\"ref\":\"${{ env.PARENT_BRANCH }}\"}'\n\nwhere\n\nPARENT_REPO - name of the parent repository as it is in Github (my_org/my_app or just my_app if there is no organization).\nWORKFLOW_ID - parent Wofklow ID to call via rest API. To find it run curl using your CI_TOKEN:\ncurl -X GET -H \"Authorization: token $CI_TOKEN\" https://api.github.com/repos/$PARENT_REPO/actions/workflows\n\n\n\nRepeat the workflow creation for every submodule.\n\nP.S. For me it works very stable. Please add information about existing github actions with the above logic if there is any."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-am - Apply a series of patches from a mailbox -u --utf8"
},
{
"role": "assistant",
"content": "Pass -u flag to git mailinfo (see git-mailinfo ).\nThe proposed commit log message taken from the e-mail\nis re-coded into UTF-8 encoding (configuration variable i18n.commitEncoding can be used to specify the project’s\npreferred encoding if it is not UTF-8). This was optional in prior versions of git, but now it is the\ndefault. You can use --no-utf8 to override this."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Creation of Merge Request in GitLab fails\n\nI migrated my existing sources from Microsoft SourceSafe to GitLab.\nNow I have two branches master and release.\nI created a third branch feature off master and committed and pushed this branch.\nAfterwards, I created a new merge request, which got accepted and merged feature into master without conflicts. Now I want to cherry-pick this merge request into release which is 15 commits behind and 12 commits ahead to master.\nWhen creating this merge request, I get an error saying \"Sorry, we cannot cherry-pick this merge request automatically.\nThis merge request may already have been cherry-picked, or a more recent commit may have updated some of its content.\" and no merge request is created. This merge request isn't already cherry-picked as it is the first cherry pick ever in this repository and there also isn't a more recent commit that updated this file.\nAdditionally, GitLab won't show any entries related to my error in the internal log.\n\nI want GitLab to create a merge request and let me resolve possible conflicts in the web interface. Is this possible?"
},
{
"role": "assistant",
"content": "Usually in this case, create a new branch for your release, cherry pick to that branch, and then push that up as a separate merge request.\nThat's how we handle our release process when our release and main diverge from each other. It gets really obvious when I go on one of my refactoring sprees minutes after we branch off release. :D\nBecause of how Git works and the acyclic graph, you can't just reuse a commit, you basically have to manually create an identical one and push them up since the previous commits of release differ than master."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together -m <msg>"
},
{
"role": "assistant",
"content": "Set the commit message to be used for the merge commit (in\ncase one is created). If --log is specified, a shortlog of the commits being merged\nwill be appended to the specified message. The git fmt-merge-msg command can be\nused to give a good default for automated git merge invocations. The automated message can include the branch description."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github Actions - No Such File or Directory on Any Run Step\n\nI am trying to test out Github Actions for a small web project. I have two projects in the repository, and I want to create a deployment script for only the web client.\nThe repository looks like this:\nroot\n|\n|-src\n| |-API\n| |\n| |-WebClient\n|\n|-docs\n\nI want to run scripts in the WebClient directory. When I try to cd into ./src/webclient, I get the error no such file or directory\nname: CI\n\non:\n push:\n branches: [ master ]\n pull_request:\n branches: [ master ]\n\njobs:\n build:\n runs-on: ubuntu-latest\n\n steps:\n - uses: actions/checkout@v2\n - name: Setup Node.js environment\n uses: actions/[email protected]\n \n - name: Open Web Client Directory\n run: |\n ls -la\n cd ./src/webclient\n ls -la\n \n - name: Run a multi-line script\n run: |\n echo Add other actions to build,\n echo test, and deploy your project.\n ls -la\n\n\nThe output for the \"Open Web Client Directory\" step:\ntotal 28\ndrwxr-xr-x 5 runner docker 4096 Oct 17 18:05 .\ndrwxr-xr-x 3 runner docker 4096 Oct 17 18:05 ..\ndrwxr-xr-x 8 runner docker 4096 Oct 17 18:05 .git\ndrwxr-xr-x 3 runner docker 4096 Oct 17 18:05 .github\n-rw-r--r-- 1 runner docker 6215 Oct 17 18:05 .gitignore\ndrwxr-xr-x 4 runner docker 4096 Oct 17 18:05 src\n/home/runner/work/_temp/43164e53-98ec-41c2-8773-72e94c3453e5.sh: line 2: cd: ./src/webclient: No such file or directory\nError: Process completed with exit code 1.\n\nIt looks to be successfully doing the ls -la command, but fails to find the directory ./src/webclient.\nIs there something obvious that I am missing? I have tried changing the command to cd src/webclient, and it fails also. This works on two different local machines, one ubuntu and one MacOS."
},
{
"role": "assistant",
"content": "I had an issue where a step was failing with the following, no matter how I configured it:\n\nError: No such file or directory\n\nTurns out this was because I had not checked out the repository in a previous step!\nIf you are accessing files from the repo, you need to perform a checkout first:\nsteps:\n - uses: actions/checkout@v2"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Error with git rebase (\"could not apply...\")\n\nI'm the administrator of the GitHub repository https://github.com/plison/opendial. I would like to reduce the number of commits on the repository, since the repository already has a few thousand commits, many of whom are minor debugging changes that could easily be squashed together (especially the ones that are a few years old).\nI'm therefore trying to apply rebasing in order to squash together part of my commits. However, I've experience the following issue:\n\nWhen I type e.g. git rebase -i HEAD~10, I get a quite long number of commit lines (much more than 10) in the interactive editor. What could be the reason?\nMore importantly, once I close the interactive editor to start the rebasing, I systematically get the error message \"error:could not apply ', even when I do not make any change to the commits (i.e. if I leave all lines as 'pick', without any modification or reordering).\n\nHow can I solve these issues? It should be noted that the repository was automatically imported from a previous (SVN) repository hosted on Google Code. The conversion seemed so far to have worked well, but I'm wondering why I get these errors when trying to rebase my commits."
},
{
"role": "assistant",
"content": "As a reminder to myself on how to resolve this:\nThe error message is not very informative. If you type \ngit rebase --continue\n\nyou realize the error is because of a merge conflict that git cannot resolve by itself, and needs your help.\nTo see what files have conflicts, type\ngit status\n\nResolve the merge conflicts in your favorite editor/IDE (hint: this should start with i and end with ntelliJ)\nMark resolution with \ngit add .\n\nIf all the conflicts are resolved, you should see something like this:\n(all conflicts fixed: run \"git rebase --continue\")\n\nSo continue your rebase with \ngit rebase --continue\n\nHopefully your rebase should now be successful\ngit status\n\nshows:\nOn branch feature/DIG-19302-Upgrade-mockito-v2\nYour branch is behind 'origin/feature/your-feature-branch' by 2 commits, and can be fast-forwarded.\n(use \"git pull\" to update your local branch)\n\nnothing to commit, working directory clean\n\nDon't do a git pull. If you do, you will only overwrite your merge conflicts. Instead push your merge conflict resolutions to the branch) with \ngit push --force\n\nYou're done! Your git log should show only 1 commit now (which is the forced update you just did)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What do I need to read to understand how git works? [closed]\nAs it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.\n \n \n\n\n\nClosed 11 years ago.\n\n\n\nI would like to understand the way git works from a architects point of view. How are files stored, how are versions kept and how do changes happen (branches, merges, etc.)?\nI am not searching for information how to use it. (I already found a lot of pages with tutorials.) But I did not find any \"behind the scenes\" details, that would make me understand."
},
{
"role": "assistant",
"content": "http://eagain.net/articles/git-for-computer-scientists/\nhttp://www.loria.fr/~molli/pmwiki/uploads/Main/gitmanual.pdf\nChap 7\nGit From the Bottom Up"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I delete a remote tag?\nHow can I delete a Git tag that has already been pushed?"
},
{
"role": "assistant",
"content": "You can push an 'empty' reference to the remote tag name:\ngit push origin :tagname\n\nOr, more expressively, use the --delete option (or -d if your git version is older than 1.8.0):\ngit push --delete origin tagname\n\nNote that git has tag namespace and branch namespace so you may use the same name for a branch and for a tag. If you want to make sure that you cannot accidentally remove the branch instead of the tag, you can specify full ref which will never delete a branch:\ngit push origin :refs/tags/tagname\n\nIf you also need to delete the local tag, use:\ngit tag --delete tagname\n\n\nBackground\nPushing a branch, tag, or other ref to a remote repository involves specifying \"which repo, what source, what destination?\"\ngit push remote-repo source-ref:destination-ref\n\nA real world example where you push your master branch to the origin's master branch is:\ngit push origin refs/heads/master:refs/heads/master\n\nWhich because of default paths, can be shortened to:\ngit push origin master:master\n\nTags work the same way:\ngit push origin refs/tags/release-1.0:refs/tags/release-1.0\n\nWhich can also be shortened to:\ngit push origin release-1.0:release-1.0\n\nBy omitting the source ref (the part before the colon), you push 'nothing' to the destination, deleting the ref on the remote end."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I clean my .git folder? Cleaned up my project directory, but .git is still massive\nThe .git/objects in my rails project directory is still massive, after deleting hundreds of Megabytes of accidentally generated garbage. \nI have tried git add -A, as well as other commands to update the index and remove nonexistent files. I gather, perhaps incorrectly, that the files with two character names in the directory are blobs. I have tried rolling back to previous commits, but no luck. \nWhat can I do to clean this directory?"
},
{
"role": "assistant",
"content": "If you added the files and then removed them, the blobs still exist but are dangling. git fsck will list unreachable blobs, and git prune will delete them.\nIf you added the files, committed them, and then rolled back with git reset --hard HEAD^, they’re stuck a little deeper. git fsck will not list any dangling commits or blobs, because your branch’s reflog is holding onto them. Here’s one way to ensure that only objects which are in your history proper will remain:\ngit reflog expire --expire=now --all\ngit repack -ad # Remove dangling objects from packfiles\ngit prune # Remove dangling loose objects\n\nAnother way is also to clone the repository, as that will only carry the objects which are reachable. However, if the dangling objects got packed (and if you performed many operations, git may well have packed automatically), then a local clone will carry the entire packfile:\ngit clone foo bar # bad\ngit clone --no-hardlinks foo bar # also bad\n\nYou must specify a protocol to force git to compute a new pack:\ngit clone file://foo bar # good"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is difference between 'git reset --hard HEAD~1' and 'git reset --soft HEAD~1'?\nI tried to undo my commit in git.\nIs it dangerous to use git reset --hard HEAD~1?\nWhat is the difference between different options for git reset?\nNote: while HEAD is the current/latest commit,\nHEAD~1 is the commit right before HEAD."
},
{
"role": "assistant",
"content": "git reset does know five \"modes\": soft, mixed, hard, merge and keep. I will start with the first three, since these are the modes you'll usually encounter. After that you'll find a nice little a bonus, so stay tuned.\n\nLet's assume you have a repository with a history akin to this:\n7e05a95 (HEAD -> main) Update a\ne62add5 Update b\nca9ae0a Update a\n9b6060d Add c\neebe372 Add b\n947586a Add a\n\nWhere the latest commit (7e05a95) contains these changes:\ndiff --git a/a b/a\nindex b66ba06..28b68e2 100644\n--- a/a\n+++ b/a\n@@ -1 +1 @@\n-new content\n+new new content\n\nNow what would happen when you run git reset with the various different modes? Let's find out!\nsoft\nWhen using git reset --soft HEAD~1 you will remove the last commit from the current branch, but the file changes will stay in your working tree. Also, the changes will stay on your index, so following with a git commit will create a commit with the exact same changes as the commit you \"removed\" before.\nHow would this look like in practice? Like this:\n> git reset --soft HEAD^ # Assuming HEAD points at 7e05a95\n> git status\nOn branch main\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n modified: a\n\nAs you see the changes in file a are on the index, and ready to be committed again.\nmixed\nThis is the default mode and quite similar to soft. When \"removing\" a commit with git reset HEAD~1 you will still keep the changes in your working tree but not on the index; so if you want to \"redo\" the commit, you will have to add the changes (git add) before commiting.\nIn practice the result might look like this:\n> git reset --mixed HEAD^ # Assuming HEAD points at 7e05a95\n> git status\nOn branch main\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git restore <file>...\" to discard changes in working directory)\n modified: a\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nThe changes of file a are still there but they're not on the index.\nhard\nWhen using git reset --hard HEAD~1 you will lose all uncommited changes and all untracked files in addition to the changes introduced in the last commit. The changes won't stay in your working tree so doing a git status command will tell you that you don't have any changes in your repository.\nTread carefully with this one. If you accidentally remove uncommited changes which were never tracked by git (speak: committed or at least added to the index), you have no way of getting them back using git.\nA practical example might look like this:\n> git reset --hard HEAD^ # Assuming HEAD points at 7e05a95\n> git status\nOn branch main\nnothing to commit, working tree clean\n\nAs you can see, no changes remain. Assuming you also had some uncommitted changes in the file b these would be lost too!\n> echo 'some uncommitted changes' > b\n> git status\nOn branch main\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git restore <file>...\" to discard changes in working directory)\n modified: b\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n> git reset --hard HEAD^ # Assuming HEAD points at 7e05a95\n> git status\nOn branch main\nnothing to commit, working tree clean\n\nBonus\nkeep\ngit reset --keep HEAD~1 is an interesting and useful one. It only resets the files which are different between the current HEAD and the given commit. It aborts the reset if one or more of these files has uncommited changes. It basically acts as a safer version of hard.\nLet's revisit the example from before, where you had some uncommitted changes in b:\n> echo 'some uncommitted changes' > b\n> git status\nOn branch main\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git restore <file>...\" to discard changes in working directory)\n modified: b\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n> git reset --keep HEAD^ # Assuming HEAD points at 7e05a95\n> git status\nOn branch main\nChanges not staged for commit:\n (use \"git add <file>...\" to update what will be committed)\n (use \"git restore <file>...\" to discard changes in working directory)\n modified: b\n\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nYou removed the changes in file a but retained the uncommitted changes in file b!\nSo to reiterate: \"hard\" will remove all changes while \"keep\" only removes changes from the reset commit(s).\n\nEach of these modes is explained in depths in the git reset documentation.\nNote\nWhen doing git reset to remove a commit the commit isn't really lost, there just is no reference pointing to it or any of it's children. You can still recover a commit which was \"deleted\" with git reset by finding it's SHA-1 key, for example with a command such as git reflog."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clone - Clone a repository into a new directory -s --shared"
},
{
"role": "assistant",
"content": "When the repository to clone is on the local machine,\ninstead of using hard links, automatically setup .git/objects/info/alternates to share the objects\nwith the source repository. The resulting repository\nstarts out without any object of its own. NOTE : this is a possibly dangerous operation; do not use\nit unless you understand what it does. If you clone your\nrepository using this option and then delete branches (or use any\nother Git command that makes any existing commit unreferenced) in the\nsource repository, some objects may become unreferenced (or dangling).\nThese objects may be removed by normal Git operations (such as git commit )\nwhich automatically call git maintenance run --auto . (See git-maintenance .) If these objects are removed and were referenced\nby the cloned repository, then the cloned repository will become corrupt. Note that running git repack without the --local option in a repository\ncloned with --shared will copy objects from the source repository into a pack\nin the cloned repository, removing the disk space savings of clone --shared .\nIt is safe, however, to run git gc , which uses the --local option by\ndefault. If you want to break the dependency of a repository cloned with --shared on\nits source repository, you can simply run git repack -a to copy all\nobjects from the source repository into a pack in the cloned repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options rebase.abbreviateCommands"
},
{
"role": "assistant",
"content": "If set to true, git rebase will use abbreviated command names in the\ntodo list resulting in something like this: p deadbee The oneline of the commit\n\tp fa1afe1 The oneline of the next commit\n\t... instead of: pick deadbee The oneline of the commit\n\tpick fa1afe1 The oneline of the next commit\n\t... Defaults to false."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git stash blunder: git stash pop and ended up with merge conflicts\nI did a git stash pop and ended up with merge conflicts. I removed the files from the file system and did a git checkout as shown below, but it thinks the files are still unmerged. I then tried replacing the files and doing a git checkout again and same result. I event tried forcing it with -f flag. Any help would be appreciated!\nchirag-patels-macbook-pro:haloror patelc75$ git status\napp/views/layouts/_choose_patient.html.erb: needs merge\napp/views/layouts/_links.html.erb: needs merge\n# On branch prod-temp\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# modified: db/schema.rb\n#\n# Changed but not updated:\n# (use \"git add <file>...\" to update what will be committed)\n# (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n# unmerged: app/views/layouts/_choose_patient.html.erb\n# unmerged: app/views/layouts/_links.html.erb\n\nchirag-patels-macbook-pro:haloror patelc75$ git checkout app/views/layouts/_choose_patient.html.erb\nerror: path 'app/views/layouts/_choose_patient.html.erb' is unmerged\nchirag-patels-macbook-pro:haloror patelc75$ git checkout -f app/views/layouts/_choose_patient.html.erb\nwarning: path 'app/views/layouts/_choose_patient.html.erb' is unmerged"
},
{
"role": "assistant",
"content": "See man git merge (HOW TO RESOLVE CONFLICTS):\n\nAfter seeing a conflict, you can do two things:\n\nDecide not to merge. The only clean-ups you need are to reset the index file to the HEAD commit to reverse 2. and to clean up working tree changes made by 2. and 3.; git-reset --hard can be used for this.\n\nResolve the conflicts. Git will mark the conflicts in the working tree. Edit the files into shape and git add them to the index. Use git commit to seal the deal.\n\n\n\nAnd under TRUE MERGE (to see what 2. and 3. refers to):\n\nWhen it is not obvious how to reconcile the changes, the following happens:\n\nThe HEAD pointer stays the same.\n\nThe MERGE_HEAD ref is set to point to the other branch head.\n\nPaths that merged cleanly are updated both in the index file and in your working tree.\n\n...\n\n\n\nSo: use git reset --hard if you want to remove the stash changes from your working tree, or git reset if you want to just clean up the index and leave the conflicts in your working tree to merge by hand.\nUnder man git stash (OPTIONS, pop) you can read in addition:\n\nApplying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Delete multiple remote branches in git\nI have a team member who inadvertently pushed over 150 of his local branches to our central repo. Thankfully, they all have the same prefix.\nUsing that prefix, is there a git command or cool little shell script I can use that will delete all of those at once?"
},
{
"role": "assistant",
"content": "Use the following command to remove all branches with PREFIX prefix on remote server.\ngit branch -r | awk -F/ '/\\/PREFIX/{print $2}' | xargs -I {} git push origin :{}\n\nYou may want to do a dry-run first to see if it is the branches that you want to remove:\ngit branch -r | awk -F/ '/\\/PREFIX/{print $2}'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %f"
},
{
"role": "assistant",
"content": "sanitized subject line, suitable for a filename"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What are the differences between 'revert', 'amend,' 'rollback', and 'undo' a commit?\nTo help in my knowledge of git so I can use it day to day, what is the difference between:\n\nrevert\namend\nrollback\nundo\n\nWhat are they and what do they do?"
},
{
"role": "assistant",
"content": "The terms revert and amend have a well-defined meaning in Git. In contrast, rollback and undo do not have such a well-defined meaning, and are open to interpretation.\nReverting a commit...\n...means creating (on the current branch) a new commit that applies the inverse changes that another commit introduced. It's the preferred approach for correcting a problem in a repo that has already been shared with others, because it doesn't involve any destruction (i.e. rewriting history).\nTo revert a commit identified by <commit>, simply run\ngit revert <commit>\n\nAmending a commit...\n...means replacing the \"current\" commit by a new one that has the same parent(s); more details in How does git commit --amend work, exactly?\n\nBe aware that\n\namending a commit that you've already pushed to a shared remote is bad practice, because it's a form of history rewriting (it \"deletes\" the most recent commit, which your collaborators may have already based their work on);\nyou can only amend the last commit on a given branch; to rewrite older commits, you need to bring out the big guns (e.g. interactive rebase).\n\nTo amend a commit, make all the required changes and stage them, then run\ngit commit --amend\n\nNo need to specify any commit, here, because the last commit on the current branch is the one that will be amended. Your editor will then pop up, giving you the opportunity to modify the commit message.\nRolling back...\n...usually means discarding (or stashing) any local changes and resetting the branch to a commit (or simply checking out a commit, but that puts you in detached-HEAD state) prior to commit one where things started to get messed up. Use\ngit reset <commit-before-things-started-to-go-belly-up>\n\nUndo a commit...\n...can mean, depending on the context,\n\nrevert a commit,\namend a commit,\nremove a commit via an interactive rebase."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --log-size"
},
{
"role": "assistant",
"content": "Include a line “log size <number>” in the output for each commit,\nwhere <number> is the length of that commit’s message in bytes.\nIntended to speed up tools that read log messages from git log output by allowing them to allocate space in advance."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.