messages listlengths 3 3 |
|---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-svn - Bidirectional operation between a Subversion repository and Git svn.useSvnsyncProps svn-remote.<name>.useSvnsyncprops"
},
{
"role": "assistant",
"content": "Similar to the useSvmProps option; this is for users\nof the svnsync(1) command distributed with SVN 1.4.x and\nlater."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitnamespaces"
},
{
"role": "assistant",
"content": "Git namespaces"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Recover from losing uncommitted changes by \"git reset --hard\"\nIs there any way to recover uncommitted changes to the working directory from a git reset --hard HEAD?"
},
{
"role": "assistant",
"content": "For previously committed changes (answer from this SO):\n$ git reflog show\n\n4b6cf8e (HEAD -> master, origin/master, origin/HEAD) HEAD@{0}: reset: moving to origin/master\n295f07d HEAD@{1}: pull: Merge made by the 'recursive' strategy.\n7c49ec7 HEAD@{2}: commit: restore dependencies to the User model\nfa57f59 HEAD@{3}: commit: restore dependencies to the Profile model\n3431936 HEAD@{4}: commit (amend): restore admin\n033f5c0 HEAD@{5}: commit: restore admin\necd2c1d HEAD@{6}: commit: re-enable settings app\n\n# assuming you want to get back to 7c49ec7 (restore dependencies to the User model)\n\n$ git reset HEAD@{2}"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index --color-moved-ws=<modes>"
},
{
"role": "assistant",
"content": "This configures how whitespace is ignored when performing the\nmove detection for --color-moved .\nThese modes can be given as a comma separated list: no Do not ignore whitespace when performing move detection. ignore-space-at-eol Ignore changes in whitespace at EOL. ignore-space-change Ignore changes in amount of whitespace. This ignores whitespace\nat line end, and considers all other sequences of one or\nmore whitespace characters to be equivalent. ignore-all-space Ignore whitespace when comparing lines. This ignores differences\neven if one line has whitespace where the other line has none. allow-indentation-change Initially ignore any whitespace in the move detection, then\ngroup the moved code blocks only into a block if the change in\nwhitespace is the same per line. This is incompatible with the\nother modes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules custom command"
},
{
"role": "assistant",
"content": "mechanism for running arbitrary commands with the\ncommit ID as an argument. Specifically, if the submodule.<name>.update configuration variable is set to !custom command , the object name of the commit recorded in the\nsuperproject for the submodule is appended to the custom command string and executed. Note that this mechanism is not supported in\nthe .gitmodules file or on the command line."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch -q --quiet"
},
{
"role": "assistant",
"content": "This is passed to both underlying git-fetch to squelch reporting of\nduring transfer, and underlying git-merge to squelch output during\nmerging."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %<( <N> [,trunc|ltrunc|mtrunc])"
},
{
"role": "assistant",
"content": "make the next placeholder take at\nleast N column widths, padding spaces on\nthe right if necessary. Optionally\ntruncate (with ellipsis .. ) at the left (ltrunc) ..ft ,\nthe middle (mtrunc) mi..le , or the end\n(trunc) rig.. , if the output is longer than\nN columns.\nNote 1: that truncating\nonly works correctly with N >= 2.\nNote 2: spaces around the N and M (see below)\nvalues are optional.\nNote 3: Emojis and other wide characters\nwill take two display columns, which may\nover-run column boundaries.\nNote 4: decomposed character combining marks\nmay be misplaced at padding boundaries."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to render a Jekyll markdown page on sites index\n\nI'm probably missing something simple but I have no way to test Jekyll locally.\nI'm using GitHub pages to render Jekyll, for starters I only want to render markdown content on the main index.html from one markdown page.\nThe structure is: \nIndex.html\n---\nlayout: default\n---\n\n_layouts\n - default.html\n//html stuff..\n<section>\n\n{{page.content}}\n\n</section>\n\nIn root folder I have a page called content.md that I wish to render for {{page.content}} the layout renders but the liquid tags section is blank.\nHow do I render content.md?\nExample: https://github.com/wycks/wordpress-gears-jekyll"
},
{
"role": "assistant",
"content": "There are a few things going on here. \n\nIn your _layouts/default.html file (and any of the other _layouts directory files for that matter), instead of:\n{{ page.content }}\n\nyou need to use:\n{{ content }}\n\nJekyll only lets you includes files from a site root level _includes directory. So, you need to move your content.md from the root to that directory (making it if it doesn't already exist). \nFinally, you need to actually make the call to the include file from your index.html file. This can be done by changing the content of your index.html file to:\n---\nlayout: default\n---\n\n{% include content.md %}\n\n\nThat will setup the behavior you are looking for. \n\nI'd point out two other things:\n\nYou may find that changing the extension of your index file from .html to .md works better. An important note though: you need to use .html if you want pagination. Per the Jekyll Pagination documentation, that feature only works when the file is named index.html.\nIf all you are doing in your index file is calling an include that only resides on that page, you might be just as well off simply putting the content directly in the index file."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to integrate sourcetree for gitlab\n\nI worked on github and integrated it to sourcetree (MAC version) for one of my project. I would like to use sourcetree for GITLAB. But I am not able to add remote of gitlab to source tree. In Repository settings, Only I can see host type as \"unknown\", \"bitbucket\", \"github\" & \"stash\". I used unknown but it won't help me.\nSourcetree Version 2.0.4 (2.0.4)"
},
{
"role": "assistant",
"content": "This worked for me,\nStep 1: Click on + New Repository> Clone from URL\nStep 2: In Source URL provide URL followed by your user name,\nExample:\n\nGitLab Repo URL : http://git.zaid-labs.info/zaid/iosapp.git\nGitLab User Name : zaid.pathan\n\nSo final URL should be http://[email protected]/zaid/iosapp.git\nNote: zaid.pathan@ added before git.\nStep 3: Enjoy cloning :)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Eclipse Android and gitignore\nWhat files/folders can I safely ignore for inclusion with git?\nI copied a good project, removed its gen and bin folders and tried to run the app. The Android Launch window says, \"Your project contains error(s), please fix them before running your application. There is a red X on the icon to the left of the project in the Package Explorer. While the gen folder does not exist in Windows Explorer, it does in Package Explorer."
},
{
"role": "assistant",
"content": "There are file types to ignore\n# built application files\n*.apk\n*.ap_\n\n# files for the dex VM\n*.dex\n\n# Java class files\n*.class\n\n# generated files\nbin/\ngen/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Eclipse project files\n.classpath\n.project\n\n# Proguard folder generated by Eclipse\nproguard/\n\n# Intellij project files\n*.iml\n*.ipr\n*.iws\n.idea/\n\nFrom Gitignore on github"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I alias commands in git?\nI saw a screencast where someone had gotten \ngit st\ngit ci\n\nto work. When I do it I get an error asking me if I meant something else.\nBeing a git newb, I need to know what you have to do to get this done?"
},
{
"role": "assistant",
"content": "Basically you just need to add lines to ~/.gitconfig\n[alias]\n st = status\n ci = commit -v\n\nOr you can use the git config alias command:\n$ git config --global alias.st status \n\nOn unix, use single quotes if the alias has a space:\n$ git config --global alias.ci 'commit -v'\n\nOn windows, use double quotes if the alias has a space or a command line argument:\nc:\\dev> git config --global alias.ci \"commit -v\"\n\nThe alias command even accepts functions as parameters. Take a look at aliases."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Android: Could not find or load main class org.gradle.wrapper.GradleWrapperMain\n\nI am trying to build my project on GitLab CI but unfortunately for me I keep getting this error inside the runner:\nError: Could not find or load main class org.gradle.wrapper.GradleWrapperMain\nNow I know there is something wrong with my environment but I just cant get my mind wrapped around the problem. I searched on the web and I found I needed to update my .gitignore file and I did here it is:\n### Java ###\n*.class\n\n### Android ###\n*.apk\n*.ap_\n\n### Package files ###\n*.war\n*.ear\n*.aar\n\n### Gradle ###\n.gradle\n build\nbin/\nbuild/\nbuild.xml\ngen/\n.gradle/\ngradlew\ngradlew.bat\ngradle-wrapper.jar\ngradle-wrapper.properties\n\n### Android Studio ###\n.idea\nlocal.properties\n.DS_Store\n/captures\n\nI also eddied my gradle.build to contain the following lines: \ntask wrapper(type: Wrapper) {\ngradleVersion = '2.0' \n}\n\nBut again every time I run a build I get stack! Here is also my .gitlab-ci.yml:\nbefore_script:\n- apt-get --quiet update --yes\n- apt-get --quiet install --yes wget tar unzip openjdk-7-jdk lib32stdc++6 lib32z1\n - wget --quiet --output-document=gradle.zip https://services.gradle.org/distributions/gradle-2.8-bin.zip\n - unzip -q gradle.zip\n - export ANDROID_HOME=\"/opt/android-sdk\"\n - chmod +x gradlew\n\n dev:\n script:\n - ./gradlew assembleDebug\n\nAnd the line where the error appears is:\n- wget --quiet --output-document=gradle.zip https://services.gradle.org/distributions/gradle-2.8-bin.zip"
},
{
"role": "assistant",
"content": "According to your gitignor, CI is never getting the gradle-wrapper.jar library, because it wasn't commited yet, but it has to be, since it is used to run the wrapper.\nCheck, whether is gradle-wrapper.jar commited, if no, then just commit it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the meaning of git reset --hard origin/master?\nI did a git pull and got an error: \n\nThe following working tree files would be overwritten by merge...\n Please move or remove them before you can merge.\n\nTo resolve this I did the following:\ngit fetch\ngit reset --hard origin/master\n\nNow when I do git pull, it says everything up to date. I want to know what exactly happens when I run these commands. I know git fetch fetches the changes from the remote repo without merging them into my local repo.\nWhat is the meaning of git reset --hard origin/master? How does it work?"
},
{
"role": "assistant",
"content": "git reset --hard origin/master\n\nsays: throw away all my staged and unstaged changes, forget everything on my current local branch and make it exactly the same as origin/master.\nYou probably wanted to ask this before you ran the command. The destructive nature is hinted at by using the same words as in \"hard reset\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to stop tracking a file without removing it from repo\nI have a config file which I want to keep on the remote repository, but I don't want to track its changes on my computer. Adding it to .gitignore doesn't do the trick.\nThe reason I don't want to track changes is because it's supposed to differ between computers depending on their environment."
},
{
"role": "assistant",
"content": "If you want to temporarily stop tracking a file, you can still use\ngit update-index --assume-unchanged <file>\n// track changes again :\ngit update-index --no-assume-unchanged <file>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc patience"
},
{
"role": "assistant",
"content": "Use \"patience diff\" algorithm when generating patches."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-notes - Add or inspect object notes --[no-]separator, --separator=<paragraph-break>"
},
{
"role": "assistant",
"content": "Specify a string used as a custom inter-paragraph separator\n(a newline is added at the end as needed). If --no-separator , no\nseparators will be added between paragraphs. Defaults to a blank\nline."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Push different branch to Heroku\nJust finised work on my other branch. Now I need to test that this works on Heroku before I merge with the master branch.\nIs it possible to push the other branch to Heroku and it replace the contents of my last push which was from the master branch?"
},
{
"role": "assistant",
"content": "Yes, pushing to a branch named differently that your current one is possible using the syntax:\ngit push heroku other:master\n\nThis tells Git to push the contents of your other branch to the master branch on the heroku remote. Keep in mind that you may have to force push if there are commits on heroku/master that don't appear in your other branch.\nFor more information have a look at the documentation of the <refspec> option to git push."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_DIFF_PATH_TOTAL"
},
{
"role": "assistant",
"content": "The total number of paths."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-difftool - Show changes using common diff tools -d --dir-diff"
},
{
"role": "assistant",
"content": "Copy the modified files to a temporary location and perform\na directory diff on them. This mode never prompts before\nlaunching the diff tool."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How is Gitlab different compared to Github?\n\nI'm trying to understand the pros and cons of the two from experienced developer's point of view. Of course Github is the more widely used of the two, but if someone could explain in general terms what they find better/lacking in either, that would be great. \n(I use Github at the moment, by the way)."
},
{
"role": "assistant",
"content": "Gitlab is a self-hosted git server. I have used both (plus bitbucket) and I don't see much difference in terms of functionality. Github's UI is far more advanced, and they offer some custom features (e.g. Releases)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-notes"
},
{
"role": "assistant",
"content": "Add or inspect object notes"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects --[no-]atomic"
},
{
"role": "assistant",
"content": "Use an atomic transaction on the remote side if available.\nEither all refs are updated, or on error, no refs are updated.\nIf the server does not support atomic pushes the push will fail."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-merge - Join two or more development histories together -q --quiet"
},
{
"role": "assistant",
"content": "Operate quietly. Implies --no-progress."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git diff output to file preserve coloring\nIs it possible to do git diff and save the output to a file with the coloring somehow?\nI know how to do git diff > filename.rtf - which saves to a file, but I'd like to preserve the coloring."
},
{
"role": "assistant",
"content": "Try:\ngit diff --color > foo.txt\n\nThen later issue:\ncat foo.txt\n\nOr:\nless -R foo.txt\n\nhttps://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration:\n\nGit automatically colors most of its output, but there’s a master\nswitch if you don’t like this behavior. To turn off all Git’s colored\nterminal output, do this:\n$ git config --global color.ui false\nThe default setting is auto, which colors output when it’s going\nstraight to a terminal, but omits the color-control codes when the\noutput is redirected to a pipe or a file.\nYou can also set it to always to ignore the difference between\nterminals and pipes. You’ll rarely want this; in most scenarios, if\nyou want color codes in your redirected output, you can instead pass a\n--color flag to the Git command to force it to use color codes. The default setting is almost always what you’ll want."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I fetch only one branch of a remote Git repository?\nI'd like to grab a single branch (not all of them) of a remote repository and create a local tracking branch that can track further updates to that remote branch. The other branches in the remote repository are very big, so I'd like to avoid fetching them. How do I do this?"
},
{
"role": "assistant",
"content": "git fetch <remote_name> <branch_name>\n\nWorked for me."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Undo part of unstaged changes in git\nHow do I undo parts of my unstaged changes in git but keep the rest as unstaged? The way I figured out is:\ngit commit --interactive\n# Choose the parts I want to delete\n# Commit the changes\ngit stash\ngit rebase -i master # (I am an ancestor of master)\n# Delete the line of the most recent commit\ngit stash apply\n\nThis works, but it would be nice if there were something like git commit --interactive only for reverting changes. Any better methods?"
},
{
"role": "assistant",
"content": "You can use git checkout -p, which lets you choose individual hunks from the diff between your working copy and index to revert. Likewise, git add -p allows you to choose hunks to add to the index, and git reset -p allows you to choose individual hunks from the diff between the index and HEAD to back out of the index.\n$ git checkout -p file/to/partially/revert\n# or ...\n$ git checkout -p .\n\nIf you wish to snapshot your git repository beforehand to preserve these changes before reverting them, I like to do:\n$ git stash; git stash apply\n\nIf you use that often, you might want to alias it:\n[alias]\n checkpoint = !git stash; git stash apply\n\nReverting individual hunks or lines can be even easier if you use a good editor mode or plugin, which may provide support for selecting lines directly to revert, as -p can be a bit clumsy to use sometimes. I use Magit, an Emacs mode that is very helpful for working with Git. In Magit, you can run magit-status, find the diffs for the changes that you want to revert, select the lines you wish to revert (or simply put the cursor on hunks you wish to revert if you want to revert a hunk at a time instead of a line at a time), and press k to revert those specific lines. I highly recommend Magit if you use Emacs."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-cherry-pick - Apply the changes introduced by some existing commits <commit>…"
},
{
"role": "assistant",
"content": "Commits to cherry-pick.\nFor a more complete list of ways to spell commits, see gitrevisions .\nSets of commits can be passed but no traversal is done by\ndefault, as if the --no-walk option was specified, see git-rev-list . Note that specifying a range will\nfeed all <commit>… arguments to a single revision walk\n(see a later example that uses maint master..next )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitattributes - Defining attributes per path String"
},
{
"role": "assistant",
"content": "Specify a comma separated list of common whitespace problems to\nnotice in the same format as the core.whitespace configuration\nvariable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Change Git repository directory location.\n\nWith Git/Github for Windows, if I have a repository with this directory: C:\\dir1\\dir2, what do I need to do to move the repo files to C:\\dir1? I can obviously physically copy and paste the files, but what do I need to do on the Git side?\nI have this repo on GitHub and I use Git Bash and GitHub for Windows."
},
{
"role": "assistant",
"content": "Simply copy the entire working directory contents (including the hidden .git directory). This will move the entire working directory to the new directory and will not affect the remote repository on GitHub.\nIf you are using GitHub for Windows, you may move the repository using the method as above. However, when you click on the repository in the application it will be unable to find it. To resolve this simply click on the blue circle with the !, select Find It and then browse to the new directory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs log.follow"
},
{
"role": "assistant",
"content": "If true , git log will act as if the --follow option was used when\na single <path> is given. This has the same limitations as --follow ,\ni.e. it cannot be used to follow multiple files and does not work well\non non-linear history."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index plain"
},
{
"role": "assistant",
"content": "Any line that is added in one location and was removed\nin another location will be colored with color.diff.newMoved .\nSimilarly color.diff.oldMoved will be used for removed lines\nthat are added somewhere else in the diff. This mode picks up any\nmoved line, but it is not very useful in a review to determine\nif a block of code was moved without permutation."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-restore - Restore working tree files"
},
{
"role": "assistant",
"content": "DESCRIPTION Restore specified paths in the working tree with some contents from a\nrestore source. If a path is tracked but does not exist in the restore\nsource, it will be removed to match the source. The command can also be used to restore the content in the index with --staged , or restore both the working tree and the index with --staged --worktree . By default, if --staged is given, the contents are restored from HEAD ,\notherwise from the index. Use --source to restore from a different commit. See \"Reset, restore and revert\" in git for the differences\nbetween the three commands. THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Selectively revert or checkout changes to a file in Git?\nIs there a command that allows you to partially undo the changes to a file (or files) in the working directory?\nSuppose you have edited a file a lot but you realize that you want to undo some of the changes back to the committed state, but not the other changes.\nI'm envisioning an option for git checkout that works a lot like git add -p, i.e. it goes through the file hunk by hunk and asks if you want to keep it or not."
},
{
"role": "assistant",
"content": "With git version >= 1.7.1 I can\ngit checkout -p dir/filename\n\nor to iterate through \"all changed hunks in all files\"\ngit checkout -p\n\nI am not sure when this feature was introduced."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --follow"
},
{
"role": "assistant",
"content": "Continue listing the history of a file beyond renames\n(works only for a single file)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-grep - Print lines matching a pattern -I"
},
{
"role": "assistant",
"content": "Don’t match the pattern in binary files."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to download .zip from GitHub for a particular commit sha?\n\nI want to download a .zip with the source of a library hosted on github, but I don't want the master, because every time I download I could be downloading a different version.\nThis particular library does not have tags, so I can't use that.\nSo how do I download the source.zip for a specific commit sha?"
},
{
"role": "assistant",
"content": "You can put the sha that you want in the download url:\nhttps://github.com/{username}/{projectname}/archive/{sha}.zip\nAs a general rule, if you have a url that works, you can replace \"master\" with the specific sha you want.\nOn unix:\nwget https://github.com/{username}/{projectname}/archive/{sha}.zip\nKeep in mind that if this is a private repo then wget will not work unless you pass an OAuth token as well.\nHere's more info on that:\nHaving trouble downloading Git archive tarballs from Private Repo"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I merge a branch into master but continue working on the branch?\nI created a branch to try a different approach and it worked, so I would like to merge the \"Farmcrops\" branch into \"Master\" to keep those changes but continue the \"Farmcrops\" branch to explore another possibility. That way, if this latest change doesn't work, I can revert back to \"Master\" which would now include the first round of changes.\nHow can I do that?"
},
{
"role": "assistant",
"content": "If I understand correctly, you're starting from\n-- o -- o -- o [master]\n \\\n o -- o [Farmcrops]\n\nYou shouldn't merge Farmcrops directly into master, because you run the risk of breaking the code in master, which, by convention, is supposed to be more stable. Instead, check out Farmcrops and merge master into it.\ngit checkout Farmcrops\ngit merge master\n\nThen you'll get\n-- o -- o -- o [master]\n \\ \\\n o -- o -- o [HEAD -> Farmcrops]\n\nRun some tests; make sure everything works as expected. Then check out master and merge Farmcrops into it:\ngit checkout master\ngit merge Farmcrops\n\nYour repo will then look like this:\n-- o -- o -- o\n \\ \\\n o -- o -- o [HEAD -> master,Farmcrops]\n\n(Note that this merge is a fast forward: it doesn't create a merge commit because Farmcrops is a direct descendant of master.)\nNow check out Farmcrops again and continue your experiment, make more commits on it, etc...\n-- o -- o -- o\n \\ \\\n o -- o -- o [master]\n \\\n o -- o -- o [HEAD -> Farmcrops]\n\nYou can always fall back on master (which now contains \"the first round of changes\", as you put it) if your new experiment on Farmcrops doesn't pan out so well."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to change the base branch of a pull request?\n\nI created a pull request on project on GitHub to a specific remote branch. After some time, the remote branch was deleted.\nHow can I change the pull request to point to another branch (specifically master)?"
},
{
"role": "assistant",
"content": "Updated: as Michael notes below, this is now possible:\n\nYou can now change the base branch of an open pull request. After you’ve created a pull request, you can modify the base branch so that the changes in the pull request are compared against a different branch. By changing the base branch of your original pull request rather than opening a new one with the correct base branch, you’ll be able to keep valuable work and discussion.\n\nClick the Edit button by the title of the pull request to reveal the base branch selector.\n\n\nOld answer\nYou can't. Just make a new pull request."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects --combined-all-paths"
},
{
"role": "assistant",
"content": "This flag causes combined diffs (used for merge commits) to\nlist the name of the file from all parents. It thus only has\neffect when --diff-merges=[dense-]combined is in use, and\nis likely only useful if filename changes are detected (i.e.\nwhen either rename or copy detection have been requested)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-send-email - Send a collection of patches as emails --[no-]format-patch"
},
{
"role": "assistant",
"content": "When an argument may be understood either as a reference or as a file name,\nchoose to understand it as a format-patch argument ( --format-patch )\nor as a file name ( --no-format-patch ). By default, when such a conflict\noccurs, git send-email will fail."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -U<n> --unified=<n>"
},
{
"role": "assistant",
"content": "Generate diffs with <n> lines of context instead of\nthe usual three.\nImplies --patch ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options core.ignoreStat"
},
{
"role": "assistant",
"content": "If true, Git will avoid using lstat() calls to detect if files have\nchanged by setting the \"assume-unchanged\" bit for those tracked files\nwhich it has updated identically in both the index and working tree. When files are modified outside of Git, the user will need to stage\nthe modified files explicitly (e.g. see Examples section in git-update-index ).\nGit will not normally detect changes to those files. This is useful on systems where lstat() calls are very slow, such as\nCIFS/Microsoft Windows. False by default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %Creset"
},
{
"role": "assistant",
"content": "reset color"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you push a tag to a remote repository using Git?\nI added a tag to the master branch on my machine:\ngit tag mytag master\n\nHow do I push this to the remote repository? Running git push gives the message:\n\nEverything up-to-date\n\nHowever, the remote repository does not contain my tag."
},
{
"role": "assistant",
"content": "To push a single tag:\ngit push origin tag <tag_name>\n\nAnd the following command should push all tags (not recommended):\n# not recommended\ngit push --tags"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitcore-tutorial"
},
{
"role": "assistant",
"content": "A Git core tutorial for developers"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab CI script: exclude branches\n\nI'm trying to improve the project building script, described in YML-file, the improvement itself seems quite trivial, but the idea of accidentally ruining the auto-builds scares me a bit.\nRight now there are several branches, version tags and other stuff in the project.\nA development branch, not built by the runners would be of use, because copying a huge project somehow between virtual machines to test the build on different platforms is not convenient at all. So, I want to exclude from builds some \"prj-dev\" branch.\nAnd there we have:\nstages:\n - build\n - linuxbuild\njob:\n tags:\n - win2008build\n stage: build\n script:\n # something complex\n\njob1:\n tags:\n - linux\n stage: linuxbuild\n script:\n # something else complex\n\nI googled and found a solution like:\nstages:\n - build\n - linuxbuild\njob:\n tags:\n - win2008build \n branches:\n except:\n - *dev-only\n\nBut it seems that our pipelines are quite different, the tags are not git tags, they are pipeline tags. So, I'm considering rather to use a config like:\nstages:\n - build\n - linuxbuild\njob:\n tags:\n - win2008build \n except:\n branches:\n - *dev-only\n\n...which would mean \"build as usual, but not my branch\". There are complications in trying it both ways, I'm pretty sure someone should know the recipe for sure.\nSo, if you please, -- how do I exclude my dev branch without changing the pipelines, config only? Is it possible at all?"
},
{
"role": "assistant",
"content": "All you need to do is use except in the gitlab-ci.yml file and add your branches directly below like this:\nmybuild:\n stage: test\n image: somedockerimage\n script:\n - some script running\n except:\n - branch-name\n\nThis is working on my project without problems."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects default"
},
{
"role": "assistant",
"content": "Is a synonym for zebra . This may change to a more sensible mode\nin the future."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-describe - Give an object a human readable name based on an available ref"
},
{
"role": "assistant",
"content": "SEARCH STRATEGY For each commit-ish supplied, git describe will first look for\na tag which tags exactly that commit. Annotated tags will always\nbe preferred over lightweight tags, and tags with newer dates will\nalways be preferred over tags with older dates. If an exact match\nis found, its name will be output and searching will stop. If an exact match was not found, git describe will walk back\nthrough the commit history to locate an ancestor commit which\nhas been tagged. The ancestor’s tag will be output along with an\nabbreviation of the input commit-ish’s SHA-1. If --first-parent was\nspecified then the walk will only consider the first parent of each\ncommit. If multiple tags were found during the walk then the tag which\nhas the fewest commits different from the input commit-ish will be\nselected and output. Here fewest commits different is defined as\nthe number of commits which would be shown by git log tag..input will be the smallest number of commits possible."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git for Perforce users\nI've been using Perforce for a number of years. I'd like to switch to using git for my personal code, but all of the git tutorials that I've seen either assume that you'e a complete source control n00b (which makes them incredibly tedious) or that you're used to svn (which I'm not).\nI know p4, and I also understand the idea behind a distributed source control system (so I don't need a sales pitch, thanks). What I'd like is a translation table from p4 command to equivalent git commands, as well as the \"can't live without\" commands that have no p4 equivalent.\nSince I suspect every p4 user uses a different subset of p4, here are some of the things I regularly do in p4 that I'd like to be able to do in git that aren't immediately obvious from the docs I've looked at:\n\ncreate multiple pending changelists in a single client. (p4 change)\nedit a pending changelist. (also p4 change)\nsee a list of all of my pending changelists (p4 changes -s pending)\nlist of all of the changed files in my client (p4 opened) or in a pending changelist (p4 describe)\nsee a diff of a pending changelist (I use a wrapper script for this which uses p4 diff and p4 describe)\nfor a given file, see which submitted changelists affected which lines (p4 annotate)\nfor a given file, see a list of the descriptions of the changelists that affected the file (p4 log)\nsubmit a pending changelist (p4 submit -c)\nabort a pending changelist (p4 revert)\n\nA lot of these revolve around \"changelists\". \"changelist\" is p4 terminology. What's the git equivalent term?\nIt sounds like branches might be what git users use in place of what p4 calls changelists. A bit confusing, since p4 also has something called a branch though they seem to be only vaguely related concepts. (Though I always thought p4's concept of a branch was pretty weird it is different yet again from the classic RCS concept of a branch.)\nAnyway... I'm not sure how to accomplish what I normally do in p4 changelists with git's branches. In p4 I can do something like this:\n$ p4 edit a.txt\n$ p4 change a.txt\nChange 12345 created.\n\nAt this point I have a changlist that contains a.txt. I can edit the description and continue working without submitting the changelist. Also, if it turns out that I need to make some changes to some other files, like say a bugfix in some other layer of the code, I can do that in the same client:\n$ p4 edit z.txt\n$ p4 change z.txt\nChange 12346 created.\n\nNow I have two separate changelists in the same client. I can work on these concurrently, and I don't need to do anything to \"switch between\" them. When it comes time to commit, I can submit them separately:\n$ p4 submit -c 12346 # this will submit the changes to z.txt\n$ p4 submit -c 12345 # this will submit the changes to a.txt\n\nI can't figure out how to replicate this in git. From my experiments, it doesn't appear that git add is associated with the current branch. As far as I can tell, when I git commit it's going to commit all files that I git add-ed no matter what branch I was in at the time:\n$ git init\nInitialized empty Git repository in /home/laurence/git-playground/.git/\n$ ls\na.txt w.txt z.txt\n$ git add -A .\n$ git commit\n Initial commit.\n 3 files changed, 3 insertions(+), 0 deletions(-)\n create mode 100644 a.txt\n create mode 100644 w.txt\n create mode 100644 z.txt\n$ vi a.txt z.txt \n2 files to edit\n$ git status\n# On branch master\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# modified: a.txt\n# modified: z.txt\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n$ git branch aardvark\n$ git checkout aardvark\nM a.txt\nM z.txt\nSwitched to branch 'aardvark'\n$ git add a.txt \n$ git checkout master\nM a.txt\nM z.txt\nSwitched to branch 'master'\n$ git branch zebra\n$ git checkout zebra\nM a.txt\nM z.txt\nSwitched to branch 'zebra'\n$ git add z.txt \n$ git status\n# On branch zebra\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# modified: a.txt\n# modified: z.txt\n#\n$ git checkout aardvark\nM a.txt\nM z.txt\nSwitched to branch 'aardvark'\n$ git status\n# On branch aardvark\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# modified: a.txt\n# modified: z.txt\n\nIn this example, the aardvark and zebra branches seem to contain exactly the same set of changes, and based on the output of git status it appears that doing a commit in either will have the same effect. Am I doing something wrong?"
},
{
"role": "assistant",
"content": "I haven't used perforce much so this may not be exactly be a 1:1 translation. Then again distributed source control systems like git and mercurial have a different workflow anyway so there really isn't (and there shouldn't) be a 1:1 translation. Anyway, here goes:\n\nCreate multiple pending changelists -> Use branches instead. In git branches are light and quick, takes less than a second to create and typically less than two seconds to merge. Don't be afraid of branching and rebase often.\ngit branch new-branch-name\ngit checkout new-branch-name\n\nOr do it all in one line:\ngit checkout -b new-branch-name\n\nSee a list of all pending changelists -> Since the equivalent of multiple pending changelist is multiple branches just view the branches:\ngit branch\n\nIf you want to view remote branches as well:\ngit branch -a\n\nIt is considered good practice to immediately delete a branch after a successful merge so you don't have to keep track of which branch are pending to be merged and which have already been merged.\nList all changed files -> For a single pending \"changelist\" in a specific branch git has a concept of the index or cache. In order to commit a change you must first add files to this index. This allows you to manually select which group of files represent a single change or to ignore irrelevant files. To see the status of which files are added, or not to this index just do:\ngit status\n\nSee a diff of a pending changelist -> There are two parts to this. First to see a diff between the working directory and the index:\ngit diff\n\nBut if you want to know the diff between what you're typing now and the last commit then you are really asking for a diff between the working directory+index and the HEAD:\ngit diff HEAD\n\nFor a given file, see which submitted changelists affected which lines -> This is easy:\ngit blame filename\n\nor even better, if you are in a windowing environment:\ngit gui blame filename\n\nGit gui takes longer to parse the file (it was written in tcl instead of C) but it has lots of neat features including the ability to \"time travel\" back into the past by clicking on a commit ID. I only wish they'd implement a feature to \"time travel\" to the future so I can find out how a given bug will finally be resolved ;-)\nFor a given file, see a list of the descriptions of the changelists that affected the file -> also easy:\ngit log filename\n\nBut git log is a much more powerful tool than just this. In fact most of my personal scripts piggyback off-of git log to read the repository. Read the man page.\nSubmit a pending changelist -> Also easy:\ngit commit\n\n\nSee my answer to a previous question to see my typical git workflow: Learning Git. Need to know if I am on the right track\nIf you follow the workflow I outlined then you'll find tools like gitk to be much more valuable since it allows you to clearly see groups of changes.\n\nAdditional answer:\nGit is very flexible and there are several ways to do what you describe. The thing to remember is to always start a new branch for each feature you're working on. This means the master branch isn't touched so you can always go back to it to do bug fixes. Working in git one should almost always start with:\ngit checkout -b new-feature-a\n\nNow you can edit file a.txt. To work concurrently on another feature do:\ngit checkout master\ngit checkout -b new-feature-z\n\nNow you can edit file z.txt. To switch back to a.txt:\ngit checkout new-feature-a\n\nBut wait, there are changes to new-feature-z and git won't let you switch branches. At this point you have two choices. The first is the simplest, commit all changes to the current branch:\ngit add .\ngit commit\ngit checkout new-feature-a\n\nThis is what I'd recommend. But if you are really not ready to commit the code, you can temporarily stash it:\ngit stash\n\nNow you can switch to branch new-feature-a. To go back to the code you were working on just pop the stash:\ngit checkout new-feature-z\ngit stash pop\n\nWhen all is done merge back all changes to master:\ngit merge --no-ff new-feature-a\ngit merge --no-ff new-feature-z\n\nBecause merges are so quick and easy (easy because conflicts are so rare and conflict resolution, when one does happen, not too hard) we use branches in git for everything.\nHere's another example of a common use of branches in git that you don't see in other source control tools (except perhaps mercurial):\nNeed to keep changing your config files to reflect your dev environment? Then use a branch:\ngit checkout -b dev-config\n\nNow edit your config files in your favourite editor then commit changes:\ngit add .\ngit commit\n\nNow every new branch can start from the dev-config branch instead of master:\ngit checkout dev-config\ngit checkout -b new-feature-branch\n\nOnce you're done remove the edits in dev-config from new-feature-branch using interactive rebase:\ngit rebase -i master\n\nDelete the commits you don't want then save. Now you have a clean branch without custom config edits. Time to merge back to master:\ngit checkout master\ngit merge --no-ff new-feature-branch\n# because master have changed, it's a good idea to rebase dev-config:\ngit checkout dev-config\ngit rebase master\n\nIt should be noted that removing edits with git rebase -i even works when all changes happen in the same file. Git remembers changes, not file content*.\n*note: actually, technically not entirely true but as a user that's what it feels like\n\nMore additional answer:\nSo, from you comments it looks like you want to have two branches to exist simultaneously so you can test how the combined code works. Well, this is a good way to illustrate the power and flexibility of branches.\nFirst, a word on the implication of cheap branching and modifiable history on your workflow. When I was using CVS and SVN I was always a bit reluctant to commit. That's because committing unstable code would inevitably f**k up other people's working code. But with git I lost that fear. That's because in git other people won't get my changes until I merge them to master. So now I find myself committing code every 5 lines I write. You don't need perfect foresight to commit. You just need to change your mindset: commit-to-branch==add-to-changeset, merge-to-master==commit-changeset.\nSo, back to examples. Here's how I would do it. Say you have a branch new-feature-z and you want to test it with new-feature-a. I would just create a new branch to test it:\n# assume we are currently in branch new-feature-z\n# branch off this branch for testing\ngit checkout -b feature-z-and-feature-a\n# now temporarily merge new-feature-a\ngit merge --no-ff new-feature-a\n\nNow you can test. If you need to modify something to make feature-z work with feature-a then do so. If so you can merge back the changes to the relevant branch. Use git rebase -i to remove irrelevant changes from the merge.\nAlternatively, you can also use git rebase to temporarily change the base of new-feature-z to point to new-feature-a:\n# assume we are currently in branch new-feature-z\ngit rebase new-feature-a\n\nNow the branch history is modified so that new-feature-z will be based off new-feature-a instead of master. Now you can test. Any changes committed in this branch will belong to the branch new-feature-z. If you need to modify new-feature-a just switch back to it and the rebase to get the new changes:\ngit checkout new-feature-a\n# edit code, add, commit etc..\ngit checkout new-feature-z\ngit rebase new-feature-a\n# now new-feature-z will contain new changes from new-feature-a\n\nWhen you're done, simply rebase back to master to remove changes from new-feature-a:\n# assume we are currently in branch new-feature-z\ngit rebase master\n\nDon't be afraid to start a new branch. Don't be afraid to start a throwaway branch. Don't be afraid to throw away branches. And since merge==submit and commit==add-to-changeset don't be afraid to commit often. Remember, commit is a developer's ultimate undo tool.\nOh, and another thing, in git deleted branches still exist in your repository. So if you've accidentally deleted something that you later realise is useful after all you can always get it back by searching the history. So don't be afraid to throw away branches."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-ls-files - Show information about files in the index and the working tree --recurse-submodules"
},
{
"role": "assistant",
"content": "Recursively calls ls-files on each active submodule in the repository.\nCurrently there is only support for the --cached and --stage modes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitglossary - A Git Glossary commit object"
},
{
"role": "assistant",
"content": "An object which contains the information about a\nparticular revision , such as parents , committer,\nauthor, date and the tree object which corresponds\nto the top directory of the stored\nrevision."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rm - Remove files from the working tree and from the index --pathspec-from-file=<file>"
},
{
"role": "assistant",
"content": "Pathspec is passed in <file> instead of commandline args. If <file> is exactly - then standard input is used. Pathspec\nelements are separated by LF or CR/LF. Pathspec elements can be\nquoted as explained for the configuration variable core.quotePath (see git-config ). See also --pathspec-file-nul and\nglobal --literal-pathspecs ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --grep-reflog=<pattern>"
},
{
"role": "assistant",
"content": "Limit the commits output to ones with reflog entries that\nmatch the specified pattern (regular expression). With\nmore than one --grep-reflog , commits whose reflog message\nmatches any of the given patterns are chosen. It is an\nerror to use this option unless --walk-reflogs is in use."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Moving a docker-compose container to openshift V3\n\nI would like to move the Omnibus gitlab docker image to openshift V3,\nso I've got the dockerfile and docker-compose files @ https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/docker. \nWhat is the best way for having a scalable openshift v3 pod ? \nAs the command oc import docker-compose is experimental so I stuck and lost in the process of building a reliable solution.\nThanks\nHerve"
},
{
"role": "assistant",
"content": "You should use https://kompose.io/\nRun kompose convert --provider=openshift in the same directory as your docker-compose.yaml file."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects lines"
},
{
"role": "assistant",
"content": "Compute the dirstat numbers by doing the regular line-based diff\nanalysis, and summing the removed/added line counts. (For binary\nfiles, count 64-byte chunks instead, since binary files have no\nnatural concept of lines). This is a more expensive --dirstat behavior than the changes behavior, but it does count rearranged\nlines within a file as much as other changes. The resulting output\nis consistent with what you get from the other --*stat options."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fast-import - Backend for fast Git data importers progress"
},
{
"role": "assistant",
"content": "Causes fast-import to echo the entire line to its own\nstandard output. This command is optional and is not needed\nto perform an import."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Install gitlab-ce on ubuntu server 17.04\n\nI'm trying to install the gitlab-ce package on a system running Ubuntu server 17.04. I followed the official installation instructions here.\nFirst I ran:\nsudo apt-get install curl openssh-server ca-certificates postfix\n\nI already had all of those installed. Then I ran:\ncurl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash\n\nWhich also worked fine. But when I try to run\nsudo apt-get install gitlab-ce\n\nI get the following error message:\nReading package lists... Done\nBuilding dependency tree \nReading state information... Done\nE: Unable to locate package gitlab-ce\n\nI know it's possible to install gitlab on Ubuntu server 17.04, since I had already done It on a previous installation. Unfortunately I installed the OS again from scratch and I can't remember how I had installed gitlab.\nThanks for any help in advance!"
},
{
"role": "assistant",
"content": "I gave up with the \"full\" automated script, as it doesn't appear to be working with 17.04... Anyway. I grabbed the latest package from https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/xenial/gitlab-ce_9.3.0-ce.0_amd64.deb\ncurl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/xenial/gitlab-ce_9.3.0-ce.0_amd64.deb/download\n\nInstalled it with the package manager\nsudo dpkg -i gitlab-ce_9.3.0-ce.0_amd64.deb\n\nThen configured it with\nsudo gitlab-ctl reconfigure\n\nThen, point your web browser at your new gitlab install and you should be good to go...\nUbuntu 20.04.1\nIncase anyone bumps back into this, while trying to gitlab on version 20.0.4 of ubuntu, life is much easier... and the instructions and automated script actually work. GitLab-CE installation instructions\non a fresh install of ubuntu: -\nsudo apt install curl\ncurl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab- ce/script.deb.sh | sudo bash\nsudo apt install gitlab-ce\n\ndone!"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to find out \"The most popular repositories\" on Github? [closed]\n\nClosed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting answers.\n \n \n\n\n\n\n\n\n\n\n\n\n\n We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.\n\n\nClosed 7 years ago.\n\n\n\n\n\n\n\n Improve this question\n \n\n\n\nOnce upon a time, we can watch the most popular repositories (Most forked or Most watched) at this page (https://github.com/popular/watched) of Github. like this:\n\nBut now when you try to explore repos, you can only see the Top 25 trending repositories. like this: https://github.com/trending\nWhy Github change this, and\nis there any way to find out the list of the most popular repos?"
},
{
"role": "assistant",
"content": "Ranking by stars or forks is not working. Each promoted or created by a famous company repository is popular at the beginning. Also it is possible to have a number of them which are in trend right now (publications, marketing, events). It doesn't mean that those repositories are useful/popular.\nThe gitmostwanted.com project (repo at github) analyses GH Archive data in order to highlight the most interesting repositories and exclude others. Just compare the results with mentioned resources."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-repack"
},
{
"role": "assistant",
"content": "Pack unpacked objects in a repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Docker on Windows 10 \"driver failed programming external connectivity on endpoint\"\n\nI am trying to use $ docker-compose up -d for a project and am getting this error message:\n\nERROR: for api Cannot start service api: driver failed programming external connectivity on endpoint dataexploration_api_1 (8781c95937a0a4b0b8da233376f71d2fc135f46aad011401c019eb3d14a0b117): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:9000:tcp:172.19.0.2:80: input/output error\n Encountered errors while bringing up the project.\n\nI am wondering if it is maybe the port? I had been trying port 8080 previously. The project was originally set up on a mac and I have cloned the repository from gitHub."
},
{
"role": "assistant",
"content": "I got the same error message on my Windows 10 Pro / Docker v17.06.1-ce-win24 / Docker-Compose v1.14.0 using Windows Powershell x86 in admin mode.\nThe solution was to simply restart Docker."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --full-history with parent rewriting"
},
{
"role": "assistant",
"content": "Ordinary commits are only included if they are !TREESAME\n(though this can be changed, see --sparse below). Merges are always included. However, their parent list is rewritten:\nAlong each parent, prune away commits that are not included\nthemselves. This results in .-A---M---N---O---P---Q\n\t / / / / /\n\tI B / D /\n\t \\ / / / /\n\t `-------------' Compare to --full-history without rewriting above. Note that E was pruned away because it is TREESAME, but the parent list of P was\nrewritten to contain E 's parent I . The same happened for C and N , and X , Y and Q ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "gitfaq - Frequently asked questions about using Git How do I change the password or token I’ve saved in my credential manager?"
},
{
"role": "assistant",
"content": "Usually, if the password or token is invalid, Git will erase it and\nprompt for a new one. However, there are times when this doesn’t always\nhappen. To change the password or token, you can erase the existing\ncredentials and then Git will prompt for new ones. To erase\ncredentials, use a syntax like the following (substituting your username\nand the hostname): $ echo url=https://author@git.example.org | git credential reject"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_PROTOCOL_FROM_USER"
},
{
"role": "assistant",
"content": "Set this Boolean environment variable to false to prevent protocols used by fetch/push/clone which are\nconfigured to the user state. This is useful to restrict recursive\nsubmodule initialization from an untrusted repository or for programs\nwhich feed potentially-untrusted URLS to git commands. See git-config for more details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database unterminatedHeader"
},
{
"role": "assistant",
"content": "(FATAL) Missing end-of-line in the object header."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why does git protocol produce more objects than git-http-backend?\nI'm using Git 1.7.1 configured with git-http-backend (Smart HTTP). I wanted to see how much faster this was compared to the git:// protocol, since now they are supposed to be on par.\nTurns out git:// protocol is compressing more objects (33,229 vs 21,193) for the exact same repo (even verified client side), and thus creating a packfile that's about 30MB bigger for my project. \nIs there some reason why git:// protocol needs more objects?\ngit:// Output\nremote: Counting objects: 44510, done.\nremote: Compressing objects: 100% (33229/33229), done.\nReceiving objects: 100% (44510/44510), 124.07 MiB | 2.84 MiB/s, done.\nremote: Total 44510 (delta 22755), reused 15866 (delta 7516)\nResolving deltas: 100% (22755/22755), done.\n\nhttp:// Output\nremote: Counting objects: 24299, done.\nremote: Compressing objects: 100% (21931/21931), done.\nremote: Total 24299 (delta 7517), reused 0 (delta 0)\nReceiving objects: 100% (24299/24299), 95.95 MiB | 2.41 MiB/s, done.\nResolving deltas: 100% (7517/7517), done."
},
{
"role": "assistant",
"content": "May be:\nvia git you download files from all branches and you can quickly switch between them, \nvia http you download only master branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why am I getting the message, \"fatal: This operation must be run in a work tree?\"\nJust installed git on Windows. I set the GIT_DIR variable to be c:\\git\\ and verified that this environment variable is maintained by cygwin (i.e. echo $GIT_DIR is what it should be). I went to the folder that I wanted to create the git repository for, let's say c:\\www, and then ran:\ngit init\ngit add .\n\nThen I get the error:\nfatal: This operation must be run in a work tree\n\nI'm not sure what went wrong, but the c:\\git directory has a config file that says:\n[core]\n repositoryformatversion = 0\n filemode = false\n bare = true\n symlinks = false\n ignorecase = true\n\nI'm pretty sure this shouldn't be bare and that's our problem."
},
{
"role": "assistant",
"content": "Also, you are probably inside the .git subfolder, move up one folder to your project root."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --indent-heuristic"
},
{
"role": "assistant",
"content": "Enable the heuristic that shifts diff hunk boundaries to make patches\neasier to read. This is the default."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-for-each-ref"
},
{
"role": "assistant",
"content": "Output information on each ref"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff-index - Compare a tree to the working tree or index -m"
},
{
"role": "assistant",
"content": "By default, files recorded in the index but not checked\nout are reported as deleted. This flag makes git diff-index say that all non-checked-out files are up\nto date."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can you clone GitLab snippets?\n\nIt's easy enough to create them, but I can't find out how to clone them and edit offline.\nIs it possible?"
},
{
"role": "assistant",
"content": "May 2020, for GitLab 13.0: yes!\n\nVersioned Snippets\nSnippets are useful for sharing small bits of code and text that may not belong in the main project’s codebase.\nThese items are important to groups and users who rely on them for other tasks, like scripts to help generate diagnostic output or setup supporting services for testing and demo environments.\nUnfortunately, a lack of version control has made it hard to know if a snippet was the latest version or what changes may have happened and how to reconcile those.\nSnippets in GitLab are now version controlled by a Git repository.\n\n\n\nWhen editing a Snippet, each change creates a commit. Snippets can also be cloned to make edits locally, and then pushed back to the Snippet repository.\nThis is the first step in enabling more collaboration on Snippets.\nIn future releases we’ll introduce support for multiple files, continue to expand features and expand permissions.\n\nSee documentation and issue.\n\nAnd with GitLab 13.5 (October 2020):\n\nSnippets with multiple files\nEngineers often use Snippets to share examples of code, reusable components, logs, and other items. These valuable pieces of information often require additional context and may require more than one file. Sharing a link to multiple files or multiple Snippets makes it challenging for users to piece this context together and understand the scope of what is being presented.\nIn GitLab 13.0, we laid a foundation for Snippets by giving them version control support based on a Git repository. Version control and the history it provides are an important piece of context when looking at code and understanding its purpose, but it may not be everything.\nGitLab now supports multiple files inside of a single Snippet, so you can create Snippets composed of multiple parts. It broadens its use to endless possibilities. For example:\n\nA snippet that includes a script and its output.\nA snippet that includes HTML, CSS, and JS code, from which the result can be easily previewed.\nA snippet with a docker-compose.yml file and its associated .env file.\nA gulpfile.js file coupled with a package.json file, which together are used to bootstrap the project and manage its dependencies.\n\nProviding all of these files in a single Snippet gives more options for the types of content that can be shared and the context that is provided when looking at them. We’re excited to see the types of content you will create and share using Snippets with multiple files!\n\nSee Documentation and Issue.\n\n\n2015: original answer: Not directly.\nGitlab already have snippets section under each project.\nLike: http://gitabhq.com/project-name/snippets/\nBut it is not available for cloning.\nThere was a request for a GitHub Gist-like feature for GitLab (based on Gistie), also asked in GitLab suggestions.\nBut that was not implemented at the time.\n\nUpdate 2019, as commented by eli, and documented in \"Downloading snippets\" (GitLab 10.8+)\n\nFor now its just possible to download snippets, e.g.\nhttps://gitlab.com/snippets/SNIPPET_ID/raw?line_ending=raw –"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to move some files from one git repo to another (not a clone), preserving history\nOur Git repositories started out as parts of a single monster SVN repository where the individual projects each had their own tree like so:\nproject1/branches\n /tags\n /trunk\nproject2/branches\n /tags\n /trunk\n\nObviously, it was pretty easy to move files from one to another with svn mv. But in Git, each project is in its own repository, and today I was asked to move a subdirectory from project2 to project1. I did something like this:\n$ git clone project2 \n$ cd project2\n$ git filter-branch --subdirectory-filter deeply/buried/java/source/directory/A -- --all\n$ git remote rm origin # so I don't accidentally overwrite the repo ;-)\n$ mkdir -p deeply/buried/different/java/source/directory/B\n$ for f in *.java; do \n> git mv $f deeply/buried/different/java/source/directory/B\n> done\n$ git commit -m \"moved files to new subdirectory\"\n$ cd ..\n$\n$ git clone project1\n$ cd project1\n$ git remote add p2 ../project2\n$ git fetch p2\n$ git branch p2 remotes/p2/master\n$ git merge p2 # --allow-unrelated-histories for git 2.9+\n$ git remote rm p2\n$ git push\n\nBut that seems pretty convoluted. Is there a better way to do this sort of thing in general? Or have I adopted the right approach?\nNote that this involves merging the history into an existing repository, rather than simply creating a new standalone repository from part of another one (as in an earlier question)."
},
{
"role": "assistant",
"content": "If your history is sane, you can take the commits out as a patch and apply them in the new repository:\ncd repository\ngit log \\\n --pretty=email \\\n --patch-with-stat \\\n --reverse \\\n --full-index \\\n --binary \\\n -m \\\n --first-parent \\\n -- path/to/file_or_folder \\\n > patch\ncd ../another_repository\ngit am --committer-date-is-author-date < ../repository/patch \n\nOr in one line\ngit log --pretty=email --patch-with-stat --reverse --full-index --binary -m --first-parent -- path/to/file_or_folder | (cd /path/to/new_repository && git am --committer-date-is-author-date)\n\nHint: If commits in the source project’s subdirectory should be extracted to a new repository root directory, git am can be given an argument like -p2 to remove extra directories from the patch.\n(Taken from Exherbo’s docs)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-gc - Cleanup unnecessary files and optimize the local repository gc.autoPackLimit"
},
{
"role": "assistant",
"content": "When there are more than this many packs that are not\nmarked with *.keep file in the repository, git gc\n--auto consolidates them into one larger pack. The\ndefault value is 50. Setting this to 0 disables it.\nSetting gc.auto to 0 will also disable this. See the gc.bigPackThreshold configuration variable below. When in\nuse, it’ll affect how the auto pack limit works."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch -S[<keyid>] --gpg-sign[=<keyid>] --no-gpg-sign"
},
{
"role": "assistant",
"content": "GPG-sign the resulting merge commit. The keyid argument is\noptional and defaults to the committer identity; if specified,\nit must be stuck to the option without a space. --no-gpg-sign is useful to countermand both commit.gpgSign configuration variable,\nand earlier --gpg-sign ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-commit-tree - Create a new commit object"
},
{
"role": "assistant",
"content": "Commit Information A commit encapsulates: all parent object ids author name, email and date committer name and email and the commit time. A commit comment is read from stdin. If a changelog\nentry is not provided via \"<\" redirection, git commit-tree will just wait\nfor one to be entered and terminated with ^D."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-send-email - Send a collection of patches as emails --force"
},
{
"role": "assistant",
"content": "Send emails even if safety checks would prevent it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove and ignore all files that have an extension from a git repository\n\nI'm working on a django project with a few other developers and we have recently realized that all the .pwc files in our app cause the commits and repository to be cluttered.\nIs there any way I can remove all .pwc files from all child directories in my git repository and then ignore them for any future commit?"
},
{
"role": "assistant",
"content": "Plenty of ways to remove them:\ngit ls-files | grep '\\.pwc$' | xargs git rm\n\nfind . -name *.pwc | xargs git rm\n\nNote: If you haven't committed them, just use rm, not git rm.\nTo ignore them in the future, simply add *.pwc to the .gitignore. (If you don't have one, create a file named .gitignore at the top level of your repository, and just add a single line saying \"*.pwc\")"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do Git LFS and git-annex differ?\n\ngit-annex has been around for quite some time, but never really gained momentum.\nGit LFS is rather young and is already supported by GitHub, Bitbucket and GitLab.\nBoth tools handle binary files in git repositories. On the other hand, GitLab seems to have replaced git-annex with Git LFS within one year.\n\nWhat are the technical differences?\nDo they solve the same problem?"
},
{
"role": "assistant",
"content": "They do solve the same problem.\nLet me start off with pro/con, then I'll move into technical differences.\ngit-annex\nPros:\n\nSupports multiple remotes that you can store the binaries.\nCan be used without support from hosting provider (for more details see here).\n\nCons:\n\nWindows support in beta, and has been for a long time\nUsers need to learn separate commands for day-to-day work\nnot supported by github and bitbucket\n\ngit-lfs\nPros:\n\nSupported by github, bitbucket and gitlab\nMost supported on all os's\nEasy to use.\nautomated based on filters\n\nCons:\n\nRequires a custom server implementation to work. A simple ssh remote is not sufficient. Reference server is under development https://github.com/git-lfs/lfs-test-server.\n\nTechnical\ngit-annex\ngit-annex works by creating a symlink in your repo that gets committed. The actual data gets stored into a separate backend (S3, rsync, and MANY others). It is written in haskell. Since it uses symlinks, windows users are forced to use annex in a much different manner, which makes the learning curve higher.\ngit-lfs\nPointer files are written. A git-lfs api is used to write the BLOBs to lfs. A special LFS server is required due to this. Git lfs uses filters so you only have to set up lfs once, and again when you want to specify which types of files you want to push to lfs."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --name-status"
},
{
"role": "assistant",
"content": "Show only names and status of changed files. See the description\nof the --diff-filter option on what the status letters mean.\nJust like --name-only the file names are often encoded in UTF-8."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Multiple Git repositories for each Eclipse project or one Git repository\nI am in the process of moving to Git from SVN. In SVN I had multiple eclipse projects in a single SVN repository that is convenient for browsing projects. I was going to move to having one git repository per eclipse project but EGit suggests doing otherwise.\nThe guide for EGit suggests putting multiple projects into a single Git repository. \nLooking at similar questions such as this suggest one project per repository.\nWhich approach is best practice and what do people implement?"
},
{
"role": "assistant",
"content": "It depends on how closely-related these projects are. Ask yourself the following questions:\n\nWill they always need to be branched/tagged together?\nWill you want to commit over all projects, or does a commit mostly only touch one project?\nDoes the build system operate on all of them or do they have a boundary there?\n\nIf you put them all in one, some things from above will be easier. You will only have to branch/tag/stash/commit in one repository, as opposed to doing it for every repository separately.\nBut if you need to have e.g. separate release cycles for the projects, then it's necessary to have each project in an independent repository.\nNote that you can always split up a repository later, or combine multiple repositories into one again without losing history.\nCombining is a bit harder to do than splitting, so I would go for one repository first and see how it goes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can GitHub show the history of changes made to one file in patch form?\nIf you do git log --patch -- path/to/file, you will get the history of the file along with a diff of all the changes made to it with each commit, like this:\n$ git log --patch -- git-rebase.sh\n\ncommit 20351bb06bf4d32ef3d1a6849d01636f6593339f\nAuthor: Ramkumar Ramachandra <[email protected]>\nDate: Sat Jun 15 18:43:26 2013 +0530\n\n rebase: use 'git stash store' to simplify logic\n\n rebase has no reason to know about the implementation of the stash. In\n the case when applying the autostash results in conflicts, replace the\n relevant code in finish_rebase () to simply call 'git stash store'.\n\n Signed-off-by: Ramkumar Ramachandra <[email protected]>\n Signed-off-by: Junio C Hamano <[email protected]>\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d0c11a9..17be392 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -153,11 +153,8 @@ finish_rebase () {\n then\n echo \"$(gettext 'Applied autostash.')\"\n else\n- ref_stash=refs/stash &&\n- >>\"$GIT_DIR/logs/$ref_stash\" &&\n- git update-ref -m \"autostash\" $ref_stash $stash_sha1 ||\n- die \"$(eval_gettext 'Cannot store $stash_sha1')\"\n-\n+ git stash store -m \"autostash\" -q $stash_sha1 ||\n+ die \"$(eval_gettext \"Cannot store \\$stash_sha1\")\"\n gettext 'Applying autostash resulted in conflicts.\n Your changes are safe in the stash.\n You can run \"git stash pop\" or \"git stash drop\" it at any time.\n\ncommit 2e6e276decde2a9f04fc29bce734a49d3ba8f484\nAuthor: Ramkumar Ramachandra <[email protected]>\nDate: Fri Jun 14 18:47:52 2013 +0530\n\n rebase: use peel_committish() where appropriate\n\n The revisions specified on the command-line as <onto> and <upstream>\n arguments could be of the form :/quuxery; so, use peel_committish() to\n resolve them. The failing tests in t/rebase and t/rebase-interactive\n now pass.\n\n Signed-off-by: Ramkumar Ramachandra <[email protected]>\n Signed-off-by: Junio C Hamano <[email protected]>\n\ndiff --git a/git-rebase.sh b/git-rebase.sh\nindex d0c11a9..6987b9b 100755\n--- a/git-rebase.sh\n+++ b/git-rebase.sh\n@@ -434,7 +434,7 @@ then\n shift\n ;;\n esac\n- upstream=`git rev-parse --verify \"${upstream_name}^0\"` ||\n+ upstream=$(peel_committish \"${upstream_name}\") ||\n die \"$(eval_gettext \"invalid upstream \\$upstream_name\")\"\n upstream_arg=\"$upstream_name\"\n else\n@@ -470,7 +470,7 @@ case \"$onto_name\" in\n fi\n ;;\n *)\n- onto=$(git rev-parse --verify \"${onto_name}^0\") ||\n+ onto=$(peel_committish \"$onto_name\") ||\n die \"$(eval_gettext \"Does not point to a valid commit: \\$onto_name\")\"\n ;;\n esac\n\nI want to be able to get the same kind of format using GitHub's web interface (not the command line), and I want a link to send to someone else without the code."
},
{
"role": "assistant",
"content": "The following URL will show all the commits for a single file in a format similar to git log -p:\nhttp://github.com/<username>/<project>/commits/<branch>/<path/to/file>\n...where:\n\n<username> is the username of the person that owns the repo\n<project> is the repo name\n<branch> can be 'master' or any other branch\n<path/to/file> is hopefully self-explanatory\n\nPicking at (somewhat) random, here is an example from the vim-fugitive repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Difference between git stash pop and git stash apply\nI've been using git stash pop for quite some time. I recently found out about the git stash apply command. When I tried it out, it seemed to work the same as git stash pop. \nWhat is the difference between git stash pop and git stash apply?"
},
{
"role": "assistant",
"content": "git stash pop throws away the (topmost, by default) stash after applying it, whereas git stash apply leaves it in the stash list for possible later reuse (or you can then git stash drop it). \nThis happens unless there are conflicts after git stash pop, in which case it will not remove the stash, leaving it to behave exactly like git stash apply.\nAnother way to look at it: git stash pop is git stash apply && git stash drop."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "VSCode \"please clean your repository working tree before checkout\"\nIn Visual Studio Code I made some changes which I do not want to commit en sync yet. However, after my holiday, I want to sync the files from the server (changes from my colleagues). So In Visual Studio Code I want to do a sync.\nI get a message \"Please clean your repository working tree before checkout\" \nWhat do I need to do to get the files of my colleagues without losing my own uncommitted changes?"
},
{
"role": "assistant",
"content": "In my experience the best way to stash the changes is like so:\n\nsync the changes from your co-workers and afterward do stash-pop like so:\n\nYou may also perform these actions in the terminal:\n\ngit stash\ngit stash pop"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Adds needs relations to GitLab CI yaml but got an error: the job was not added to the pipeline\n\nI am trying to add needs between jobs in the Gitlab CI yaml configuration file.\n\nstages:\n - build\n - test\n - package\n - deploy\n\nmaven-build:\n stage: build\n only:\n - merge_requests\n - master\n - branches\n ...\ntest:\n stage: test\n needs: [ \"maven-build\" ]\n only:\n - merge_requests\n - master\n ...\ndocker-build:\n stage: package\n needs: [ \"test\" ]\n only:\n - master\n ...\ndeploy-stage:\n stage: deploy\n needs: [ \"docker-build\" ]\n only:\n - master\n ...\ndeploy-prod:\n stage: deploy\n needs: [ \"docker-build\" ]\n only:\n - master\n when: manual\n ...\n\n\nI have used the GitLab CI online lint tools to check my syntax, it is correct.\nBut when I pushed the codes, it always complains:\n\n 'test' job needs 'maven-build' job\n but it was not added to the pipeline\n\nYou can also test your .gitlab-ci.yml in CI Lint\n\nThe GitLab CI did not run at all.\nUpdate: Finally I made it. I think the needs position is sensitive, move all needs under the stage, it works. My original scripts included some other configuration between them."
},
{
"role": "assistant",
"content": "CI-jobs that depend on each other need to have the same limitations!\nIn your case that would mean to share the same only targets:\nstages:\n - build\n - test\n\nmaven-build:\n stage: build\n only:\n - merge_requests\n - master\n - branches\n\ntest:\n stage: test\n needs: [ \"maven-build\" ]\n only:\n - merge_requests\n - master\n - branches\n\nthat should work from my experience^^"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub: Permission denied (publickey). fatal: The remote end hung up unexpectedly\nI have followed these instructions below to upload a project. \nGlobal setup:\n Download and install Git\n git config --global user.name \"Your Name\"\n git config --global user.email [email protected]\n Add your public key\n\n\nNext steps:\n\n mkdir tirengarfio\n cd tirengarfio\n git init\n touch README\n git add README\n git commit -m 'first commit'\n git remote add origin [email protected]:tirenga/tirenga.git\n git push origin master\n\nBut I get this error:\n\nPermission denied (publickey). fatal:\n The remote end hung up unexpectedly"
},
{
"role": "assistant",
"content": "I had to add my public key to github. https://help.github.com/articles/generating-ssh-keys"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "does git store diff information in commit objects?\nAccording to this:\n\nIt is important to note that this is very different from most SCM \n systems that you may be familiar with. Subversion, CVS, Perforce, \n Mercurial and the like all use Delta Storage systems - they store \n the differences between one commit and the next. Git does not do \n this - it stores a snapshot of what all the files in your project \n look like in this tree structure each time you commit. This is a \n very important concept to understand when using Git.\n\nYet when I run git show $SHA1ofCommitObject...\ncommit 4405aa474fff8247607d0bf599e054173da84113\nAuthor: Joe Smoe <[email protected]>\nDate: Tue May 1 08:48:21 2012 -0500\n\n First commit\n\ndiff --git a/index.html b/index.html\nnew file mode 100644\nindex 0000000..de8b69b\n--- /dev/null\n+++ b/index.html\n@@ -0,0 +1 @@\n+<h1>Hello World!</h1>\ndiff --git a/interests/chess.html b/interests/chess.html\nnew file mode 100644\nindex 0000000..e5be7dd\n--- /dev/null\n+++ b/interests/chess.html\n@@ -0,0 +1 @@\n+Did you see on Slashdot that King's Gambit accepted is solved! <a href=\"http://game\n\n... it outputs the diff of the commit with the previous commits. I know that git doesn't store diffs in blob objects, but does it store diffs in commit objects? Or is git show dynamically calculating the diff?"
},
{
"role": "assistant",
"content": "What the statement means is that, most other version control systems need a point of reference in the past to be able to re-create the current commit.\nFor example, at some point in the past, a diff-based VCS (version control system) would have stored a full snapshot:\nx = snapshot\n+ = diff\nHistory:\nx-----+-----+-----+-----(+) Where we are now\n\nSo, in such a scenario, to re-create the state at (now), it would have to checkout (x) and then apply diffs for each (+) until it gets to now. Note that it would extremely inefficient to store deltas forever, so every so often, delta based VCSes store a full snapshot. Here's how its done for subversion.\nNow, git is different. Git stores references to complete blobs and this means that with git, only one commit is sufficient to recreate the codebase at that point in time. Git does not need to look up information from past revisions to create a snapshot.\nSo if that is the case, then where does the delta compression that git uses come in?\nWell, it is nothing but a compression concept - there is no point storing the same information twice, if only a tiny amount has changed. Therefore, represent what has changed, but store a reference to it, so that the commit that it belongs to, which is in effect a tree of references, can still be re-created without looking at past commits. The thing is, though, that Git does not do this immediately after every commit, but rather on a garbage collection run. So, if git has not run its garbage collection, you can see objects in your index with very similar content.\nHowever, when Git runs its garbage collection (or when you call git gc manually), then the duplicates are cleaned up and a read only pack file is created. You don't have to worry about running garbage collection manually - git contains heuristics which tell it when to do so."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --expand-tabs=<n> --expand-tabs --no-expand-tabs"
},
{
"role": "assistant",
"content": "Perform a tab expansion (replace each tab with enough spaces\nto fill to the next display column that is a multiple of <n> )\nin the log message before showing it in the output. --expand-tabs is a short-hand for --expand-tabs=8 , and --no-expand-tabs is a short-hand for --expand-tabs=0 ,\nwhich disables tab expansion. By default, tabs are expanded in pretty formats that indent the log\nmessage by 4 spaces (i.e. medium , which is the default, full ,\nand fuller )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-parse - Pick out and massage parameters --show-prefix"
},
{
"role": "assistant",
"content": "When the command is invoked from a subdirectory, show the\npath of the current directory relative to the top-level\ndirectory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to make a GitHub mirror to Bitbucket?\n\nI have a repo that I've cloned from GitHub and want to have a mirror of this repo on BitBucket. Is there is any way how to do it? Something like having two origin in the repo as I think."
},
{
"role": "assistant",
"content": "You could simply add a second remote:\ngit remote add bitbucket /url/to/am/empty/bitbucket/repo\n\nand push everything to bitbucket:\ngit push --mirror bitbucket\n\nYou can actually pull from or push to multiple remotes from your local repo.\n\nUpdate 2020:\nAs noted below in Rahulmohan Kolakandy's answer, if you are talking about an on-premise BitBucket server (as opposed to bitbucket.org), then you can take advantage of BitBucket Server Smart Mirroring.\nAs commented by V-Q-A NGUYEN: \nBitBucket Server Smart Mirroring (introduced originally in 2016, and Oct. 2017 for BitBucket Server)\n\nis only available for customers with an active Bitbucket Data Center license"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-filter-branch - Rewrite branches --original <namespace>"
},
{
"role": "assistant",
"content": "Use this option to set the namespace where the original commits\nwill be stored. The default value is refs/original ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is the difference between a commit and a revision in Git?\nThere are a number of git commands, such as git clone --depth 10 <repo>, that require the number of revisions [git help revisions] to be given. \nWhat is the distinction between a commit and a revision (in git, rather than say svn)?\nOr does it only show up in the plural when trying to count revisions/commits, e.g. that revisons must be counted by walking the DAG (directed acyclic graph) of commits and their parents, or some other careful distinction?"
},
{
"role": "assistant",
"content": "See \"SPECIFYING REVISIONS\" of git rev-parse:\n\nA revision parameter <rev> typically, but not necessarily, names a commit object.\n It uses what is called an extended SHA1 syntax, [and includes] various ways to spell object names. \n\nSo \"revision\" refers to the id you can use as a parameter to reference an object in git (usually a commit).\nHEAD@{5 minutes ago} is a revision which reference the commit present 5 minutes ago.\ngitrevision mentions:\n\n[...] some Git commands (such as git show) also take revision parameters which denote other objects than commits, e.g. blobs (\"files\") or trees (\"directories of files\"). \n\nFor instance, the following rev parameter doesn't reference a commit:\n<rev>:<path>, e.g. HEAD:README, :README, master:./README\n\n\nA suffix : followed by a path names the blob or tree at the given path in the tree-ish object named by the part before the colon.\n\n\nA \"commit\" in Git generally designates a \"commit object\" (as described in git commit-tree for instance):\n\nA commit encapsulates:\n\nall parent object ids\nauthor name, email and date\ncommitter name and email and the commit time.\n\n\n\nSo:\n\na commit designates one of the git objects (others are blobs, tree, tags, notes),\na revision is a way to reference a git object.\n\n\nIn your case (git clone) --depth <n> does:\n\nCreate a shallow clone with a history truncated to the specified number of revisions. \n\nIt is for all the commits accessible at that depth, up to n revisions per path in the DAG.\nSince the result can be more than n commits, the term revision is more adapted here in order to emphasize you don't want just n commits, but any commits referenced by a max of n revisions accessible.\nHowever, in this context, revisions clearly reference only commits (as illustrated below) reachable (as you mentioned in \"Is git clone --depth 1 (shallow clone) more useful than it makes out?\"). \nThe question is \"reachable from what\"? \nYou referenced this thread which included:\n\nIIRC, --depth=<n> is not \"deepen by <n>\", but \"make sure I have at least <n> from the updated tip(s)\".\n The shallow-clone hack gives you quite useless (even though it may be internally consistent) semantics if you shallow-cloned way in the past and fetched with --depth after the other side added many more commits than <n>, as you cannot guess what the right\n value of <n> should be without actually fetching without --depth."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Retrieve specific commit from a remote Git repository\nIs there any way to retrieve only one specific commit from a remote Git repo without cloning it on my PC? The structure of remote repo is absolutely same as that of mine and hence there won't be any conflicts but I have no idea how to do this and I don't want to clone that huge repository.\nI am new to git, is there any way?"
},
{
"role": "assistant",
"content": "Starting with Git version 2.5+ (Q2 2015), fetching a single commit (without cloning the full repo) is actually possible.\nSee commit 68ee628 by Fredrik Medley (moroten), 21 May 2015.\n(Merged by Junio C Hamano -- gitster -- in commit a9d3493, 01 Jun 2015)\nYou now have a new config (on the server side)\nuploadpack.allowReachableSHA1InWant\n\n\nAllow upload-pack to accept a fetch request that asks for an object that is reachable from any ref tip. However, note that calculating object reachability is computationally expensive.\nDefaults to false.\n\nIf you combine that server-side configuration with a shallow clone (git fetch --depth=1), you can ask for a single commit (see t/t5516-fetch-push.sh:\ngit fetch --depth=1 ../testrepo/.git <full-length SHA1>\n\nYou can use the git cat-file command to see that the commit has been fetched:\ngit cat-file commit <full-length SHA1>\n\n\n\"git upload-pack\" that serves \"git fetch\" can be told to serve\ncommits that are not at the tip of any ref, as long as they are\nreachable from a ref, with uploadpack.allowReachableSHA1InWant\nconfiguration variable.\n\nAs noted by matt in the comments:\n\nNote that SHA must be the full unabbreviated SHA, otherwise Git will claim it couldn't find the commit\n\n\nThe full documentation is:\n\nupload-pack: optionally allow fetching reachable sha1\n\n\nWith uploadpack.allowReachableSHA1InWant configuration option set on the server side, \"git fetch\" can make a request with a \"want\" line that names an object that has not been advertised (likely to have been obtained out of band or from a submodule pointer).\nOnly objects reachable from the branch tips, i.e. the union of advertised branches and branches hidden by transfer.hideRefs, will be processed.\nNote that there is an associated cost of having to walk back the history to check the reachability.\nThis feature can be used when obtaining the content of a certain commit,\nfor which the sha1 is known, without the need of cloning the whole\nrepository, especially if a shallow fetch is used.\nUseful cases are e.g.\n\nrepositories containing large files in the history,\nfetching only the needed data for a submodule checkout,\nwhen sharing a sha1 without telling which exact branch it belongs to and in Gerrit, if you think in terms of commits instead of change numbers.\n(The Gerrit case has already been solved through allowTipSHA1InWant as every Gerrit change has a ref.)\n\n\n\nGit 2.6 (Q3 2015) will improve that model.\nSee commit 2bc31d1, commit cc118a6 (28 Jul 2015) by Jeff King (peff).\n(Merged by Junio C Hamano -- gitster -- in commit 824a0be, 19 Aug 2015)\n\nrefs: support negative transfer.hideRefs\n\n\nIf you hide a hierarchy of refs using the transfer.hideRefs config, there is no way to later override that config to \"unhide\" it.\nThis patch implements a \"negative\" hide which causes matches to immediately be marked as unhidden, even if another match would hide it.\nWe take care to apply the matches in reverse-order from how they are fed to us by the config machinery, as that lets our usual \"last one wins\" config precedence work (and entries in .git/config, for example, will override /etc/gitconfig).\nSo you can now do:\ngit config --system transfer.hideRefs refs/secret\ngit config transfer.hideRefs '!refs/secret/not-so-secret'\n\nto hide refs/secret in all repos, except for one public bit\nin one specific repo.\n\n\nGit 2.7 (Nov/Dec 2015) will improve again:\nSee commit 948bfa2, commit 00b293e (05 Nov 2015), commit 78a766a, commit 92cab49, commit 92cab49, commit 92cab49 (03 Nov 2015), commit 00b293e, commit 00b293e (05 Nov 2015), and commit 92cab49, commit 92cab49, commit 92cab49, commit 92cab49 (03 Nov 2015) by Lukas Fleischer (lfos).\nHelped-by: Eric Sunshine (sunshineco).\n(Merged by Jeff King -- peff -- in commit dbba85e, 20 Nov 2015)\n\nconfig.txt: document the semantics of hideRefs with namespaces\n\n\nRight now, there is no clear definition of how transfer.hideRefs should\nbehave when a namespace is set.\nExplain that hideRefs prefixes match stripped names in that case. This is how hideRefs patterns are currently\nhandled in receive-pack.\n\n\nhideRefs: add support for matching full refs\n\n\nIn addition to matching stripped refs, one can now add hideRefs patterns that the full (unstripped) ref is matched against.\nTo distinguish between stripped and full matches, those new patterns must be prefixed with a circumflex (^).\n\nHence the new documentation:\ntransfer.hideRefs:\n\n\nIf a namespace is in use, the namespace prefix is stripped from each reference before it is matched against transfer.hiderefs patterns.\nFor example, if refs/heads/master is specified in transfer.hideRefs and\nthe current namespace is foo, then refs/namespaces/foo/refs/heads/master\nis omitted from the advertisements but refs/heads/master and\nrefs/namespaces/bar/refs/heads/master are still advertised as so-called\n\"have\" lines.\nIn order to match refs before stripping, add a ^ in front of\nthe ref name. If you combine ! and ^, ! must be specified first.\n\n\nR.. mentions in the comments the config uploadpack.allowAnySHA1InWant, which allows upload-pack to accept a fetch request that asks for any object at all. (Defaults to false).\nSee commit f8edeaa (Nov. 2016, Git v2.11.1) by David \"novalis\" Turner (novalis):\n\nupload-pack: optionally allow fetching any sha1\n\n\nIt seems a little silly to do a reachabilty check in the case where we\ntrust the user to access absolutely everything in the repository.\nAlso, it's racy in a distributed system -- perhaps one server\nadvertises a ref, but another has since had a force-push to that ref,\nand perhaps the two HTTP requests end up directed to these different\nservers.\n\n\nWith Git 2.34 (Q4 2021), \"git upload-pack\"(man) which runs on the other side of git fetch(man) forgot to take the ref namespaces into account when handling want-ref requests.\nSee commit 53a66ec, commit 3955140, commit bac01c6 (13 Aug 2021) by Kim Altintop (kim).\n(Merged by Junio C Hamano -- gitster -- in commit 1ab13eb, 10 Sep 2021)\n\ndocs: clarify the interaction of transfer.hideRefs and namespaces\nSigned-off-by: Kim Altintop\nReviewed-by: Jonathan Tan\n\n\nExpand the section about namespaces in the documentation of transfer.hideRefs to point out the subtle differences between upload-pack and receive-pack.\n3955140 (\"upload-pack.c: treat want-ref relative to namespace\", 2021-07-30, Git v2.34.0 -- merge listed in batch #5) taught upload-pack to reject want-refs for hidden refs, which is now mentioned.\nIt is clarified that at no point the name of a hidden ref is revealed, but the object id it points to may.\n\ngit config now includes in its man page:\n\nreference before it is matched against transfer.hiderefs patterns. In\norder to match refs before stripping, add a ^ in front of the ref name. If\nyou combine ! and ^, ! must be specified first.\n\ngit config now includes in its man page:\n\nis omitted from the advertisements. If uploadpack.allowRefInWant is set,\nupload-pack will treat want-ref refs/heads/master in a protocol v2\nfetch command as if refs/namespaces/foo/refs/heads/master did not exist.\nreceive-pack, on the other hand, will still advertise the object id the\nref is pointing to without mentioning its name (a so-called \".have\" line).\n\n\nWith Git 2.39 (Q4 2022), \"git receive-pack\"(man) used to use all the local refs as the boundary for checking connectivity of the data git push(man) sent, but now it uses only the refs that it advertised to the pusher.\nIn a repository with the .hideRefs configuration, this reduces the resources needed to perform the check.\nSee commit bcec678, commit 5ff36c9, commit 8c1bc2a, commit 1e9f273, commit 05b9425, commit 9b67eb6, commit 5eeb9aa (17 Nov 2022) by Patrick Steinhardt (pks-t).\n(Merged by Junio C Hamano -- gitster -- in commit f8828f9, 23 Nov 2022)\n\nrevision: add new parameter to exclude hidden refs\nSigned-off-by: Patrick Steinhardt\nSigned-off-by: Taylor Blau\n\n\nUsers can optionally hide refs from remote users in git-upload-pack(1), git-receive-pack(1) and others via the transfer.hideRefs, but there is not an easy way to obtain the list of all visible or hidden refs right now.\nWe'll require just that though for a performance improvement in our connectivity check.\nAdd a new option --exclude-hidden= that excludes any hidden refs from the next pseudo-ref like --all or --branches.\n\nrev-list-options now includes in its man page:\n\n--exclude-hidden=[receive|uploadpack]\nDo not include refs that would be hidden by git-receive-pack or\ngit-upload-pack by consulting the appropriate receive.hideRefs or\nuploadpack.hideRefs configuration along with transfer.hideRefs (see\ngit config). This option affects the next pseudo-ref option\n--all or --glob and is cleared after processing them.\n\nAnd:\n\nrev-parse: add --exclude-hidden= option\nSigned-off-by: Patrick Steinhardt\nSigned-off-by: Taylor Blau\n\n\nAdd a new --exclude-hidden= option that is similar to the one we just added to git-rev-list(1).\nGiven a section name uploadpack or receive as argument, it causes us to exclude all references that would be hidden by the respective $section.hideRefs configuration.\n\ngit rev-parse now includes in its man page:\n\n--exclude-hidden=[receive|uploadpack]\nDo not include refs that would be hidden by git-receive-pack or\ngit-upload-pack by consulting the appropriate receive.hideRefs or\nuploadpack.hideRefs configuration along with transfer.hideRefs (see\ngit config). This option affects the next pseudo-ref option\n--all or --glob and is cleared after processing them."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to make one job only run after another job passes in a GitLab pipeline\n\nFrom what I have just ran into, the \"needs\" line in a gitlab-ci.yml file only checks to see if the job that is defined in the \"needs\" line is being run - not if it passes or fails.\nI ran the below code in my pipeline and the \"build-latest\" job runs even if the \"test-\ntag\" job fails.\nI only want the \"build-latest\" job to run if the \"test-tag\" job passes.\nHow is this achieved?\nbuild-latest:\n stage: publish\n image:\n name: gcr.io/go-containerregistry/crane:debug\n entrypoint: [\"\"]\n rules:\n #- if: $CI_COMMIT_TAG != null\n - if: $CI_COMMIT_REF_NAME == \"add-latest-tagging\"\n when: always\n needs:\n - test-tag\n script:\n - crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY"
},
{
"role": "assistant",
"content": "The issue lies with the fact that you added\nwhen: always\n\nIt is true that since you specified needs, the build-latest job will need the job test-tag to execute first.\n\nAfter test-tag job concluded it will evaluate if it should execute the build-latest job.\nBy adding the always clause to the build-latest job will force it to execute, even if the test-tag fails. Provided test-tag job has at least concluded\n\nLong story sort, you should remove the when always clause"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Switch Git branch without files checkout\nIs it possible in Git to switch to another branch without checking out all files?\nAfter switching branch I need to delete all files, regenerate them, commit and switch back. So checking out files is just a waste of time (and there are about 14,000 files - it is a long operation).\nTo make everything clear:\nI need all this to upload documentation to GitHub.\nI have a repository with the gh-pages branch. When I rebuild documentation locally, I copy it to the repository directory, commit and push to GitHub. But I was not happy, because I had two copies of documentation locally. And I decided to create an empty branch and after committing, switch to empty and delete files. But switching back is a long operation - so I asked this question.\nI know that I can just leave on the gh-pages branch and delete files, but I don't like dirty working trees."
},
{
"role": "assistant",
"content": "Yes, you can do this.\ngit symbolic-ref HEAD refs/heads/otherbranch\n\nIf you need to commit on this branch, you'll want to reset the index too otherwise you'll end up committing something based on the last checked out branch.\ngit reset"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-svn - Bidirectional operation between a Subversion repository and Git --commit-url"
},
{
"role": "assistant",
"content": "Use the specified URL to connect to the destination Subversion\nrepository. This is useful in cases where the source SVN\nrepository is read-only. This option overrides configuration\nproperty commiturl . git config --get-all svn-remote.<name>.commiturl"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to delete all Git commits except the last five\nI have a very large Git repository which only contains binary files which are changed pretty often. Naturally the Git repository is much larger than the actual files in it. I don't really care about old history, I only need some of the newer history to be able to revert some wrong changes. So let's say I want to remove all commits except the last five. \nNaturally I want to do this to keep the repository small so the removed commits must be purged completely from the repo.\nAnd I want to do all this non-interactively with a single command (alias) or script. How can I do this?"
},
{
"role": "assistant",
"content": "Here's an rebase-last-five alias to get you started. It will recreate the current branch so only the most recent five commits are in the history. It's probably best to make this a script (git-rebase-last-five.sh) that is available in a directory on your PATH; Git will find and use scripts named git-....sh without the need for any special configuration. The script should do more error checking and handling than this simple alias.\n$ git config --global alias.rebase-last-five '!b=\"$(git branch --no-color | cut -c3-)\" ; h=\"$(git rev-parse $b)\" ; echo \"Current branch: $b $h\" ; c=\"$(git rev-parse $b~4)\" ; echo \"Recreating $b branch with initial commit $c ...\" ; git checkout --orphan new-start $c ; git commit -C $c ; git rebase --onto new-start $c $b ; git branch -d new-start ; git gc'\n\nCAVEAT EMPTOR: Do heed the warnings about changing history.\nCheck the man pages (git help <command> or online) for further information.\nAn example usage:\n$ git --version\ngit version 1.7.12.rc2.16.g034161a\n$ git log --all --graph --decorate --oneline\n* e4b2337 (HEAD, master) 9\n* e508980 8\n* 01927dd 7\n* 75c0fdb 6\n* 20edb42 5\n* 1260648 4\n* b3d6cc8 3\n* 187a0ef 2\n* e5d09cf 1\n* 07bf1e2 initial\n$ git rebase-last-five \nCurrent branch: master e4b2337ef33d446bbb48cbc86b44afc964ba0712\nRecreating master branch with initial commit 20edb42a06ae987463016e7f2c08e9df10fd94a0 ...\nSwitched to a new branch 'new-start'\n[new-start (root-commit) 06ed4d5] 5\n 1 file changed, 1 insertion(+)\n create mode 100644 A\nFirst, rewinding head to replay your work on top of it...\nApplying: 6\nApplying: 7\nApplying: 8\nApplying: 9\nDeleted branch new-start (was 06ed4d5).\nCounting objects: 35, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (15/15), done.\nWriting objects: 100% (35/35), done.\nTotal 35 (delta 4), reused 0 (delta 0)\n$ git log --all --graph --decorate --oneline\n* a7fb54b (HEAD, master) 9\n* 413e5b0 8\n* 638a1ae 7\n* 9949c28 6\n* 06ed4d5 5"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitk"
},
{
"role": "assistant",
"content": "The Git repository browser"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Undo a git stash\nI just did a stash in a project that I haven't commit. Is there a way to go back to the state before I stashed? How could I do this? I've closed the terminal and my laptop is shut down. I've done some researched and it seems there's no way to do this."
},
{
"role": "assistant",
"content": "You can just run:\ngit stash pop\n\nand it will unstash your changes.\nIf you want to preserve the state of files (staged vs. working), use \ngit stash apply --index"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Change Fork Name For Github\n\nI recently had an idea for a project. I found a project identical to the one I want to create on Github. I got very lucky because the person just started so there is a base, but everything is very raw and perfect for adding onto. \nI made a fork of the project and made a big mistake. After I cloned the fork and committed changes to it I realized I wanted to rename the fork. Obviously this would have been easier to do from the start.\nThese are instructions from Github itself\n\nWhen you rename a repository, its issues, wiki, stars, and followers\n are preserved. Forks continue to point to the root repository.\nHowever, redirects are not set up for links that point to the old\n location. You will need to update your local repositories to point to\n the new location.\n\nWhich is great, i can simply rename the fork on Github but that leaves me repositories with the old links. How can I update my local repositories?"
},
{
"role": "assistant",
"content": "If you haven't renamed already, you can just push all pending changes, rename, and just clone again.\nIf you've already renamed, you should just update the origin on your local repos:\ngit remote set-url origin git://github.com/youruser/yourrepo"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options branch.<name>.remote"
},
{
"role": "assistant",
"content": "When on branch <name>, it tells git fetch and git push which remote to fetch from or push to. The remote to push to\nmay be overridden with remote.pushDefault (for all branches).\nThe remote to push to, for the current branch, may be further\noverridden by branch.<name>.pushRemote . If no remote is\nconfigured, or if you are not on any branch and there is more than\none remote defined in the repository, it defaults to origin for\nfetching and remote.pushDefault for pushing.\nAdditionally, . (a period) is the current local repository\n(a dot-repository), see branch.<name>.merge 's final note below."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I have multiple working directories with Git?\nI'm not sure if this is something supported by Git, but in theory it seems like it should work to me.\nMy workflow often involves my editing of files in multiple branches simultaneously. In other words, I often want to open a few files in one branch is while I edit the contents of another file in another branch.\nMy typical solution to this is to make two checkouts, but it's a shame I can't share branches and refs between them. What I would like is to just have two working directories managed by the same .git folder.\nI'm aware of local git clone solutions (the default, which is to hardlink shared objects, and the --shared option, which sets up an alternate object store with the original repo), but these solutions only cut down on disk space usage, and especially in the case of --shared, seem fraught with peril.\nIs there a way to use one .git folder, and have two working directories backed by it? Or is Git hardcoded to have just one working directory checked out at any time?"
},
{
"role": "assistant",
"content": "Git 2.5 proposes since July 2015 a replacement for contrib/workdir/git-new-workdir: git worktree\nSee commit 68a2e6a by Junio C Hamano (gitster).\nThe release note mentions:\n\nA replacement for contrib/workdir/git-new-workdir that does not rely on symbolic links and make sharing of objects and refs safer by making the borrowee and borrowers aware of each other.\n\nSee commit 799767cc9 (Git 2.5rc2)\nThat means you now can do a git worktree add <path> [<branch>]\n\nCreate <path> and checkout <branch> into it. The new working directory\nis linked to the current repository, sharing everything except working\ndirectory specific files such as HEAD, index, etc.\nThe git worktree section adds:\nA git repository can support multiple working trees, allowing you to check out more than one branch at a time.\nWith git worktree add, a new working tree is associated with the repository.\nThis new working tree is called a \"linked working tree\" as opposed to the \"main working tree\" prepared by \"git init\" or \"git clone\".\nA repository has one main working tree (if it's not a bare repository) and zero or more linked working trees.\n\n\ndetails:\n\n\nEach linked working tree has a private sub-directory in the repository's\n$GIT_DIR/worktrees directory.\nThe private sub-directory's name is usually the base name of the linked working tree's path, possibly appended with a number to make it unique.\nFor example, when $GIT_DIR=/path/main/.git the command git worktree add /path/other/test-next next creates:\n\nthe linked working tree in /path/other/test-next and\nalso creates a $GIT_DIR/worktrees/test-next directory (or $GIT_DIR/worktrees/test-next1 if test-next is already taken).\n\nWithin a linked working tree:\n\n$GIT_DIR is set to point to this private directory (e.g. /path/main/.git/worktrees/test-next in the example) and\n$GIT_COMMON_DIR is set to point back to the main working tree's $GIT_DIR (e.g. /path/main/.git).\n\nThese settings are made in a .git file located at the top directory of the linked working tree.\nWhen you are done with a linked working tree you can simply delete it.\nThe working tree's administrative files in the repository will eventually be removed automatically (see gc.pruneworktreesexpire in git config), or you can run git worktree prune in the main or any linked working tree to\nclean up any stale administrative files.\n\n\nWarning: there is still a git worktree \"BUGS\" section to be aware of.\n\nThe support for submodules is incomplete.\nIt is NOT recommended to make multiple checkouts of a superproject.\n\n\nNote: with git 2.7rc1 (Nov 2015) you are able to list your worktrees.\nSee commit bb9c03b, commit 92718b7, commit 5193490, commit 1ceb7f9, commit 1ceb7f9, commit 5193490, commit 1ceb7f9, commit 1ceb7f9 (08 Oct 2015), commit 92718b7, commit 5193490, commit 1ceb7f9, commit 1ceb7f9 (08 Oct 2015), commit 5193490, commit 1ceb7f9 (08 Oct 2015), commit 1ceb7f9 (08 Oct 2015), and commit ac6c561 (02 Oct 2015) by Michael Rappazzo (rappazzo).\n(Merged by Junio C Hamano -- gitster -- in commit a46dcfb, 26 Oct 2015)\n\nworktree: add 'list' command\n\n\n'git worktree list' iterates through the worktree list, and outputs\ndetails of the worktree including the path to the worktree, the currently\nchecked out revision and branch, and if the work tree is bare.\n$ git worktree list\n/path/to/bare-source (bare)\n/path/to/linked-worktree abcd1234 [master]\n/path/to/other-linked-worktree 1234abc (detached HEAD)\nThere is also porcelain format option available.\nThe porcelain format has a line per attribute.\n\nAttributes are listed with a label and value separated by a single space.\nBoolean attributes (like 'bare' and 'detached') are listed as a label only, and are only present if and only if the value is true.\nAn empty line indicates the end of a worktree\n\n\nFor instance:\n$ git worktree list --porcelain\n\nworktree /path/to/bare-source\nbare\n\nworktree /path/to/linked-worktree\nHEAD abcd1234abcd1234abcd1234abcd1234abcd1234\nbranch refs/heads/master\n\nworktree /path/to/other-linked-worktree\nHEAD 1234abc1234abc1234abc1234abc1234abc1234a\ndetached\n\n\nNote: if you MOVE a worktree folder, you need to manually update the gitdir file.\nSee commit 618244e (22 Jan 2016), and commit d4cddd6 (18 Jan 2016) by Nguyễn Thái Ngọc Duy (pclouds).\nHelped-by: Eric Sunshine (sunshineco).\n(Merged by Junio C Hamano -- gitster -- in commit d0a1cbc, 10 Feb 2016)\nThe new doc in git 2.8 (March 2016) will include:\n\nIf you move a linked working tree, you need to update the 'gitdir' file\nin the entry's directory.\nFor example, if a linked working tree is moved to /newpath/test-next and its .git file points to /path/main/.git/worktrees/test-next, then update\n/path/main/.git/worktrees/test-next/gitdir to reference /newpath/test-next instead.\n\n\nBe careful when deleting a branch: before git 2.9 (June 2016), you could delete one in use in another working tree.\n\nWhen \"git worktree\" feature is in use, \"git branch -d\" allowed\ndeletion of a branch that is checked out in another worktree.\n\nSee commit f292244 (29 Mar 2016) by Kazuki Yamaguchi (rhenium).\nHelped-by: Eric Sunshine (sunshineco).\n(Merged by Junio C Hamano -- gitster -- in commit 4fca4e3, 13 Apr 2016)\n\nbranch -d: refuse deleting a branch which is currently checked out\n\n\nWhen a branch is checked out by current working tree, deleting the\nbranch is forbidden.\nHowever when the branch is checked out only by other working trees, deleting incorrectly succeeds.\nUse find_shared_symref() to check if the branch is in use, not just\ncomparing with the current working tree's HEAD.\n\n\nSimilarly, before git 2.9 (June 2016), renaming a branch checked out in another worktree did not adjust the symbolic HEAD in said other worktree.\nSee commit 18eb3a9 (08 Apr 2016), and commit 70999e9, commit 2233066 (27 Mar 2016) by Kazuki Yamaguchi (rhenium).\n(Merged by Junio C Hamano -- gitster -- in commit 741a694, 18 Apr 2016)\n\nbranch -m: update all per-worktree HEADs\n\n\nWhen renaming a branch, currently only the HEAD of current working tree\nis updated, but it must update HEADs of all working trees which point at\nthe old branch.\nThis is the current behavior, /path/to/wt's HEAD is not updated:\n % git worktree list\n /path/to 2c3c5f2 [master]\n /path/to/wt 2c3c5f2 [oldname]\n % git branch -m master master2\n % git worktree list\n /path/to 2c3c5f2 [master2]\n /path/to/wt 2c3c5f2 [oldname]\n % git branch -m oldname newname\n % git worktree list\n /path/to 2c3c5f2 [master2]\n /path/to/wt 0000000 [oldname]\n\nThis patch fixes this issue by updating all relevant worktree HEADs\nwhen renaming a branch.\n\n\nThe locking mechanism is officially supported with git 2.10 (Q3 2016)\nSee commit 080739b, commit 6d30862, commit 58142c0, commit 346ef53, commit 346ef53, commit 58142c0, commit 346ef53, commit 346ef53 (13 Jun 2016), and commit 984ad9e, commit 6835314 (03 Jun 2016) by Nguyễn Thái Ngọc Duy (pclouds).\nSuggested-by: Eric Sunshine (sunshineco).\n(Merged by Junio C Hamano -- gitster -- in commit 2c608e0, 28 Jul 2016)\ngit worktree lock [--reason <string>] <worktree>\ngit worktree unlock <worktree>\n\n\nIf a linked working tree is stored on a portable device or network share\nwhich is not always mounted, you can prevent its administrative files from\nbeing pruned by issuing the git worktree lock command, optionally\nspecifying --reason to explain why the working tree is locked.\n<worktree>: If the last path components in the working tree's path is unique among working trees, it can be used to identify worktrees.\nFor example if you only have to working trees at \"/abc/def/ghi\" and \"/abc/def/ggg\", then \"ghi\" or \"def/ghi\" is enough to point to the former working tree.\n\n\nGit 2.13 (Q2 2017) add a lock option in commit 507e6e9 (12 Apr 2017) by Nguyễn Thái Ngọc Duy (pclouds).\nSuggested-by: David Taylor (dt).\nHelped-by: Jeff King (peff).\n(Merged by Junio C Hamano -- gitster -- in commit e311597, 26 Apr 2017)\n\nAllow to lock a worktree immediately after it's created.\nThis helps prevent a race between \"git worktree add; git worktree lock\" and\n\"git worktree prune\".\n\nSo git worktree add' --lock is the equivalent of git worktree lock after git worktree add, but without race condition.\n\nGit 2.17+ (Q2 2018) adds git worktree move / git worktree remove: see this answer.\n\nGit 2.19 (Q3 2018) add a \"--quiet\" option to make \"git worktree add\" less\nverbose.\nSee commit 371979c (15 Aug 2018) by Elia Pinto (devzero2000).\nHelped-by: Martin Ågren [email protected], Duy Nguyen (pclouds), and Eric Sunshine (sunshineco).\n(Merged by Junio C Hamano -- gitster -- in commit a988ce9, 27 Aug 2018)\n\nworktree: add --quiet option\n\n\nAdd the '--quiet' option to git worktree, as for the other git commands.\n'add' is the only command affected by it since all other commands, except 'list', are currently silent by default.\n\n\nNote that \"git worktree add\" used to do a \"find an available name with stat\nand then mkdir\", which is race-prone.\nThis has been fixed with Git 2.22 (Q2 2019) by using mkdir and reacting to EEXIST in a loop.\nSee commit 7af01f2 (20 Feb 2019) by Michal Suchanek (hramrach).\n(Merged by Junio C Hamano -- gitster -- in commit 20fe798, 09 Apr 2019)\n\nworktree: fix worktree add race\n\n\nGit runs a stat loop to find a worktree name that's available and\nthen does mkdir on the found name.\nTurn it to mkdir loop to avoid another invocation of worktree add finding the same free name and creating the directory first.\n\n\nGit 2.22 (Q2 2019) fixes the logic to tell if a Git repository has a working tree protects \"git branch -D\" from removing the branch that is currently checked\nout by mistake.\nThe implementation of this logic was broken for repositories with unusual name, which unfortunately is the norm for submodules these days.\nSee commit f3534c9 (19 Apr 2019) by Jonathan Tan (jhowtan).\n(Merged by Junio C Hamano -- gitster -- in commit ec2642a, 08 May 2019)\n\nworktree: update is_bare heuristics\n\n\nWhen \"git branch -D <name>\" is run, Git usually first checks if that\nbranch is currently checked out.\nBut this check is not performed if the Git directory of that repository is not at \"<repo>/.git\", which is the case if that repository is a submodule that has its Git directory stored as \"super/.git/modules/<repo>\", for example.\nThis results in the branch being deleted even though it is checked out.\nThis is because get_main_worktree() in worktree.c sets is_bare on a\nworktree only using the heuristic that a repo is bare if the worktree's\npath does not end in \"/.git\", and not bare otherwise.\nThis is_bare code was introduced in 92718b7 (\"worktree: add details to the worktree struct\", 2015-10-08, Git v2.7.0-rc0), following a pre-core.bare heuristic.\nThis patch does 2 things:\n\nTeach get_main_worktree() to use is_bare_repository() instead, introduced in 7d1864c (\"Introduce is_bare_repository() and core.bare configuration variable\", 2007-01-07, Git v1.5.0-rc1) and updated in e90fdc3 (\"Clean up work-tree handling\", 2007-08-01, Git v1.5.3-rc4).\nThis solves the \"git branch -D <name>\" problem described above.\nHowever...\nIf a repository has core.bare=1 but the \"git\" command is being run from one of its secondary worktrees, is_bare_repository() returns false (which is fine, since there is a worktree available).\nAnd, treating the main worktree as non-bare when it is bare causes issues: for example, failure to delete a branch from a secondary worktree that is referred to by a main worktree's HEAD, even if that main worktree is bare.\n\nIn order to avoid that, also check core.bare when setting is_bare.\nIf core.bare=1, trust it, and otherwise, use is_bare_repository().\n\n\nWith Git 2.29 (Q4 2020), the \"worktree\" API offers a better determination of a worktree path.\nSee commit 918d8ff, commit 1c4854e, commit 246756f, commit 62573a5 (31 Jul 2020) by Eric Sunshine (sunshineco).\n(Merged by Junio C Hamano -- gitster -- in commit 197253e, 10 Aug 2020)\n\nworktree: drop bogus and unnecessary path munging\nSigned-off-by: Eric Sunshine\n\n\nThe content of .git/worktrees/<id>/gitdir must be a path of the form \"/path/to/worktree/.git\".\nAny other content would be indicative of a corrupt \"gitdir\" file.\nTo determine the path of the worktree itself one merely strips the \"/.git\" suffix, and this is indeed how the worktree path was determined from inception.\nHowever, 5193490442 (\"worktree: add a function to get worktree details\", 2015-10-08, Git v2.7.0-rc0 -- merge listed in batch #7) extended the path manipulation in a mysterious way.\nIf it is unable to strip \"/.git\" from the path, then it instead reports the current working directory as the linked worktree's path:\nif (!strbuf_strip_suffix(&worktree_path, \"/.git\")) {\n strbuf_reset(&worktree_path);\n strbuf_add_absolute_path(&worktree_path, \".\");\n strbuf_strip_suffix(&worktree_path, \"/.\");\n} \n\nThis logic is clearly bogus; it can never be generally correct behavior. It materialized out of thin air in 5193490442 with neither explanation nor tests to illustrate a case in which it would be desirable.\nIt's possible that this logic was introduced to somehow deal with a corrupt \"gitdir\" file, so that it returns some sort of meaningful value, but returning the current working directory is not helpful. In fact, it is quite misleading (except in the one specific case when the current directory is the worktree whose \"gitdir\" entry is corrupt).\nMoreover, reporting the corrupt value to the user, rather than fibbing about it and hiding it outright, is more helpful since it may aid in diagnosing the problem.\nTherefore, drop this bogus path munging and restore the logic to the original behavior of merely stripping \"/.git\"."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.