messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --show-pulls"
},
{
"role": "assistant",
"content": "In addition to the commits shown in the default history, show\neach merge commit that is not TREESAME to its first parent but\nis TREESAME to a later parent. When a merge commit is included by --show-pulls , the merge is\ntreated as if it \"pulled\" the change from another branch. When using --show-pulls on this example (and no other options) the resulting\ngraph is: I---X---R---N Here, the merge commits R and N are included because they pulled\nthe commits X and R into the base branch, respectively. These\nmerges are the reason the commits A and B do not appear in the\ndefault history. When --show-pulls is paired with --simplify-merges , the\ngraph includes all of the necessary information: .-A---M--. N\n\t / / \\ /\n\tI B R\n\t \\ / /\n\t \\ / /\n\t `---X--' Notice that since M is reachable from R , the edge from N to M was simplified away. However, N still appears in the history as an\nimportant commit because it \"pulled\" the change R into the main\nbranch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files checkout.guess"
},
{
"role": "assistant",
"content": "Provides the default value for the --guess or --no-guess option in git checkout and git switch . See git-switch and git-checkout ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-apply - Apply a patch to files and/or to the index -3 --3way"
},
{
"role": "assistant",
"content": "Attempt 3-way merge if the patch records the identity of blobs it is supposed\nto apply to and we have those blobs available locally, possibly leaving the\nconflict markers in the files in the working tree for the user to\nresolve. This option implies the --index option unless the --cached option is used, and is incompatible with the --reject option.\nWhen used with the --cached option, any conflicts are left at higher stages\nin the cache."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "When to delete branches in Git?\nSuppose we have an application that's stable. \nTomorrow, someone reports a big ol' bug that we decide to hotfix right away. So we create a branch for that hotfix off of \"master\", we name it \"2011_Hotfix\", and we push it up so that all of the developers can collaborate on fixing it.\nWe fix the bug, and merge \"2011_Hotfix\" into \"master\" as well as into the current development branch. And push \"master.\"\nWhat do we do with \"2011_Hotfix\" now? Should it just sit out there as a branch forever until the end of time or should we now delete it, since it has served its purpose? It seems unclean to just leave branches lying around everywhere, as the list of branches will likely become very long, most of which aren't even necessary anymore.\nIn the event that it should be deleted, what will happen to its history? Will that be maintained, even though the actual branch is no longer available? Also, how would I remove a remote branch?"
},
{
"role": "assistant",
"content": "You can safely remove a branch with git branch -d yourbranch. If it contains unmerged changes (ie, you would lose commits by deleting the branch), git will tell you and won't delete it.\nSo, deleting a merged branch is cheap and won't make you lose any history.\nTo delete a remote branch, use git push origin :mybranch, assuming your remote name is origin and the remote branch you want do delete is named mybranch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: \"Cannot 'squash' without a previous commit\" error while rebase\nI have the following in the to-do text of git rebase -i HEAD~2:\npick 56bcce7 Closes #2774\npick e43ceba Lint.py: Replace deprecated link\n\n# Rebase 684f917..e43ceba onto 684f917 (2 command(s))\n#\n...\n\nNow, when I try to squash the first one(56bcce7) and pick the second one by adding \"s\" before the first, I get the following error:\nCannot 'squash' without a previous commit\n\nCan someone explain me what it means, and how do I do it?\nI want to squash the first commit(56bcce7) and \"select and reword\" the second(e43ceba) commit"
},
{
"role": "assistant",
"content": "I had a similar problem which I solved as follows: \nThis is the commit group I wanted to squash: \n1 s 01cc5a08 Removes open div\n2 s a2b6eecf Restores old fonts\n3 s 603479ff Cleans left out div\n4 pick 5afdbc33 Update: show logo on landing page\n5 s 04c1cb13 change version of dev and prod from 1 to 2\n6 s bbe6a8f8 Update: show logo on landing page if they have one\n7 s c0d6008a Adds check for C users\n\nAs you can see, I wanted no. 4, but 1, 2 and 3 had no previous commit to squash into. Hence the Cannot 'squash' without a previous commit error.\nMy solution was to use the r option for # r, reword = use commit, but edit the commit message\nSo my commits list looked like this: \n1 r 01cc5a08 Removes open div\n2 s a2b6eecf Restores old fonts\n3 s 603479ff Cleans left out div\n4 s 5afdbc33 Update: show logo on landing page\n5 s 04c1cb13 change version of dev and prod from 1 to 2\n6 s bbe6a8f8 Update: show logo on landing page if they have one\n7 s c0d6008a Adds check for C users\n\nAfter saving, the interactive shell asked me for the rewording of the chosen commit. \nAfter that, my commit log resulted in a single commit which resulted in a cleaner commit history."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --no-indent-heuristic"
},
{
"role": "assistant",
"content": "Disable the indent heuristic."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "ssh command -T option\n\nI'm wondering what the -T option in the following command does, cannot see this option in the manual somehow:\n$ ssh -T [email protected]\nWelcome to GitLab, Simeon !\n\nCould somebody explain?"
},
{
"role": "assistant",
"content": "I explained before what TTY was: a text terminal is needed when you open an interactive session to a remote server.\nBut: in the context of a remote Git repository hosting server (GitHub, Gitlab, BitBucket, ...), no remote server will ever allow you to open an interactive session (for security reason)\nThen only reason why you would still do an ssh -T [email protected] would be to test if you are correctly authenticated, and the session would immediately end with:\nHi username! You've successfully authenticated, \nbut GitHub does not provide shell access. \n\nSince no tty is needed for that test, you should use the -T option when making this test."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I get my C code to automatically print out its Git version hash?\nIs there an easy way to write C code that can access its Git version hash? \nI wrote software in C to collect scientific data in a laboratory setting. My code records the data it collects in a .yaml file for later analysis. My experiments change from day-to-day and I often have to modify the code. To keep track of revisions, I use a git repository. \nI would like to be able to include the Git revision hash as a comment in my .yaml data files. That way, I could look at the .yaml file and know exactly what code was used to generate the data shown in that file. Is there an easy way to do this automatically?"
},
{
"role": "assistant",
"content": "If you are using a make-based build, you can put this in the Makefile:\nGIT_VERSION := \"$(shell git describe --abbrev=4 --dirty --always --tags)\"\n\n(See man git describe for what the switches do)\nthen add this to your CFLAGS:\n-DVERSION=\\\"$(GIT_VERSION)\\\"\n\nThen you can just reference the version directly in the program as though it was a #define:\nprintf(\"Version: %s\\n\", VERSION);\n\nBy default this just prints an abbreviated git commit id, but optionally you can tag particular releases with something like:\ngit tag -a v1.1 -m \"Release v1.1\"\n\nthen it will print out:\nVersion: v1.1-2-g766d\n\nwhich means, 2 commits past v1.1, with a git commit id beginning with \"766d\".\nIf there are uncommitted changes in your tree, it will append \"-dirty\".\nThere is no dependency scanning so you have to do an explicit make clean to force the version to be updated. This can be solved however.\nThe advantages are that it is simple and doesn't require any extra build dependencies like perl or awk. I have used this approach with GNU automake and with Android NDK builds."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "is it possible to add a comment to a diff file (unified)?\nI wonder if it's possible to add a certain amount of unparsed content to a diff file (unified) that is ignored as a comment.\nOne good use of this would be having git diffs augmented with important information such as from which branch is that diff from (especially when using the --full-index option, which merely displays the blob references)."
},
{
"role": "assistant",
"content": "The unified diff starts with two line header:\n --- from-file from-file-modification-time\n +++ to-file to-file-modification-time\n\nAnything before this header is ignored, so you can add any comment here, for example:\n This may be some useful description of this patch that\n will be ignored by the diff/patch utility.\n --- a/foo 2002-02-21 23:30:39.942229878 -0800\n +++ b/foo 2002-02-21 23:30:50.442260588 -0800\n @@ -1,7 +1,6 @@\n -The Way that can be told of is not the eternal Way;\n -The name that can be named is not the eternal name.\n The Nameless is the origin of Heaven and Earth;\n -The Named is the mother of all things.\n +The named is the mother of all things.\n +\n Therefore let there always be non-being,\n so we may see their subtlety,\n And let there always be being,\n\nGit itself uses this space before header for some metadata, for example:\ndiff --git a/foo b/foo\nindex 59a4d1f..e48dfe7 100644\n--- a/foo\n+++ b/foo"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "See \"real\" commit date / time in github (hour/day)\n\nIs there a way to see the date of a commit in github, with day/hour precision? Older commits appear in a \"human readable\" format, such as \"2 years ago\" instead of showing the actual date.\n\nIf it's not possible to see the actual date on github, is there a easier workaround than git clone?"
},
{
"role": "assistant",
"content": "Hover your mouse over the 2 years ago and you'll get the timestamp."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: How to find out on which branch a tag is?\nI'm currently busy with a project with a lot of branches and I have a tag for last changes which where done on one of the branches. But it's not clear for me on which branch this tag is. \nHow to find out on which branch a tag is?"
},
{
"role": "assistant",
"content": "Even shorter:\ngit branch --contains tags/<tag>\n\n(it works for any tree-ish reference)\n\nIf you can find which commit a tag refers to:\n git rev-parse --verify tags/<tag>^{commit}\n # or, shorter:\n git rev-parse tags/<tag>~0\n\nThen you can find which branch contain that commit.\ngit branch --contains <commit>\n\n\nAs commented below by user3356885, for the fetched branches (branches in remotes namespace)\ngit branch -a --contains tags/<tag>\ngit branch -a --contains <commit>\n\n\nAs noted in Pyr3z's answer, for each candidate tag listed above, you can add:\ngit log -1 --pretty='%D' TAG\n\nThat will show the branches associated to that tag."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to remove a too large file in a commit when my branch is ahead of master by 5 commits\nContext\nI'm working alone on a project and I used github until now to save my work other than on my computer.\nUnfortunately, I added a very large file to the local repository : 300mb (which exceed Github's limit).\nWhat I did\nI will try to make an history of what I made :\n\nI (dumbly) added everything to the index :\n git add *\n\n\nI committed changes :\n git commit -m \"Blablabla\"\n\n\nI tried to push to origin master\n git push origin master \n\n\n\nIt took a while, so I just CTRL+C, and repeated step 2 and 3 four times, until I realised that a file was too large to be pushed to github.\n\nI made the terrible mistake to delete my large file (I don't remember if I did a git rm or a simple rm)\n\nI followed the instructions on (https://help.github.com/articles/remove-sensitive-data)\n\nWhen I try to git filter branch, I get the following error : \"Cannot rewrite branches: You have unstaged changes.\""
},
{
"role": "assistant",
"content": "A simple solution I used:\n\nDo git reset HEAD^ for as many commits you want to undo, it will keep your changes and your actual state of your files, just flushing the commits of them.\n\nOnce the commits are undone, you can then think about how to re-commit your files in a better way, e.g.: removing/ignoring the huge files and then adding what you want and then committing again. Or use Git LFS to track those huge files.\n\n\n\nEdit: this answer is also acceptable if for instance your commits needed authentication (e.g.: username and email) and that you need to add the proper credentials after having commited. You can undo things the same way.\nQuestion: would someone have a way to just cherrypick the commit that is bad and change it directly? I'm asking especially in the case of someone who would just need to re-authenthify his commits like in here, but in a case where the files needs not to be changed. Only commits to authentify."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do you copy and paste into Git Bash\nI'm using msysgit running on Windows XP.\nTried Ctrl+V, Right click, Middle click, google... no luck."
},
{
"role": "assistant",
"content": "Press Insert.\nAlso, to copy from the window, try clicking the console's window icon (topleft) and choosing Edit -> Mark, then drag a box on the text, then press Enter. (You can also paste via the window icon menu, but the key is faster.)\nUPDATE\nStarting from Windows 10 the CTRL + C, CTRL + V and a lot of other feature are implemented in conhost.exe so they should work with every console utility on Windows. (You have to enable Properties -> Option tab -> Quick Edit Mode)\nRef: http://blogs.windows.com/buildingapps/2014/10/07/console-improvements-in-the-windows-10-technical-preview/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-replay"
},
{
"role": "assistant",
"content": "EXPERIMENTAL: Replay commits on a new base, works with bare repos too"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can't remove file from git commit\nHow do I discard all git commits that haven't been pushed and then force git to not commit anything in the data/ directory?\nI'm trying to force overwrite all changes to a project stored on github from my c9.io project. I accidentally git added some mongodb data files. I tried to add the data/ directory to .gitignore. I pulled from github to get the updated .gitignore, however when I try and git push, these stubborn files in data/ are still staged for commit. I also tried git reset, git rebase, git clean and this where I changed dmpfile.sql to pi/data/node-login.1.\nPlease help I've been at this for hours and I'm really frustrated\nCounting objects: 15, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (13/13), done.\nWriting objects: 100% (13/13), 150.22 KiB | 92 KiB/s, done.\nTotal 13 (delta 6), reused 0 (delta 0)\nremote: warning: File pi/data/local.0 is 64.00 MB; this is larger than GitHub's recommended maximum file size of 50 MB\nremote: warning: File pi/data/node-login.0 is 64.00 MB; this is larger than GitHub's recommended maximum file size of 50 MB\nremote: error: GH001: Large files detected.\nremote: error: Trace: e6ade98208c08b634ed28aefea36dfbb\nremote: error: See http://git.io/iEPt8g for more information.\nremote: error: File pi/data/node-login.1 is 128.00 MB; this exceeds GitHub's file size limit of 100 MB\nTo [email protected]:bobbyg603/goddard.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:bobbyg603/goddard.git'\n\n.gitignore:\nlib-cov\n*.seed\n*.log\n*.csv\n*.dat\n*.out\n*.pid\n*.gz\n\ndata/\n\npids\nlogs\nresults\n\nnpm-debug.log\nnode_modules\n\n.project\n.settings\n\nThanks,\nBobby"
},
{
"role": "assistant",
"content": "Thanks to Chris I was able to fix this by running the following:\n\ngit filter-branch -f --index-filter 'git rm --cached --ignore-unmatch pi/data/node-login.0'\ngit filter-branch -f --index-filter 'git rm --cached --ignore-unmatch pi/data/node-login.1'\ngit filter-branch -f --index-filter 'git rm --cached --ignore-unmatch pi/data/local.0'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git does not recognize exe file\n\nI'd like to upload NuGet.exe to github but all exe files are not listed to my local repository.\nI did upload NuGet.exe file about two weeks ago at another project repo, but now I cannot upload any exe file at all. There is no global .gitignore that I specially defined.\nbelow code is my .gitignore file.\nwhat am I missing?\n# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)\n[Bb]in/\n[Oo]bj/\n\n# mstest test results\nTestResults\n\n## Ignore Visual Studio temporary files, build results, and\n## files generated by popular Visual Studio add-ons.\n\n# User-specific files\n*.suo\n*.user\n*.sln.docstates\n\n# Build results\n[Dd]ebug/\n[Rr]elease/\nx64/\n*_i.c\n*_p.c\n*.ilk\n*.meta\n*.obj\n*.pch\n*.pdb\n*.pgc\n*.pgd\n*.rsp\n*.sbr\n*.tlb\n*.tli\n*.tlh\n*.tmp\n*.log\n*.vspscc\n*.vssscc\n.builds\n\n# Visual C++ cache files\nipch/\n*.aps\n*.ncb\n*.opensdf\n*.sdf\n\n# Visual Studio profiler\n*.psess\n*.vsp\n*.vspx\n\n# Guidance Automation Toolkit\n*.gpState\n\n# ReSharper is a .NET coding add-in\n_ReSharper*\n\n# NCrunch\n*.ncrunch*\n.*crunch*.local.xml\n\n# Installshield output folder \n[Ee]xpress\n\n# DocProject is a documentation generator add-in\nDocProject/buildhelp/\nDocProject/Help/*.HxT\nDocProject/Help/*.HxC\nDocProject/Help/*.hhc\nDocProject/Help/*.hhk\nDocProject/Help/*.hhp\nDocProject/Help/Html2\nDocProject/Help/html\n\n# Click-Once directory\npublish\n\n# Publish Web Output\n*.Publish.xml\n\n# NuGet Packages Directory\npackages\n\n# Windows Azure Build Output\ncsx\n*.build.csdef\n\n# Windows Store app package directory\nAppPackages/\n\n# Others\n[Bb]in\n[Oo]bj\nsql\nTestResults\n[Tt]est[Rr]esult*\n*.Cache\nClientBin\n[Ss]tyle[Cc]op.*\n~$*\n*.dbmdl\nGenerated_Code #added for RIA/Silverlight projects\n\n# Backup & report files from converting an old project file to a newer\n# Visual Studio version. Backup files are not needed, because we have git ;-)\n_UpgradeReport_Files/\nBackup*/\nUpgradeLog*.XML\n\n# Windows-specific files\nThumbs.db\ndesktop.ini\n# Mac-specific things (thanks to Michael Aaron Safyan)\n.DS_Store\n\n-- EDIT --\nsame files under .nuget/ directory .config and .targets files are well treated. I can check git ls-files --others -i --exclude-standard gives NuGet.exe is ignored, but I don't know which rule makes it."
},
{
"role": "assistant",
"content": "First, you can check if a file is locally ignored ion your repo with git check-ignore:\ngit check-ignore -v -- yourFile\n\nSecond, you can force to add that file (bypassing any ignore rule):\ngit add -f yourFile"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I use 'git reset --hard HEAD' to revert to a previous commit? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I revert a Git repository to a previous commit?\n\n (41 answers)\n \n\nClosed 9 years ago.\n\n\n\nI know that Git tracks changes I make to my application, and holds on to them until I commit the changes.\nTo revert to a previous commit, I used:\n$ git reset --hard HEAD\n\nHEAD is now at 820f417 micro\n\nHow do I then revert the files on my hard drive back to that previous commit?\nMy next steps were:\ngit add .\ngit commit -m \"revert\"\n\nBut none of the files have changed on my hard drive..."
},
{
"role": "assistant",
"content": "First, it's always worth noting that git reset --hard is a potentially dangerous command, since it throws away all your uncommitted changes. For safety, you should always check that the output of git status is clean (that is, empty) before using it.\nInitially you say the following:\n\nSo I know that Git tracks changes I make to my application, and it holds on to them until I commit the changes, but here's where I'm hung up:\n\nThat's incorrect. Git only records the state of the files when you stage them (with git add) or when you create a commit. Once you've created a commit which has your project files in a particular state, they're very safe, but until then Git's not really \"tracking changes\" to your files. (for example, even if you do git add to stage a new version of the file, that overwrites the previously staged version of that file in the staging area.)\nIn your question you then go on to ask the following:\n\nWhen I want to revert to a previous commit I use: git reset --hard HEAD And git returns: HEAD is now at 820f417 micro\nHow do I then revert the files on my hard drive back to that previous commit?\n\nIf you do git reset --hard <SOME-COMMIT> then Git will:\n\nMake your current branch (typically master) back to point at <SOME-COMMIT>.\nThen make the files in your working tree and the index (\"staging area\") the same as the versions committed in <SOME-COMMIT>.\n\nHEAD points to your current branch (or current commit), so all that git reset --hard HEAD will do is to throw away any uncommitted changes you have.\nSo, suppose the good commit that you want to go back to is f414f31. (You can find that via git log or any history browser.) You then have a few different options depending on exactly what you want to do:\n\nChange your current branch to point to the older commit instead. You could do that with git reset --hard f414f31. However, this is rewriting the history of your branch, so you should avoid it if you've shared this branch with anyone. Also, the commits you did after f414f31 will no longer be in the history of your master branch.\nCreate a new commit that represents exactly the same state of the project as f414f31, but just adds that on to the history, so you don't lose any history. You can do that using the steps suggested in this answer - something like:\ngit reset --hard f414f31\ngit reset --soft HEAD@{1}\ngit commit -m \"Reverting to the state of the project at f414f31\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is it possible to do a sparse checkout without checking out the whole repository first?\nI'm working with a repository with a very large number of files that takes hours to checkout. I'm looking into the possibility of whether Git would work well with this kind of repository now that it supports sparse checkouts but every example that I can find does the following:\ngit clone <path>\ngit config core.sparsecheckout true\necho <dir> > .git/info/sparse-checkout\ngit read-tree -m -u HEAD\n\nThe problem with this sequence of commands is the original clone also does a checkout. If you add -n to the original clone command, then the read-tree command results in the following error:\nerror: Sparse checkout leaves no entry on working directory\nHow can do the sparse checkout without checking out all the files first?"
},
{
"role": "assistant",
"content": "Please note that this answer does download a complete copy of the data from a repository. The git remote add -f command will clone the whole repository. From the man page of git-remote:\n\nWith -f option, git fetch <name> is run immediately after the remote information is set up.\n\n\nTry this:\nmkdir myrepo\ncd myrepo\ngit init\ngit config core.sparseCheckout true\ngit remote add -f origin git://...\necho \"path/within_repo/to/desired_subdir/*\" > .git/info/sparse-checkout\ngit checkout [branchname] # ex: master\n\nNow you will find that you have a \"pruned\" checkout with only files from path/within_repo/to/desired_subdir present (and in that path).\nNote that on windows command line you must not quote the path, i.e. you must change the 6th command with this one:\necho path/within_repo/to/desired_subdir/* > .git/info/sparse-checkout\n\nif you don't you'll get the quotes in the sparse-checkout file, and it will not work"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options merge.renameLimit"
},
{
"role": "assistant",
"content": "The number of files to consider in the exhaustive portion of\nrename detection during a merge. If not specified, defaults\nto the value of diff.renameLimit. If neither\nmerge.renameLimit nor diff.renameLimit are specified,\ncurrently defaults to 7000. This setting has no effect if\nrename detection is turned off."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %n"
},
{
"role": "assistant",
"content": "newline"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_FLUSH"
},
{
"role": "assistant",
"content": "If this Boolean environment variable is set to true, then commands such\nas git blame (in incremental mode), git rev-list , git log , git check-attr and git check-ignore will\nforce a flush of the output stream after each record have been\nflushed. If this\nvariable is set to false, the output of these commands will be done\nusing completely buffered I/O. If this environment variable is\nnot set, Git will choose buffered or record-oriented flushing\nbased on whether stdout appears to be redirected to a file or not."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git clone can't resolve proxy\nWhen I try to clone from git\ngit clone \"http://github.com/symfony/symfony.git\" \"d:/www/a/vendor/symfony\"\n\nI get an error\nCloning into 'd:/www/a/vendor/symfony'...\nerror: Couldn't resolve proxy '(null)' while accessing http://github.com/symfony/symfony.git/info/refs\nfatal: HTTP request failed\n\nI'm connected directly to the internet (without proxy). I tried to turn off firewall and didn't help. I'm on windows and just installed Git-1.7.10-preview20120409.exe from http://code.google.com/p/msysgit/downloads/list . Previously I had 1.7.8 and this command worked. I also reinstalled TortoiseGit but I think it doesn't matter.\nMy C:\\Documents and Settings\\xxx\\.gitconfig file is\n[http]\n proxy = \n[user]\n name = xxxx\n email = [email protected]"
},
{
"role": "assistant",
"content": "Seems the problem is reported in the mailing list.\nDoes this help?\ngit config --global --unset http.proxy"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects reason"
},
{
"role": "assistant",
"content": "A human-readable explanation. In the case of successfully pushed\nrefs, no explanation is needed. For a failed ref, the reason for\nfailure is described."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --progress=<header>"
},
{
"role": "assistant",
"content": "Show progress reports on stderr as objects are considered. The <header> text will be printed with each progress update."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %ad"
},
{
"role": "assistant",
"content": "author date (format respects --date= option)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "warning: ignoring broken ref refs/remotes/origin/HEAD\nSince a few days ago, every time I press tab key to complete branch names in bash I see the message:\n\nwarning: ignoring broken ref refs/remotes/origin/HEAD warning: ignoring broken ref refs/remotes/origin/HEAD\n\nFor example, this is what I see when I have a branch called feature/foo and I press tab:\ngit checkout f\n\n$ git checkout fwarning: ignoring broken ref refs/remotes/origin/HEAD\nwarning: ignoring broken ref refs/remotes/origin/HEAD\neature/"
},
{
"role": "assistant",
"content": "I encountered this recently when someone on my team deleted our old development branch from the remote. I ran this command to check the status of HEAD:\n$ git symbolic-ref refs/remotes/origin/HEAD\nrefs/remotes/origin/old_dev\n\nThis command output the name of the old development branch, which no longer exists.\nI fixed the warnings using this:\n$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/new_dev\n\n(Where \"new_dev\" is a branch name. Replace it with the name of the branch you want HEAD to point to.)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc zebra"
},
{
"role": "assistant",
"content": "Blocks of moved text are detected as in blocks mode. The blocks\nare painted using either the color.diff.{old,new}Moved color or color.diff.{old,new}MovedAlternative . The change between\nthe two colors indicates that a new block was detected."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %m"
},
{
"role": "assistant",
"content": "left ( < ), right ( > ) or boundary ( - ) mark"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "When doing a 'git push', what does '--set-upstream' do?\nWhat does git --set-upstream do? \nI tried to understand it by reading the git manual, but I didn't quite get it."
},
{
"role": "assistant",
"content": "To avoid confusion,\nrecent versions of git deprecate this somewhat ambiguous --set-upstream option\nin favor of a more verbose --set-upstream-to option\nwith identical syntax and behavior.\n[ Reference ]\n\n\ngit branch --set-upstream-to <remote-branch>\n\nsets the default remote branch for the current local branch.\nAny future git pull command (with the current local branch checked-out),\nwill attempt to bring in commits from the <remote-branch> into the current local branch.\n\nOne way to avoid having to explicitly type --set-upstream / --set-upstream-to is to use its shorthand flag -u as follows:\ngit push -u origin local-branch\n\nThis sets the upstream association for any future push/pull attempts automatically.\nFor more details, check out this detailed explanation about upstream branches and tracking."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-update-index - Register file contents in the working tree to the index -g --again"
},
{
"role": "assistant",
"content": "Runs git update-index itself on the paths whose index\nentries are different from those of the HEAD commit."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker --no-optional-locks"
},
{
"role": "assistant",
"content": "Do not perform optional operations that require locks. This is\nequivalent to setting the GIT_OPTIONAL_LOCKS to 0 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-pull - Fetch from and integrate with another repository or a local branch --dry-run"
},
{
"role": "assistant",
"content": "Show what would be done, without making any changes."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-bundle - Move objects and refs by archive --version=<version>"
},
{
"role": "assistant",
"content": "Specify the bundle version. Version 2 is the older format and can only be\nused with SHA-1 repositories; the newer version 3 contains capabilities that\npermit extensions. The default is the oldest supported format, based on the\nhash algorithm in use."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I perform a `git pull` without re-entering my SSH password?\nIs it possible to configure git/ssh so I don't have to enter my passphrase every time I want to perform a git pull? Note that the repo is a private one on github.\nOr, alternatively, what would be the best practice to automate code deployment from a private Github repo?\nAdditional details: EC2 instance running a public AMI based on Fedora."
},
{
"role": "assistant",
"content": "Have a look at this link https://help.github.com/articles/working-with-ssh-key-passphrases/\n\nBut I don’t want to enter a long passphrase every time I use the key!\nNeither do I! Thankfully, there’s a nifty little tool called\n ssh-agent that can save your passphrase securely so you don’t have\n to re-enter it. If you’re on OSX Leopard or later your keys can be\n saved in the system’s keychain to make your life even easier. Most\n linux installations will automatically start ssh-agent for you when\n you log in."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fetch - Download objects and refs from another repository --shallow-since=<date>"
},
{
"role": "assistant",
"content": "Deepen or shorten the history of a shallow repository to\ninclude all reachable commits after <date>."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Automatically wrap long Git commit messages in Vim\nUsing Git, my editor for commits is Vim. I'm constantly doing a poor job of remembering to wrap lines and so I get long lines (see this answer for example). Is there a way using some git config or .vimrc magic that I can get Vim to automatically wrap lines at 72 columns? \nRelated question."
},
{
"role": "assistant",
"content": "Add this to your .vimrc:\nau FileType gitcommit setlocal tw=72"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to see what type of line endings are already in git repository?\n\nFirst of all, I'm not asking what does it mean or how to change it. The thing what interest me most is: how can I see what's already in repo? What type of line endings.\nI have my repositories on github and bitbucket.\nThanks for help"
},
{
"role": "assistant",
"content": "You can use this command:\ngit ls-files --eol\n\nIt will output one line per file with the following information:\ni/lf w/crlf attr/text=auto eol=lf file.txt\n\nIn that example, i/lf means that the file uses lf in the index, and w/crlf means it uses crlf in the working directory."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-fsck"
},
{
"role": "assistant",
"content": "Verifies the connectivity and validity of the objects in the database"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order %T"
},
{
"role": "assistant",
"content": "tree hash"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git checkout: updating paths is incompatible with switching branches\nMy problem is related to Fatal Git error when switching branch.\nI try to fetch a remote branch with the command\ngit checkout -b local-name origin/remote-name\n\nbut I get this error message:\n\nfatal: git checkout: updating paths is incompatible with switching branches.\n Did you intend to checkout 'origin/remote-name' which can not be resolved as commit?\n\nIf I manually create a branch and then pull the remote branch, it works, just as making a new clone and checking the branch out.\nWhy does it not work on the repository I work with?"
},
{
"role": "assistant",
"content": "I believe this occurs when you are trying to checkout a remote branch that your local git repo is not aware of yet. Try:\ngit remote show origin\n\nIf the remote branch you want to checkout is under \"New remote branches\" and not \"Tracked remote branches\" then you need to fetch them first:\ngit remote update\ngit fetch\n\nNow it should work:\ngit checkout -b local-name origin/remote-name"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can you get the number of lines of code from a GitHub repository?\n\nIn a GitHub repository you can see “language statistics”, which displays the percentage of the project that’s written in a language. It doesn’t, however, display how many lines of code the project consists of. Often, I want to quickly get an impression of the scale and complexity of a project, and the count of lines of code can give a good first impression. 500 lines of code implies a relatively simple project, 100,000 lines of code implies a very large/complicated project.\nSo, is it possible to get the lines of code written in the various languages from a GitHub repository, preferably without cloning it?\n\nThe question “Count number of lines in a git repository” asks how to count the lines of code in a local Git repository, but:\n\nYou have to clone the project, which could be massive. Cloning a project like Wine, for example, takes ages.\nYou would count lines in files that wouldn’t necessarily be code, like i13n files.\nIf you count just (for example) Ruby files, you’d potentially miss massive amount of code in other languages, like JavaScript. You’d have to know beforehand which languages the project uses. You’d also have to repeat the count for every language the project uses.\n\nAll in all, this is potentially far too time-intensive for “quickly checking the scale of a project”."
},
{
"role": "assistant",
"content": "You can run something like\n\ngit ls-files | xargs wc -l\n\nWhich will give you the total count!\n\nYou can also add more instructions. Like just looking at the JavaScript files.\ngit ls-files | grep '\\.js' | xargs wc -l"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to serve other vhosts next to Gitlab Omnibus server? [Full step-by-step solution]\n\nI installed Gitlab CE on a dedicated Ubuntu 14.04 server edition with Omnibus package.\nNow I would want to install three other virtual hosts next to gitlab. \nTwo are node.js web applications launched by a non-root user running on two distinct ports > 1024, the third is a PHP web application that need a web server to be launched from.\nThere are:\n\na private bower registry running on 8081 (node.js)\na private npm registry running on 8082 (node.js)\na private composer registry (PHP)\n\nBut Omnibus listen 80 and doesn't seem to use neither Apache2 or Nginx, thus I can't use them to serve my PHP app and reverse-proxy my two other node apps.\n\nWhat serving mechanics Gitlab Omnibus uses to listen 80 ?\n How should I create the three other virtual hosts to be able to provide the following vHosts ?\n\ngitlab.mycompany.com (:80) -- already in use\nbower.mycompany.com (:80)\nnpm.mycompany.com (:80)\npackagist.mycompany.com (:80)"
},
{
"role": "assistant",
"content": "About these\n\nBut Omnibus listen 80 and doesn't seem to use neither Apache2 or Nginx [, thus ...].\n\nand @stdob comment :\n\nDid omnibus not use nginx as a web server ??? – \n\nWich I responded \n\nI guess not because nginx package isn't installed in the system ...\n\nIn facts\nFrom Gitlab official docs :\n\nBy default, omnibus-gitlab installs GitLab with bundled Nginx.\n\nSo yes! \n\nOmnibus package actually uses Nginx ! \n\nbut it was bundled, explaining why it doesn't require to be installed as dependency from the host OS.\nThus YES! Nginx can, and should be used to serve my PHP app and reverse-proxy my two other node apps.\nThen now\nOmnibus-gitlab allows webserver access through user gitlab-www which resides\nin the group with the same name. To allow an external webserver access to\nGitLab, external webserver user needs to be added gitlab-www group.\nTo use another web server like Apache or an existing Nginx installation you will have to do\nthe following steps:\nDisable bundled Nginx by specifying in /etc/gitlab/gitlab.rb\nnginx['enable'] = false\n# For GitLab CI, use the following:\nci_nginx['enable'] = false\n\nCheck the username of the non-bundled web-server user. By default, omnibus-gitlab has no default setting for external webserver user.\nYou have to specify the external webserver user username in the configuration!\nLet's say for example that webserver user is www-data.\nIn /etc/gitlab/gitlab.rb set\nweb_server['external_users'] = ['www-data']\n\nThis setting is an array so you can specify more than one user to be added to gitlab-www group.\nRun sudo gitlab-ctl reconfigure for the change to take effect.\nSetting the NGINX listen address or addresses\nBy default NGINX will accept incoming connections on all local IPv4 addresses.\nYou can change the list of addresses in /etc/gitlab/gitlab.rb.\nnginx['listen_addresses'] = [\"0.0.0.0\", \"[::]\"] # listen on all IPv4 and IPv6 addresses\n\nFor GitLab CI, use the ci_nginx['listen_addresses'] setting.\nSetting the NGINX listen port\nBy default NGINX will listen on the port specified in external_url or\nimplicitly use the right port (80 for HTTP, 443 for HTTPS). If you are running\nGitLab behind a reverse proxy, you may want to override the listen port to\nsomething else. For example, to use port 8080:\nnginx['listen_port'] = 8080\n\nSimilarly, for GitLab CI:\nci_nginx['listen_port'] = 8081\n\nSupporting proxied SSL\nBy default NGINX will auto-detect whether to use SSL if external_url\ncontains https://. If you are running GitLab behind a reverse proxy, you\nmay wish to keep the external_url as an HTTPS address but communicate with\nthe GitLab NGINX internally over HTTP. To do this, you can disable HTTPS using\nthe listen_https option:\nnginx['listen_https'] = false\n\nSimilarly, for GitLab CI:\nci_nginx['listen_https'] = false\n\nNote that you may need to configure your reverse proxy to forward certain\nheaders (e.g. Host, X-Forwarded-Ssl, X-Forwarded-For, X-Forwarded-Port) to GitLab.\nYou may see improper redirections or errors (e.g. \"422 Unprocessable Entity\",\n\"Can't verify CSRF token authenticity\") if you forget this step. For more\ninformation, see:\n\nWhat's the de facto standard for a Reverse Proxy to tell the backend SSL is used?\nhttps://wiki.apache.org/couchdb/Nginx_As_a_Reverse_Proxy\n\n\nTo go further you can follow the official docs at https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#using-a-non-bundled-web-server\n\nConfiguring our gitlab virtual host\nInstalling Phusion Passenger\nWe need to install ruby (gitlab run in omnibus with a bundled ruby) globally in the OS\n$ sudo apt-get update \n$ sudo apt-get install ruby\n$ sudo gem install passenger\n\nRecompile nginx with the passenger module\nInstead of Apache2 for example, nginx isn't able to be plugged with binary modules on-the-fly. It must be recompiled for each new plugin you want to add.\nPhusion passenger developer team worked hard to provide saying, \"a bundled nginx version of passenger\" : nginx bins compiled with passenger plugin.\nSo, lets use it:\n\nrequirement: we need to open our TCP port 11371 (the APT key port).\n\n$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7\n$ sudo apt-get install apt-transport-https ca-certificates\n\n\ncreating passenger.list\n$ sudo nano /etc/apt/sources.list.d/passenger.list\n\nwith these lignes\n# Ubuntu 14.04\ndeb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main\n\n\nuse the right repo for your ubuntu version. For Ubuntu 15.04 for example: \n deb https://oss-binaries.phusionpassenger.com/apt/passenger vivid main\n\nEdit permissions: \n$ sudo chown root: /etc/apt/sources.list.d/passenger.list\n$ sudo chmod 600 /etc/apt/sources.list.d/passenger.list\n\nUpdating package list:\n$ sudo apt-get update\n\nAllowing it as unattended-upgrades\n$ sudo nano /etc/apt/apt.conf.d/50unattended-upgrades\n\nFind or create this config block on top of the file:\n// Automatically upgrade packages from these (origin:archive) pairs\nUnattended-Upgrade::Allowed-Origins {\n\n // you may have some instructions here\n\n};\n\nAdd the following:\n// Automatically upgrade packages from these (origin:archive) pairs\nUnattended-Upgrade::Allowed-Origins {\n\n // you may have some instructions here\n\n // To check \"Origin:\" and \"Suite:\", you could use e.g.:\n // grep \"Origin\\|Suite\" /var/lib/apt/lists/oss-binaries.phusionpassenger.com*\n \"Phusion:stable\";\n\n};\n\nNow (re)install nginx-extra and passenger:\n$ sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak_\"$(date +%Y-%m-%d_%H:%M)\"\n$ sudo apt-get install nginx-extras passenger\n\nconfigure it\nUncomment the passenger_root and passenger_ruby directives in the /etc/nginx/nginx.conf file:\n$ sudo nano /etc/nginx/nginx.conf\n\n... to obtain something like:\n##\n# Phusion Passenger config\n##\n# Uncomment it if you installed passenger or passenger-enterprise\n##\n\npassenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;\npassenger_ruby /usr/bin/passenger_free_ruby;\n\ncreate the nginx site configuration (the virtual host conf)\n$ nano /etc/nginx/sites-available/gitlab.conf\n\nserver {\n listen *:80;\n server_name gitlab.mycompany.com;\n server_tokens off;\n root /opt/gitlab/embedded/service/gitlab-rails/public;\n\n client_max_body_size 250m;\n access_log /var/log/gitlab/nginx/gitlab_access.log;\n error_log /var/log/gitlab/nginx/gitlab_error.log;\n\n # Ensure Passenger uses the bundled Ruby version\n passenger_ruby /opt/gitlab/embedded/bin/ruby;\n\n # Correct the $PATH variable to included packaged executables\n passenger_env_var PATH \"/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/bin:/bin\";\n\n # Make sure Passenger runs as the correct user and group to\n # prevent permission issues\n passenger_user git;\n passenger_group git;\n\n # Enable Passenger & keep at least one instance running at all times\n passenger_enabled on;\n passenger_min_instances 1;\n\n error_page 502 /502.html;\n}\n\nNow we can enable it:\n$ sudo ln -s /etc/nginx/sites-available/gitlab.cong /etc/nginx/sites-enabled/\n\n\nThere is no a2ensite equivalent coming natively with nginx, so we use ln, but if you want, there is a project on github:\n nginx_ensite:\n nginx_ensite and nginx_dissite for quick virtual host enabling and disabling\nThis is a shell (Bash) script that replicates for nginx the Debian a2ensite and a2dissite for enabling and disabling sites as virtual hosts in Apache 2.2/2.4.\n\nIt' done :-). Finally, restart nginx\n$ sudo service nginx restart\n\nWith this new configuration, you are able to run other virtual hosts next to gitlab to serve what you want\nJust create new configs in /etc/nginx/sites-available. \n\nIn my case, I made running and serving this way on the same host :\n\n\ngitlab.mycompany.com - the awesome git platform written in ruby\nci.mycompany.com - the gitlab continuous integration server written in ruby\nnpm.mycompany.com - a private npm registry written in node.js\nbower.mycompany.com - a private bower registry written in node.js\npackagist.mycompany.com - a private packagist for composer registry written in php\n\nFor example, to serve npm.mycompany.com :\nCreate a directory for logs:\n$ sudo mkdir -p /var/log/private-npm/nginx/\n\nAnd fill a new vhost config file:\n$ sudo nano /etc/nginx/sites-available/npm.conf\n\nWith this config\nserver {\n listen *:80;\n server_name npm.mycompany.com\n\n client_max_body_size 5m;\n access_log /var/log/private-npm/nginx/npm_access.log;\n error_log /var/log/private-npm/nginx/npm_error.log;\n\n location / {\n proxy_pass http://localhost:8082;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection 'upgrade';\n proxy_set_header Host $host;\n proxy_cache_bypass $http_upgrade;\n }\n}\n\nThen enable it and restart it:\n$ sudo ln -s /etc/nginx/sites-available/npm.conf /etc/nginx/sites-enabled/\n$ sudo service nginx restart"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_ALLOW_PROTOCOL"
},
{
"role": "assistant",
"content": "If set to a colon-separated list of protocols, behave as if protocol.allow is set to never , and each of the listed\nprotocols has protocol.<name>.allow set to always (overriding any existing configuration). See the description of protocol.allow in git-config for more details."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules deinit [-f|--force] (--all|[--] <path>…)"
},
{
"role": "assistant",
"content": "Unregister the given submodules, i.e. remove the whole submodule.$name section from .git/config together with their work\ntree. Further calls to git submodule update , git submodule foreach and git submodule sync will skip any unregistered submodules until\nthey are initialized again, so use this command if you don’t want to\nhave a local checkout of the submodule in your working tree anymore. When the command is run without pathspec, it errors out,\ninstead of deinit-ing everything, to prevent mistakes. If --force is specified, the submodule’s working tree will\nbe removed even if it contains local modifications. If you really want to remove a submodule from the repository and commit\nthat use git-rm instead. See gitsubmodules for removal\noptions."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to discard local changes and pull latest from GitHub repository\nI have a directory on my machine where I store all projects from GitHub. I opened one of them and made changes locally on my machine. Project got messed up and now I want to discard all the changes I made and pull the latest version from the repository. I am relatively new to GitHub, using Git Shell. \nWould git pull command be sufficient?\nDo I need to do anything extra to discard the changes made locally?\nCan anyone help?"
},
{
"role": "assistant",
"content": "git reset is what you want, but I'm going to add a couple extra things you might find useful that the other answers didn't mention.\ngit reset --hard HEAD resets your changes back to the last commit that your local repo has tracked. If you made a commit, did not push it to GitHub, and want to throw that away too, see @absiddiqueLive's answer.\ngit clean -df will discard any new files or directories that you may have added, in case you want to throw those away. If you haven't added any, you don't have to run this.\ngit pull (or if you are using git shell with the GitHub client) git sync will get the new changes from GitHub.\nEdit from way in the future:\nI updated my git shell the other week and noticed that the git sync command is no longer defined by default. For the record, typing git sync was equivalent to git pull && git push in bash. I find it still helpful so it is in my bashrc."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Variables in Jenkins Workflow plugin\nI'd like to access git variables such as GIT_COMMIT and GIT_BRANCH when I have checked out a repository from git further down in the build stream. Currently I find no available variable to access these two parameters.\nnode {\n git git+ssh://git.com/myproject.git\n echo \"$GIT_COMMIT - $BRANCH_NAME\"\n}\n\nIs such variables available and in case, where would I find them. I don't mind if they are available through some groovy variables or wherever, just that I can access them.\nMaybe I lack the debugging skills in Groovy and this is easy to find, but I just can't find it with my limited skills."
},
{
"role": "assistant",
"content": "Depending on the SCM plugin you are using, the checkout step may return additional information about the revision. This was resolved in JENKINS-26100. It was released in the 2.6 version of the workflow-scm-step plugin.\nFor example, using the Git plugin, you can do something like:\nfinal scmVars = checkout(scm)\necho \"scmVars: ${scmVars}\"\necho \"scmVars.GIT_COMMIT: ${scmVars.GIT_COMMIT}\"\necho \"scmVars.GIT_BRANCH: ${scmVars.GIT_BRANCH}\"\n\nThis will vary depending on the plugin you use, so the original answer may work better for you.\n\nOriginal Answer\nWith the 2.4 release of the Pipeline Nodes and Processes Plugin, you can simply do:\ndef gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "EGit and Eclipse modifies .gitignore file but it should not\nI'm using Eclipse and EGit, but Eclipse modifies my .gitignore file without me asking to do so. As soon as I open Eclipse the .gitignore file is modified.\nI've added some folders to .gitignore (through EGit) but removed them after, but Eclipse keeps adding removed lines to .gitignore.\n\ngit checkout .gitignore, I get the good version of the file\nThen I go to Eclipse window\nThen I go back to terminal and issue: git status, \nI can see that .gitignore is now modified.\n\nHow can it be?"
},
{
"role": "assistant",
"content": "By default, EGit automatically adds resources marked as \"Derived\" to .gitignore. A typical example is the bin folder in a Java project containing the compiled classes.\nYou can disable this by going to Window > Preferences > Team > Git > Projects and deselect \"Automatically ignore derived resources by adding them to .gitignore\".\nThere was also a bug in EGit where it added entries when the Eclipse model and the filesystem were out-of-sync, see bug 421610 (fixed for EGit 3.5)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab Build Runner on Windows uses HTTP instead of SSH\n\nI am new to Gitlab CI but have been reading on the topic for a while now.\nI have to test-compile C#-Projects on my Gitlab after every commit and found out that I need to use a Windows Shell-Runner setup for CI to build my project correctly. \nUnfortunately, my Gitlab setup only allows developers and machines to connect over SSH, not HTTP. But my Windows runner always tries to connect over http and fails the build. \nHow can I configure it properly?\nI already tried to edit the config.toml associated with the runner, but there is no option to specify whether to use ssh or http."
},
{
"role": "assistant",
"content": "If your runner is accessible through ssh, try and register it with the gitlab-runner register command.\nSee \"GitLab Continuous Integration \" from Christian Stankowic:\n# sudo gitlab-runner register\n Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/ci):\n http://gitlab.localdomain.loc/ci\n Please enter the gitlab-ci token for this runner:\n xxx\n Please enter the gitlab-ci description for this runner:\n [gitlab.localdomain.loc]:\n Please enter the gitlab-ci tags for this runner (comma separated):\n rpm764,generic\n INFO[0035] 7ab95543 Registering runner... succeeded\n Please enter the executor: ssh, shell, parallels, docker, docker-ssh:\n ssh\n Please enter the SSH server address (eg. my.server.com):\n gitlab.localdomain.loc\n Please enter the SSH server port (eg. 22):\n 22\n Please enter the SSH user (eg. root):\n su-gitlab-ci\n Please enter the SSH password (eg. docker.io):\n myPassword\n Please enter path to SSH identity file (eg. /home/user/.ssh/id_rsa):\n /home/su-gitlab-ci/.ssh/id_rsa\n INFO[0143] Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!\n\nThat would help generate the config.toml file with the right content, including an ssh config."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: Recover deleted (remote) branch\n\nI need to recover two Git branches that I somehow deleted during a push.\nThese two branches were created on a different system and then pushed to my \"shared\" (github) repository.\nOn my system, I (apparently) retrieved the branches during a fetch:\n~/myfolder> git fetch\nremote: Counting objects: 105, done.\nremote: Compressing objects: 100% (58/58), done.\nremote: Total 62 (delta 29), reused 0 (delta 0)\nUnpacking objects: 100% (62/62), done.\nFrom github.com:mygiturl\n * [new branch] contact_page -> origin/contact_page\n 731d1bb..e8b68cc homepage -> origin/homepage\n * [new branch] new_pictures -> origin/new_pictures\n\nRight after that I did a push to send my local changes up to the central repo. For some reason, these branches were deleted from both my local system and the central repo:\n~/myfolder> git push\nCounting objects: 71, done.\nDelta compression using up to 2 threads.\nCompressing objects: 100% (43/43), done.\nWriting objects: 100% (49/49), 4.99 KiB, done.\nTotal 49 (delta 33), reused 0 (delta 0)\nTo [email protected]:mygiturl.git\n - [deleted] contact_page\n + e8b68cc...731d1bb homepage -> homepage (forced update)\n bb7e9f2..e0d061c master -> master\n - [deleted] new_pictures\n e38ac2e..bb7e9f2 origin/HEAD -> origin/HEAD\n 731d1bb..e8b68cc origin/homepage -> origin/homepage\n e38ac2e..bb7e9f2 origin/master -> origin/master\n * [new branch] origin/contact_page -> origin/contact_page\n * [new branch] origin/new_pictures -> origin/new_pictures\n\nIt's not terribly easy to get the branches off of their birthplace machine, so I'd like to try and recover them from my local if possible.\nAll of the git \"undo\" information I've googled has to with recovering lost commits. I don't think that applies here, since I don't have commit UIDs for these branches.\nI'd like to know how I can get these back. I'd also like to know how they were deleted in the first place and how I can avoid this in the future.\nEDIT: by request, here's my repo configuration\nuser.name=Craig Walker\n[email protected]\nalias.unadd=reset HEAD\ncore.repositoryformatversion=0\ncore.filemode=true\ncore.bare=false\ncore.logallrefupdates=true\ncore.ignorecase=true\nremote.origin.fetch=+refs/heads/*:refs/remotes/origin/*\n[email protected]:MyGitURL.git\nremote.origin.mirror=true\nbranch.master.remote=origin\nbranch.master.merge=refs/heads/master\nalias.undo=reset --hard\nalias.test=push -f ci HEAD:master\nalias.st=status\nalias.ci=commit\nalias.br=branch\nalias.co=checkout\nalias.ch=checkout\nalias.df=diff\nalias.lg=log -p\nalias.who=shortlog -s --\nremote.ci.url=ContinuousIntegrationGitURL\nremote.ci.fetch=+refs/heads/*:refs/remotes/ci/*\nbranch.photo.remote=origin\nbranch.photo.merge=refs/heads/photos\nremote.foo.url=FooGitURL\nremote.foo.fetch=+refs/heads/*:refs/remotes/cynthia/*\nbranch.homepage.remote=origin\nbranch.homepage.merge=refs/heads/homepage"
},
{
"role": "assistant",
"content": "I'm not an expert. But you can try\ngit fsck --full --no-reflogs | grep commit\n\nto find the HEAD commit of deleted branch and get them back."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I view the source of Markdown files on Github?\n\nGithub helpfully renders Markdown (.md) files to HTML when viewing on github.com (for example, this README.md).\nWhen viewing any other source file, it is shown as unrendered source code (for example, this .gitignore). A handy feature this gives is linking directly to a line in the source by clicking the line number (for example, like this).\nHow can I view the unrendered source of Markdown files on Github (so I can link to a particular line in the source)?\nnote: I know of the \"Raw\" button, however it does not provide any of the nice UI Github has."
},
{
"role": "assistant",
"content": "If you don't want to use the \"raw\" button, you can (since June 2021) add ?plain=1 to your GitHub markdown file URL:\n\nAppending ?plain=1 to the url for any Markdown file will now display the file without rendering.\nAs with other code files, it will also show line numbers, and can be used to link other users to a specific line or lines.\nFor example, appending ?plain=1#L52 will highlight line 52 of a plain text Markdown file.\n\nExample:\nhttps://github.com/git/git/blob/master/README.md?plain=1#L49-L51\n\nSince Sept. 2021, there is a button which adds the ?plain=1 for you:"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options gc.recentObjectsHook"
},
{
"role": "assistant",
"content": "When considering whether or not to remove an object (either when\ngenerating a cruft pack or storing unreachable objects as\nloose), use the shell to execute the specified command(s).\nInterpret their output as object IDs which Git will consider as\n\"recent\", regardless of their age. By treating their mtimes as\n\"now\", any objects (and their descendants) mentioned in the\noutput will be kept regardless of their true age. Output must contain exactly one hex object ID per line, and nothing\nelse. Objects which cannot be found in the repository are ignored.\nMultiple hooks are supported, but all must exit successfully, else the\noperation (either generating a cruft pack or unpacking unreachable\nobjects) will be halted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I switch my git repository to a particular commit\nIn my git repository, I made 5 commits, like below in my git log:\ncommit 4f8b120cdafecc5144d7cdae472c36ec80315fdc\nAuthor: Michael \nDate: Fri Feb 4 15:26:38 2011 -0800\n\ncommit b688d46f55db1bc304f7f689a065331fc1715079\nAuthor: Michael\nDate: Mon Jan 31 10:37:42 2011 -0800\n\ncommit b364f9dcec3b0d52666c4f03eb5f6efb7e1e7bda\nAuthor: Michael\nDate: Wed Jan 26 13:33:17 2011 -0800\n\ncommit 4771e26619b9acba3f059b491c6c6d70115e696c\nAuthor: Michael \nDate: Wed Jan 26 11:16:51 2011 -0800\n\ncommit 6e559cb951b9bfa14243b925c1972a1bd2586d59\nAuthor: Michael \nDate: Fri Jan 21 11:42:27 2011 -0800\n\nHow can I roll back my previous 4 commits locally in a branch?\nIn other words, how can I create a branch without my latest 4 commits (assume I have the SHA of that commit from git log)?"
},
{
"role": "assistant",
"content": "To create a new branch (locally):\n\nWith the commit hash (or part of it)\ngit checkout -b new_branch 6e559cb\n\nor to go back 4 commits from HEAD\ngit checkout -b new_branch HEAD~4\n\n\nOnce your new branch is created (locally), you might want to replicate this change on a remote of the same name: How can I push my changes to a remote branch\n\nFor discarding the last three commits, see Lunaryorn's answer below.\n\nFor moving your current branch HEAD to the specified commit without creating a new branch, see Arpiagar's answer below."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "List git commits to master branch between two dates\nHow can i get a list of all the git commits done to the master branch between 2014-01-01 and 2014-06-30?\nI know git log will give me roughly this format (repeated for all commits):\ncommit <hash>\nauthor: <author name>\ndate: <date>\n<comment>\n\nBut how can it be limited to selected dates and a one line per commit format?\n<hash> <author> <date>\n<hash> <author> <date>"
},
{
"role": "assistant",
"content": "$ git log --since \"DEC 1 2014\" --until \"DEC 5 2014\" --pretty=format:\"%h %an %ad\"\n\nThis will give the format you want for the commits between dec 1 2014 and dec 5 2014, you can change the dates as you like\nIf you wish to change the format, you can read about the options here"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "MSysGit vs. Git for Windows\nI am having trouble determining the difference between MSysGit and Git for Windows. How are they different? Why would I choose one over the other?"
},
{
"role": "assistant",
"content": "Are they not the same thing?\nOn: http://msysgit.github.com/ The title is Git for Windows, the application is msysgit.\nEven in the event they are not, I expect the only differences will be in the method of compilation (i.e. compiler used and any options set) and any extraneous packaging (such as having a bash emulating shell as in msysgit). The actual product (Git itself) should remain broadly similar.\n\nEdit: Thanks to Jarrod for pointing this out. I've left the above in for posterity. To quote the wiki:\n\nmsysGit is the development environment\n to compile Git for Windows. It is\n complete, in the sense that you just\n need to install msysGit, and then you\n can build Git. Without installing any\n 3rd-party software.\n msysGit is not Git for Windows; that\n is an installer which installs Git --\n and only Git.\nIt is easy to see the difference: the\n installers for Git have the prefix\n Git-, the msysGit installers have the\n prefix msysGit-. Another telltale is\n that the msysGit installers come in\n two flavors: fullinstall and\n netinstall. Further, msysGit does not\n install to C:\\Program Files by\n default. But msysGit comes with gcc,\n the GNU C Compiler.\n\nSo, the difference between the two projects:\n\nmsysGit is the msys+mingw environment + everything needed to compile Git yourself, on Windows.\nGit for Windows is exactly that: Git, compiled for Windows."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitformat-chunk"
},
{
"role": "assistant",
"content": "Chunk-based file formats"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-init - Create an empty Git repository or reinitialize an existing one group true"
},
{
"role": "assistant",
"content": "Make the repository group-writable, (and g+sx , since the git group may not be\nthe primary group of all users). This is used to loosen the permissions of an\notherwise safe umask (2) value. Note that the umask still applies to the other\npermission bits (e.g. if umask is 0022 , using group will not remove read\nprivileges from other (non-group) users). See 0xxx for how to exactly specify\nthe repository permissions."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Bower: ENOGIT Git is not installed or not in the PATH\nGit is installed and is in the path.\nPlatform: Red Hat Enterprise Linux 5.8.\n>which git\n/usr/local/bin/git\n\nYet bower can't find it:\nbower angular#1.0.6 ENOGIT git is not installed or not in the PATH\n\nWhat is the recommended work-around?"
},
{
"role": "assistant",
"content": "Adding Git to Windows 7/8/8.1 Path\nNote: You must have msysgit installed on your machine. Also, the path to my Git installation is \"C:\\Program Files (x86)\\Git\". Yours might be different. Please check where yours is before continuing.\nOpen the Windows Environment Variables/Path Window.\n\nRight-click on My Computer -> Properties\nClick Advanced System Settings link from the left side column\nClick Environment Variables in the bottom of the window\nThen under System Variables look for the path variable and click edit\nAdd the pwd to Git's binary and cmd at the end of the string like this:\n;%PROGRAMFILES(x86)%\\Git\\bin;%PROGRAMFILES(x86)%\\Git\\cmd\n\n\nNow test it out in PowerShell. Type git and see if it recognizes the command.\n\nSource: Adding Git to Windows 7 Path"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-reset - Reset current HEAD to the specified state"
},
{
"role": "assistant",
"content": "NAME git-reset - Reset current HEAD to the specified state"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is it possible to configure N postgresql service instance in a GitLab CI?\n\nIs there a way to configure 5 postgresql instance in a Gitlab CI?\nThis is my configuration:\nimage: something:latest\n\nvariables:\n SPRING_PROFILES_ACTIVE: gitlab-ci\n POSTGRES_USER: gitlab-ci\n POSTGRES_PASSWORD: gitlab-ci\n POSTGRES_DB: DATA_V1\n LDAP_DOMAIN: domain.com\n LDAP_ORGANISATION: org\n LDAP_ADMIN_PASSWORD: hello-ci\n\nservices:\n- name: docker:dind\n- name: osixia/openldap:1.1.9\n- name: postgres:10.0-alpine\n alias: user-management-db\n- name: postgres:10.0-alpine\n alias: company-management-db\n\nIt generate errors in CI : \n[0;m[0KStarting service docker:dind ...\n[0;m[0KPulling docker image docker:dind ...\n[0;m[0KUsing docker image docker:dind ID=sha256:4998cc824d9ac8e4be3bb89afa004c87911e796cde15f0676d437fcb8a8dd06b for docker service...\n[0;m[0KStarting service osixia/openldap:1.1.9 ...\n[0;m[0KPulling docker image osixia/openldap:1.1.9 ...\n[0;m[0KUsing docker image osixia/openldap:1.1.9 ID=sha256:0670342c5b82a10b014f0cf1060752ccb740cd8bd28a704ac3fa1191a4e31594 for osixia/openldap service...\n[0;m[0KStarting service postgres:10.0-alpine ...\n[0;m[0KPulling docker image postgres:10.0-alpine ...\n[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...\n[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.\n[0;m[0KStarting service postgres:10.0-alpine ...\n[0;m[0KPulling docker image postgres:10.0-alpine ...\n[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...\n[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.\n[0;m[0KStarting service postgres:10.0-alpine ...\n[0;m[0KPulling docker image postgres:10.0-alpine ...\n[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...\n[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.\n[0;m[0KStarting service postgres:10.0-alpine ...\n[0;m[0KPulling docker image postgres:10.0-alpine ...\n[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...\n[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.\n[0;m[0KStarting service postgres:10.0-alpine ...\n[0;m[0KPulling docker image postgres:10.0-alpine ...\n[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...\n[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.\n[0;m[0KStarting service postgres:10.0-alpine ...\n[0;m[0KPulling docker image postgres:10.0-alpine ...\n[0;m[0KUsing docker image postgres:10.0-alpine ID=sha256:0f0ff37589e948e31d9e64bb6c1b31cdbd4d7d0336b656cb6094be568e54ad04 for postgres service...\n[0;m[0;33mWARNING: Service postgres:10.0-alpine is already created. Ignoring.\n\nIt also can't be configured individually with variables that way.\nSo far my workaround was to create only one service with multiple database that won't be always possible. (two ldap for example)\nDid anybody have ever tried such configuration in Gitlab-CI?\nSeems like it has been repaired in gitlab 9.3 https://gitlab.com/gitlab-org/gitlab-runner/merge_requests/639/pipelines"
},
{
"role": "assistant",
"content": "It's possible. For example:\nunit-test:\n services:\n - name: registry.company.com/postgres:14.6\n alias: db1\n variables:\n POSTGRES_DB: \"db1\"\n POSTGRES_USER: \"user1\"\n POSTGRES_PASSWORD: \"pw1\"\n POSTGRES_INITDB_ARGS: \"--encoding=UTF8 --no-locale\"\n - name: registry.company.com/postgres:14.6\n alias: db2\n variables:\n POSTGRES_DB: \"db2\"\n POSTGRES_USER: \"user2\"\n POSTGRES_PASSWORD: \"pw2\"\n POSTGRES_INITDB_ARGS: \"--encoding=UTF8 --no-locale\"\n\nThis will start two postgreses, one reachable under the hostname db1 and the other with the hostname db2.\nHere is the documentation: https://docs.gitlab.com/ee/ci/services/index.html#available-settings-for-services"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-stash - Stash the changes in a dirty working directory away Saving unrelated changes for future use"
},
{
"role": "assistant",
"content": "When you are in the middle of massive changes and you find some\nunrelated issue that you don’t want to forget to fix, you can do the\nchange(s), stage them, and use git stash push --staged to stash them\nout for future use. This is similar to committing the staged changes,\nonly the commit ends-up being in the stash and not on the current branch. # ... hack hack hack ...\n$ git add --patch foo # add unrelated changes to the index\n$ git stash push --staged # save these changes to the stash\n# ... hack hack hack, finish current changes ...\n$ git commit -m 'Massive' # commit fully tested changes\n$ git switch fixup-branch # switch to another branch\n$ git stash pop # to finish work on the saved changes"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Merge commits don't appear in git rebase --interactive\ngit log reveals the following:\ncommit 1abcd[...]\nAuthor: [...]\nDate: [...]\n\n [Useful commit]\n\ncommit 2abcd[...]\nAuthor: [...]\nDate: [...]\n\n Merge branch [...] of [etc. etc.]\n\ncommit 3abcd[...]\nAuthor: [...]\nDate: [...]\n\n [Useful commit]\n\nThat merge commit is useless to me - it doesn't represent a meaningful state of the branch and was generated from a remote pull, so I have the real commits of the remote history - no need for a commit to mark the fact that I pulled. I would like to squash this merge commit. My usual technique for doing a squash is:\ngit rebase --interactive HEAD~2 (or however far back I need to go)\nAnd then I would squash it into a neighboring commit. I do this some times if for example I make a commit, realize I missed a tiny important detail (single file, or hadn't changed a line in one of the files), and do another commit that's basically just a quick oops. That way when I push my changes back to the remote, everything is nice and clean and tells a cohesive narrative. \nHowever, in this case, when I run the git rebase ... command, commit 2abcd doesn't appear! It seems to skip right over 2abcd and instead displays 1abcd and 3abcd. Is there something special about a merge commit that prevents it from being appearing in git rebase --interactive? What other technique could I use to squash that merge commit?\nUPDATE per @Cupcake's request:\nThe output of git log --graph --oneline --decorate looks like this:\n* 1abcd (useful commit)\n* 2abcd (merge)\n| \\ <-- from remote\n| * 3abcd (useful commit)\n| |\n\nHelpful?"
},
{
"role": "assistant",
"content": "Rebase doesn't normally preserve merge commits without --preserve-merges\nOk, so I'm not exactly sure what would happen if you tried to squash a merge commit using an interactive rebase with --preserve-merges...but this is how I would remove the merge commit in your case and make your history linear:\n\nRebase everything before the merge commit on top of the remote branch.\nCherry-pick or rebase everything after the merge commit on top of the previously rebased commits.\n\nIf you only have 1 commit after the merge commit\nSo in terms of commands, that would look something like this:\n# Reset to commit before merge commit\ngit reset --hard <merge>^\n\n# Rebase onto the remote branch\ngit rebase <remote>/<branch>\n\n# Cherry-pick the last commit\ngit cherry-pick 1abcd \n\nIf you have more than 1 commit after the merge commit\n# Leave a temporary branch at your current commit\ngit branch temp\n\n# Reset to commit before merge commit\ngit reset --hard <merge>^\n\n# Rebase onto the remote branch\ngit rebase <remote>/<branch>\n\n# Cherry-pick the last commits using a commit range.\n# The start of the range is exclusive (not included)\ngit cherry-pick <merge>..temp\n\n# Alternatively to the cherry-pick above, you can instead rebase everything\n# from the merge commit to the tip of the temp branch onto the other\n# newly rebased commits.\n#\n# You can also use --preserve-merges to preserve merge commits following\n# the first merge commit that you want to get rid of...but if there were\n# any conflicts in those merge commits, you'll need to re-resolve them again.\ngit rebase --preserve-merges --onto <currentBranch> <merge> temp\n\n# These next steps are only necessary if you did the rebase above,\n# instead of using the cherry-pick range.\n#\n# Fast-forward your previous branch and delete temp\ngit checkout <previousBranch>\ngit merge temp\ngit branch -d temp\n\nDocumentation\n\nOfficial Linux Kernel git-cherry-pick(1) Manual Page\nOfficial Linux Kernel git-rebase(1) Manual Page"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git Pull is Not Possible, Unmerged Files\nI've read all of the similar questions on this; it seems that none of the following have worked:\nDelete offending files\ngit reset --hard HEAD\ngit stash\ngit pull\n\nNearly every combination, stashing changes and pulling from repository, results in unmergable files. I'd like to discard all local changes and just use the remote, but I cannot clone again (bandwidth and internet usage limitations with the developer trying to do this). How do I do this? \nJust tried:\ngit stash\ngit pull\n\nAlso did not work.\nMore Info\nThere is one local commit, and the upstream has a commit as well. I've thus tried git pull --rebase but it's still not working properly... That gives me errors - \"exiting because of an unresolved conflict\". If I do git stash, git reset --hard HEAD, git pull --rebase, I get the error \"pull is not possible, unmerged changes...\""
},
{
"role": "assistant",
"content": "Say the remote is origin and the branch is master, and say you already have master checked out, might try the following:\ngit fetch origin\ngit reset --hard origin/master\n\nThis basically just takes the current branch and points it to the HEAD of the remote branch.\nWARNING: As stated in the comments, this will throw away your local changes and overwrite with whatever is on the origin.\nOr you can use the plumbing commands to do essentially the same:\ngit fetch <remote>\ngit update-ref refs/heads/<branch> $(git rev-parse <remote>/<branch>)\ngit reset --hard\n\nEDIT: I'd like to briefly explain why this works.\nThe .git folder can hold the commits for any number of repositories. Since the commit hash is actually a verification method for the contents of the commit, and not just a randomly generated value, it is used to match commit sets between repositories.\nA branch is just a named pointer to a given hash. Here's an example set:\n$ find .git/refs -type f\n.git/refs/tags/v3.8\n.git/refs/heads/master\n.git/refs/remotes/origin/HEAD\n.git/refs/remotes/origin/master\n\nEach of these files contains a hash pointing to a commit:\n$ cat .git/refs/remotes/origin/master\nd895cb1af15c04c522a25c79cc429076987c089b\n\nThese are all for the internal git storage mechanism, and work independently of the working directory. By doing the following:\ngit reset --hard origin/master\n\ngit will point the current branch at the same hash value that origin/master points to. Then it forcefully changes the working directory to match the file structure/contents at that hash.\nTo see this at work go ahead and try out the following:\ngit checkout -b test-branch\n# see current commit and diff by the following\ngit show HEAD\n# now point to another location\ngit reset --hard <remote>/<branch>\n# see the changes again\ngit show HEAD"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-submodule - Initialize, update or inspect submodules --init"
},
{
"role": "assistant",
"content": "This option is only valid for the update command.\nInitialize all submodules for which \"git submodule init\" has not been\ncalled so far before updating."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to do a forced-push to another branch in Git\nDoing a forced push is done by:\ngit push origin +branch\n\nDoing a push to a differently-named remote branch is done by:\ngit push origin local:remote\n\nHow does one do a forced push to a differently-named remote branch?\nI tried:\ngit push origin local:+remote\n\nBut it creates a new branch named +remote"
},
{
"role": "assistant",
"content": "The + needs to come at the beginning of the argument representing the couple.\ngit push origin +localBranchName:remoteBranchName\n\nThat's hard to remember sometimes, so there's also the --force flag.\ngit push origin --force localBranchName:remoteBranchName\n\nBut be aware if you push multiple branches with that flag, then they will all be force pushed.\ngit push origin --force localBranchName:remoteBranchName anotherLocalBranch\n\nIn that case, you may not have wanted to force push anotherLocalBranch, so you should instead use the + to specify which ones you want forced.\ngit push origin +localBranchNameForced:remoteBranchName localBranchNotForced:remoteBranchNotForced +anotherLocalBranchForcePushedToUpstreamTracking\n\nDo read Torek's answer for a better explanation, and check out some of his other answers for world-class knowledge on git."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Get error message ''fatal: sha1 information is lacking or useless\" when apply a patch using \"git am -3\"\nI am trying to apply a series of patches from 1 git repository to another git repository using git am -3 \"path to a patch\". I apply them in order, from patch 1-4, it works fine.\nBut when I come to 5th patch,I get the error saying \"fatal: sha1 information is lacking or useless\". I go the to git repository where I apply the patch, I do see the file 'dev/afile'.\nSo I wonder why git is complaining about \"sha1 information is lacking or useless (dev/afile.c)\" and how can I fix my problem?\n $ git am -3 ~/Tmp/mypatches/0005-fifth.patch\nApplying: rpmsg: Allow devices to use custom buffer allocator\nfatal: sha1 information is lacking or useless (dev/afile.c).\nRepository lacks necessary blobs to fall back on 3-way merge.\nCannot fall back to three-way merge.\nPatch failed at 0001 first patch\nWhen you have resolved this problem run \"git am --resolved\".\nIf you would prefer to skip this patch, instead run \"git am --skip\".\nTo restore the original branch and stop patching run \"git am --abort\".\n\nAnd why it said \"Patch failed at 0001 first patch\", when I do \"git am -3 ~/Tmp/mypatches/0005-fifth.patch\", it completes with no error.\nThank you."
},
{
"role": "assistant",
"content": "Just did the following and was able to solve this issue:\npatch -p1 < example.patch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options lsrefs.unborn"
},
{
"role": "assistant",
"content": "May be \"advertise\" (the default), \"allow\", or \"ignore\". If \"advertise\",\nthe server will respond to the client sending \"unborn\" (as described in gitprotocol-v2 ) and will advertise support for this feature during the\nprotocol v2 capability advertisement. \"allow\" is the same as\n\"advertise\" except that the server will not advertise support for this\nfeature; this is useful for load-balanced servers that cannot be\nupdated atomically (for example), since the administrator could\nconfigure \"allow\", then after a delay, configure \"advertise\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to configure git bash command line completion?\nE.g. on a fresh ubuntu machine, I've just run sudo apt-get git, and there's no completion when typing e.g. git check[tab].\nI didn't find anything on http://git-scm.com/docs, but IIRC completion is included in the git package these days and I just need the right entry in my bashrc."
},
{
"role": "assistant",
"content": "On Linux\nOn most distributions, git completion script is installed into /etc/bash_completion.d/ (or /usr/share/bash-completion/completions/git) when you install git, no need to go to github. You just need to use it - add this line to your .bashrc:\nsource /etc/bash_completion.d/git\n# or\nsource /usr/share/bash-completion/completions/git\n\nIn some versions of Ubuntu, git autocomplete may be broken by default, reinstalling by running this command should fix it:\nsudo apt-get install git-core bash-completion\n\nOn Mac\nYou can install git completion using Homebrew or MacPorts.\nHomebrew\nif $BASH_VERSION > 4: brew install bash-completion@2 (updated version)\nPay special care which version of bash you have as MacOS default ships with 3.2.57(1)-release.\nadd to .bash_profile:\n [[ -r \"/usr/local/etc/profile.d/bash_completion.sh\" ]] && . \"/usr/local/etc/profile.d/bash_completion.sh\"\n\nFor older versions of bash: brew install bash-completion\nadd to .bash_profile:\n[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion\n\nMacPorts\nsudo port install git +bash_completion\nthen add this to your .bash_profile:\nif [ -f /usr/share/bash-completion/bash_completion ]; then\n . /usr/share/bash-completion/bash_completion\nfi\n\nmore info in this guide: Install Bash git completion\nNote that in all cases you need to create a new shell (open a new terminal tab/window) for changes to take effect."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github: How do I add my own projects to an \"organization\" account?\nI have started collaborating on a series of projects with several developers on github, and we recently created an organization with it's own \"organization\" type account on github. I see that I can fork repositories of my collaborators into the organization account using the usual fork menu, but of course I cannot fork my own account. \nWhat is the expected workflow to import my existing repositories into the organizational account? (I presume I could fork projects hosted by the other members, but not my own?)"
},
{
"role": "assistant",
"content": "Navigate to the Settings tab of your repository:\n\n\n\nScroll down to the Danger Zone and click Transfer:\n\n\n\nAfter reading the warnings, provide the name of the repository that you want to transfer and the specific organisation that the repository is going to be transferred to and click I understand, transfer this repository:\n\n\n\nDone! You 'll then be notified that you action will take effect in a few minutes:\n\n\nFor more details, you can always refer to the official documentation.\nWarning: once this is done, make sure you also update any local repository references using the following command git remote set-url origin <new-origin>."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I archive git branches?\nI have some old branches in my git repository that are no longer under active development. I would like to archive the branches so that they don't show up by default when running git branch -l -r. I don't want to delete them, because I want to keep the history. How can I do this?\nI know that it's possible to create a ref outside of refs/heads. For example, refs/archive/old_branch. Are there any consequences of doing that?"
},
{
"role": "assistant",
"content": "I believe the proper way to do this is to tag the branch. If you delete the branch after you have tagged it then you've effectively kept the branch around but it won't clutter your branch list.\nIf you need to go back to the branch just check out the tag. It will effectively restore the branch from the tag.\nTo archive and delete the branch:\ngit tag archive/<branchname> <branchname>\ngit branch -d <branchname>\n\nTo restore the branch some time later:\ngit checkout -b <branchname> archive/<branchname>\n\nThe history of the branch will be preserved exactly as it was when you tagged it."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "heroku and github at the same time\nSo I understand that heroku functions as a git repository, but let's say i want to use github as well as a repository. How do I set it up such that I have two repositories and both are in sync?"
},
{
"role": "assistant",
"content": "You can have multiple remotes on a git installation. You would have a github remote, and a heroku remote.\nAssuming you already have github setup, then you probably push to github with something like:\ngit push origin master\norigin is your remote, and master is your branch.\nFollow the instructions in getting started with Heroku choose your desired language and continue through the tutorial. This tutorial assumes that you already have github setup, and will show you how to create your heroku remote - via heroku create.\nYou then push to github as normal, and push to heroku via:\ngit push heroku master\nThe same format applies - heroku is your remote, and master is your branch. You are not overwriting your Github remote here, you are adding another, so you can still do both pushes via one commit with workflow such as:\ngit add .\ngit commit -m \"Going to push to Heroku and Git\"\ngit push origin master -- push to Github Master branch\ngit push heroku master -- push to Heroku"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Building Go apps with private modules in Docker\n\nI'm trying to build a go project in a docker container that relies on private submodules.\nI was hoping that --mount=type=ssh would pass my ssh credentials to the container and it'd work. Currently I can build locally with just make the GOPRIVATE variable set and the git config update.\nHere is my relevant Dockerfile currently\n# syntax = docker/dockerfile:experimental\n\nFROM golang:1.14.3-alpine AS build\nRUN apk add --no-cache git \\\n openssh-client \\\n ca-certificates\n\nWORKDIR /src\nENV GIT_TERMINAL_PROMPT=1\nENV GOPRIVATE=\"gitlab.com/company_foo\"\nRUN git config --global url.\"ssh://[email protected]\".insteadOf \"https://gitlab.com\"\n\n\n\n# Authorize SSH Host\n# Skip Host verification for git\nRUN mkdir -p /root/.ssh && \\\n chmod 0700 /root/.ssh && \\\n ssh-keyscan gitlab.com > /root/.ssh/known_hosts &&\\\n chmod 644 /root/.ssh/known_hosts && touch /root/.ssh/config \\\n && echo \"StrictHostKeyChecking no\" > /root/.ssh/config\n\nCOPY go.mod go.sum .\nRUN --mount=type=ssh mkdir -p /var/ssh && \\\n GIT_SSH_COMMAND=\"ssh -o \\\"ControlMaster auto\\\" -o \\\"ControlPersist 300\\\" -o \\\"ControlPath /var/ssh/%r@%h:%p\\\"\" \\\n go mod download\nCOPY . .\nRUN --mount=type=cache,target=/root/.cache/go-build go build -o api-server ./cmd/api-server\nRUN --mount=type=cache,target=/root/.cache/go-build go build -o migrations ./cmd/migrations\n\nI've also tried adding a CI_JOB_TOKEN with\nRUN echo -e \"machine gitlab.com\\nlogin gitlab-ci-token\\npassword ${CI_JOB_TOKEN}\" > ~/.netrc\n\nbut this also didn't work. Perhaps I did it wrong.\nAll of this results in the failure:\n revision v0.0.3: unknown revision v0.0.3\n\nrelating to one of our private repos.\nAny advice would be appreciate.\nI'm absolutely at a lost."
},
{
"role": "assistant",
"content": "This workes for me.\nFROM golang:1.14\nARG USERNAME=user1\nARG PASSWORD=secret\n\nWORKDIR /app\nADD . .\nENV GOPRIVATE=private.git.local/*\nRUN echo \"machine private.git.local login $USERNAME password $PASSWORD\" > ~/.netrc\n\nRUN go build -o testGo main.go\nCMD [\"/app/testGo\"]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to force push to Gitlab\n\ngit push --force gitlab master \nEnumerating objects: 50, done.\nCounting objects: 100% (50/50), done.\nDelta compression using up to 8 threads\nCompressing objects: 100% (29/29), done.\nWriting objects: 100% (40/40), 12.22 KiB | 4.07 MiB/s, done.\nTotal 40 (delta 26), reused 18 (delta 11)\nremote: GitLab: You are not allowed to force push code to a protected branch on this project.\nTo gitlab.com:xxx/yyyy.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to '[email protected]:xxx/yyyy.git'\n\nWhat should I do to push my commits to Gitlab? I use several remotes, and other remotes are OK and I was able to finish\ngit push --force some_other_remote master"
},
{
"role": "assistant",
"content": "From the official documentation on dealing with Protected Branches:\n\nNavigate to your project’s Settings ➔ Repository\nScroll to find the Protected branches section.\nFrom the Branch dropdown menu, select the branch you want to protect and click Protect.\n\nFollowing the steps above, you should be greeted with a box similar to this one below.\n\nThere, you can click either:\n\n\"Allowed to force push\" toggle button, or\nthe orange Unprotect button\n\nfor the branch you want to force push to, e.g., master.\nIf you don't want to navigate through the navigation bars, you can also fill out this URL template:\nhttps://gitlab.com/<USERNAME>/<PROJECTNAME>/settings/repository#js-protected-branches-settings\n\nand replace <USERNAME> and <PROJECTNAME> with your specific username and project name, respectively.\nNote, the \"Allowed to force push\" button is probably favored over un-selecting the Unprotect button because branch protection gives you additional safety from accidentally deleting your branch. But either option appears to work.\nMore help:\n\nCommunity discussion on force pushing on branch https://gitlab.com/gitlab-com/support-forum/issues/93\nOfficial documentation to do so https://docs.gitlab.com/ee/user/project/protected_branches.html"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_COMMITTER_NAME"
},
{
"role": "assistant",
"content": "The human-readable name used in the committer identity when creating commit or\ntag objects, or when writing reflogs. Overrides the user.name and committer.name configuration settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Gitlab deploy script - envsubst: command not found\n\nI have a gitlab repo with CI/CD pipeline. It has deploy.sh script, which runs smoothly until envsubst command:\n#!/bin/bash\n\nset -e\n<...>\n# deploy via ssh\nSSH=\"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -l $SSH_USER \n$HOST\"\n\necho \"create project dir\"\n$SSH \"mkdir -p $PROJECT_ROOT\"\n\necho \"create env file\"\nenvsubst < $CI_ENVIRONMENT_NAME.tmpl.env | $SSH \"cat > ${PROJECT_ROOT}/${CI_ENVIRONMENT_NAME}.env\"\n\nJob fails with error:\ncreate env file\n./deploy.sh: line 65: envsubst: command not found\n\nHeaders of '.gitlab-ci.yml' file:\nimage: docker:latest\nservices:\n - docker:dind"
},
{
"role": "assistant",
"content": "As DavidMaze pointed out, I added 'gettext' package to '.gitlab-ci.yml' file:\ndeploy-on-server:\n stage: deploy\n when: manual\n before_script:\n - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'\n - apk update && apk add bash\n - apk update && apk add gettext\n <...>"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to find the current git branch in detached HEAD state\nI can find the current git branch name by doing either of these:\ngit branch | awk '/^\\*/ { print $2 }'\ngit describe --contains --all HEAD\n\nBut when in a detached HEAD state, such as in the post build phase in a Jenkins maven build (or in a Travis git fetch), these commands doesn't work.\nMy current working solution is this:\ngit show-ref | grep $(git log --pretty=%h -1) | sed 's|.*/\\(.*\\)|\\1|' | sort -u | grep -v HEAD\n\nIt displays any branch name that has the last commit on its HEAD tip. This works fine, but I feel that someone with stronger git-fu might have a prettier solution?"
},
{
"role": "assistant",
"content": "A more porcelain way:\ngit log -n 1 --pretty=%d HEAD\n\n# or equivalently:\ngit show -s --pretty=%d HEAD\n\nThe refs will be listed in the format (HEAD, master) - you'll have to parse it a little bit if you intend to use this in scripts rather than for human consumption.\nYou could also implement it yourself a little more cleanly:\ngit for-each-ref --format='%(objectname) %(refname:short)' refs/heads | awk \"/^$(git rev-parse HEAD)/ {print \\$2}\"\n\nwith the benefit of getting the candidate refs on separate lines, with no extra characters."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show-ref - List references in a local repository --head"
},
{
"role": "assistant",
"content": "Show the HEAD reference, even if it would normally be filtered out."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-fsck - Verifies the connectivity and validity of the objects in the database badFilemode"
},
{
"role": "assistant",
"content": "(INFO) A tree contains a bad filemode entry."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --stat[=<width>[,<name-width>[,<count>]]]"
},
{
"role": "assistant",
"content": "Generate a diffstat. By default, as much space as necessary\nwill be used for the filename part, and the rest for the graph\npart. Maximum width defaults to terminal width, or 80 columns\nif not connected to a terminal, and can be overridden by <width> . The width of the filename part can be limited by\ngiving another width <name-width> after a comma or by setting diff.statNameWidth=<width> . The width of the graph part can be\nlimited by using --stat-graph-width=<width> or by setting diff.statGraphWidth=<width> . Using --stat or --stat-graph-width affects all commands generating a stat graph,\nwhile setting diff.statNameWidth or diff.statGraphWidth does not affect git format-patch .\nBy giving a third parameter <count> , you can limit the output to\nthe first <count> lines, followed by ... if there are more. These parameters can also be set individually with --stat-width=<width> , --stat-name-width=<name-width> and --stat-count=<count> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I change which commit master points to in git?\nIn git, I've been making commits onto the master branch, when really I should have been working on a feature branch. I want to change this so that master is back to where it started, and what was on master is now on a new branch. Basically, my commit history looks like this:\nA -- B -- C -- D -- E\n | |\n | master\n origin/master\n\nAnd I want it to look like this:\n master\n |\nA -- B -- C -- D -- E\n | |\n | new_branch\n origin/master\n\nHow can I change where master points?"
},
{
"role": "assistant",
"content": "Stash your uncommitted changes: git stash\nCreate a new branch: git branch new_branch\nReset master to origin/master: git reset --hard origin/master\nCheck out the new branch again: git checkout new_branch\nUnstash your changes: git stash pop\n\nStash/unstash is not necessary if your working tree is clean. Just make sure there are no changes in your working tree, because those will be removed when you reset --hard\n\nAnother possibility (faster, and without the need to stash and reset):\n\nCheck out a new branch: git checkout -b new_branch master\nCreate a 'new' master branch and point it to origin/master's commit: git branch -f master origin/master"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Rebasing a local branch from develop\nI want to rebase a feature branch from develop. I am using PhpStorm Git integration and I have 2 different develop branches:\nrefs/remotes/origin/develop\nrefs/heads/develop\n\nIn order to do not mess up things, which one do I have to choose to rebase?"
},
{
"role": "assistant",
"content": "I don't know the phpstorm interface for Git, but in the command line I'd do the following:\n\ngit checkout develop\ngit pull origin develop -> this fetches the remote version of the develop branch and merges it (or rebases it, depending on your pull strategy) into/onto your local branch. This way the local and the remote versions of develop are the same\ngit checkout feature-brach\ngit rebase develop\n\nIf there are any conflicts - resolve them. After that you can create a pull request against develop."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How can I preview a merge in git?\nI have a git branch (the mainline, for example) and I want to merge in another development branch. Or do I?\nIn order to decide whether I really want to merge this branch in, i'd like to see some sort of preview of what the merge will do. Preferably with the ability to see the list of commits that are being applied.\nSo far, the best I can come up with is merge --no-ff --no-commit, and then diff HEAD."
},
{
"role": "assistant",
"content": "git log ..otherbranchlist of changes that will be merged into current branch.\ngit diff ...otherbranchdiff from common ancestor (merge base) to the head of what will be merged. Note the three dots, which have a special meaning compared to two dots (see below).\ngitk ...otherbranchgraphical representation of the branches since they were merged last time.\n\nEmpty string implies HEAD, so that's why just ..otherbranch instead of HEAD..otherbranch.\nThe two vs. three dots have slightly different meaning for diff than for the commands that list revisions (log, gitk etc.). For log and others two dots (a..b) means everything that is in b but not a and three dots (a...b) means everything that is in only one of a or b. But diff works with two revisions and there the simpler case represented by two dots (a..b) is simple difference from a to b and three dots (a...b) mean difference between common ancestor and b (git diff $(git merge-base a b)..b)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-notes - Add or inspect object notes notes.mergeStrategy"
},
{
"role": "assistant",
"content": "Which merge strategy to choose by default when resolving notes\nconflicts. Must be one of manual , ours , theirs , union , or cat_sort_uniq . Defaults to manual . See the \"NOTES MERGE STRATEGIES\"\nsection of git-notes for more information on each strategy. This setting can be overridden by passing the --strategy option to git-notes ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitHub changes repository to the wrong language\nI know this isn't a huge deal, but I like my GitHub to be linguistically diversified. I wrote a project in Swift and when I commit it says it's in Objective-C.\nI think it might be because the Parse frameworks are written in Objective-C and it detects that, but is there a way to change the display language on the main repository page?"
},
{
"role": "assistant",
"content": "I found the simplest thing was to create a file called .gitattributes in the root folder of my repository, and give it these contents:\n* linguist-vendored\n*.js linguist-vendored=false\n\nThis example tells GitHub/Linguist to ignore all files, and then just look at .js files. My project, https://github.com/aim12340/jQuery-Before-Ready, was listed as HTML because the HTML example files were bigger than the JavaScript files. This file fixes it for me and now it's listed as JavaScript."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %cs"
},
{
"role": "assistant",
"content": "committer date, short format ( YYYY-MM-DD )"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to force update when doing git pull?\nI'm doing git pull of an open source lib, I don't care what my local copy is I just want to update it with the origin's version.\ni.e. it can blow away my local changes."
},
{
"role": "assistant",
"content": "This should do the trick:\ngit reset --hard HEAD\ngit pull"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I use an env file with GitHub Actions?\n\nI have multiple environments (dev, qa, prod) and I'm using .env files to store secrets etc... Now I'm switching to GitHub Actions, and I want to use my .env files and declare them into the env section of the github actions yml.\nBut from what I've seen so far, it seems that I can not set a file path and I have to manually re-declare all variables.\nHow should I proceed as best practice?"
},
{
"role": "assistant",
"content": "A quick solution here could be having a step to manually create the .env file before you need it.\n - name: 'Create env file'\n run: |\n touch .env\n echo API_ENDPOINT=\"https://xxx.execute-api.us-west-2.amazonaws.com\" >> .env\n echo API_KEY=${{ secrets.API_KEY }} >> .env\n cat .env"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What does \"Changes not staged for commit\" mean\nI thought if you want to track the files you should git add [files you want to track]\nI don't know why I got the messages Changes not staged for commit.\nIf those files were not staged, shouldn't git shows me those files were Untracked like that\n\nAll I've done was create a new feature from develop branch and worked in feature/change_excel_format branch\nI thought Those files should be in staged status,\nBut git status told me Changes not staged for commit\n\nTo brief, \nI only know there are 3 stages in git untracked, staged, committed\nCan any one tell me , what was the stage in for Changes not staged for commit\n\nSo if I modified the file a (already in the repo)\nand type git st , the git will tell me Changes not staged for commit\nif I git a then the file a will be in staged status\nif I modified the file a now, there will be two status of file a in git, right ?\nSo I have to decide if make the staged a be commit or make the not stage a to be staged,\nand then the previous staged file awill be discard ?"
},
{
"role": "assistant",
"content": "when you change a file which is already in the repository, you have to git add it again if you want it to be staged.\nThis allows you to commit only a subset of the changes you made since the last commit. For example, let's say you have file a, file b and file c. You modify file a and file b but the changes are very different in nature and you don't want all of them to be in one single commit. You issue\ngit add a\ngit commit a -m \"bugfix, in a\"\ngit add b\ngit commit b -m \"new feature, in b\"\n\nAs a side note, if you want to commit everything you can just type\ngit commit -a"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to add a new project to Github using VS Code\nAll the tutorials i've seen till now shows to first create a repository on github, copy the link go to vscode and git clone it and from that on, you can do commits and pushes.\nIs that the right way ? can't I just start a project from vscode and then upload it to my git ?\nEDIT 2020 :\nYou can now do it right inside vscode! just follow these steps:\n1- Open your new project folder with vscode\n2- click on the source conrol menu on the sidebar (or press Ctrl+Shift+G)\n3- Click on publish to github \n4- From there just login and follow the instructions and you're good to go.\n@Debu's answer details every step, so you can jump to there"
},
{
"role": "assistant",
"content": "Here are the detailed steps needed to achieve this.\nThe existing commands can be simply run via the CLI terminal of VS-CODE. It is understood that Git is installed in the system, configured with desired username and email Id.\n\nNavigate to the local project directory and create a local git repository:\ngit init\n\nOnce that is successful, click on the 'Source Control' icon on the left navbar in VS-Code.One should be able to see files ready to be commit-ed. Press on 'Commit' button, provide comments, stage the changes and commit the files. Alternatively you can run from CLI\ngit commit -am \"Your comment\"\n\nNow you need to visit your GitHub account and create a new Repository. Exclude creating 'README.md', '.gitIgnore' files. Also do not add any License to the repo. Sometimes these settings cause issue while pushing in.\n\nCopy the link to this newly created GitHub Repository.\n\nCome back to the terminal in VS-CODE and type these commands in succession:\ngit remote add origin <Link to GitHub Repo> //maps the remote repo link to local git repo\ngit remote -v //this is to verify the link to the remote repo\ngit push -u origin master // pushes the commit-ed changes into the remote repo\n\n\n\nNote: If it is the first time the local git account is trying to\nconnect to GitHub, you may be required to enter credentials to GitHub in a separate window.\n\n\nYou can see the success message in the Terminal. You can also verify by refreshing the GitHub repo online."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options splitIndex.sharedIndexExpire"
},
{
"role": "assistant",
"content": "When the split index feature is used, shared index files that\nwere not modified since the time this variable specifies will\nbe removed when a new shared index file is created. The value\n\"now\" expires all entries immediately, and \"never\" suppresses\nexpiration altogether.\nThe default value is \"2.weeks.ago\".\nNote that a shared index file is considered modified (for the\npurpose of expiration) each time a new split-index file is\neither created based on it or read from it.\nSee git-update-index ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --bisect"
},
{
"role": "assistant",
"content": "Pretend as if the bad bisection ref refs/bisect/bad was listed and as if it was followed by --not and the good\nbisection refs refs/bisect/good-* on the command\nline."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-blame - Show what revision and author last modified each line of a file --score-debug"
},
{
"role": "assistant",
"content": "Include debugging information related to the movement of\nlines between files (see -C ) and lines moved within a\nfile (see -M ). The first number listed is the score.\nThis is the number of alphanumeric characters detected\nas having been moved between or within files. This must be above\na certain threshold for git blame to consider those lines\nof code to have been moved."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What exactly is a Release in GitHub?\n\nWhat is it exactly?\nFor what is it used? \nHow widespread is the usage? \nHow is it usually used?"
},
{
"role": "assistant",
"content": "From Official GitHub:\nReleases are GitHub's way of packaging and providing software to your users. You can think of it as a replacement to using downloads to provide software.\nWith Releases, you can provide links to binary files, as well as release notes describing your changes.\nAt their core, Releases are based on Git tags. Tags mark a specific point in the history of your project, so they're a great way to indicate a Release. Releases are ordered by a tag's date in the following way:\n\nIf it's an annotated tag, the tag object's date is used.\nIf it's a lightweight tag, then the commit object's date is used.\n\nFor more information about viewing your existing tags, see Working With Tags."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git rebase change author? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow do I change the author and committer name/email for multiple commits?\n\n (42 answers)\n \n\nClosed 11 years ago.\n\n\n\nSo I stupidly made 3 commits on a machine that was not configured for git (no author or email) and I want to change those 3 commits (have not been pushed) authors to what they are suppose to be.\nI know git commit --amend can change the author, but how can I do it to 3? I know rebase can change the message. Is there a way to change author?"
},
{
"role": "assistant",
"content": "You can use interactive rebase. The answer from this post gives you an example:\nHow to change the commit author for one specific commit?.\nIn particular, you can do the following to change one specific commit:\ngit commit --amend --author=\"Author Name <[email protected]>\" --no-edit\nThe author asks for changing author at a specific commit, but interactive rebasing can be used to change authors of multiple commits if you edit all commits that you wish to change.\nOther potential useful techniques related to interactive rebasing could be found in the Pro Git book\nhttp://git-scm.com/book/en/Git-Tools-Rewriting-History, including squashing, redordering, editing messages, etc."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --signature-file=<file>"
},
{
"role": "assistant",
"content": "Works just like --signature except the signature is read from a file."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I find and restore a deleted file in a Git repository?\nSay I'm in a Git repository. I delete a file and commit that change. I continue working and make some more commits. Then, I discover that I need to restore that file after deleting it.\nI know I can checkout a file using git checkout <commit> -- filename.txt, but I don't know when that file was deleted.\n\nHow do I find the commit that deleted a given filename?\nHow do I restore that file back into my working copy?"
},
{
"role": "assistant",
"content": "Find the last commit that affected the given path. As the file isn't in the HEAD commit, that previous commit must have deleted it.\ngit rev-list -n 1 HEAD -- <file_path>\n\nThen checkout the version at the commit before, using the caret (^) symbol:\ngit checkout <deleting_commit>^ -- <file_path>\n\nOr in one command, if $file is the file in question.\ngit checkout $(git rev-list -n 1 HEAD -- \"$file\")^ -- \"$file\"\n\n\nIf you are using zsh and have the EXTENDED_GLOB option enabled, the caret symbol won't work. You can use ~1 instead.\ngit checkout $(git rev-list -n 1 HEAD -- \"$file\")~1 -- \"$file\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Add .gitignore to gitignore\nIs it possible to add the .gitignore file to .gitignore itself?\n.gitignore\n\nDoesn't work though\nI don't want to see it in edited files"
},
{
"role": "assistant",
"content": "The .gitignore file's purpose is to prevent everyone who collaborates on a project from accidentally commiting some common files in a project, such as generated cache files. Therefore you should not ignore .gitignore, since it's supposed to be included in the repository.\nIf you want to ignore files in just one repository but want to avoid committing the ignore list (for example for personal files) you can add them to .git/info/exclude in that repository.\nIf you want to ignore certain files on every repository on your machine you can create the file ~/.gitignore_global and then run\ngit config --global core.excludesfile ~/.gitignore_global"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to delete remote repository on github?\n\nI want to know how to delete repo in github account. I cannot see any indicators to delete on github interface."
},
{
"role": "assistant",
"content": "You can go to the main page of the repository and under your repository name, click \"Settings\"...\n\n...and scroll down to the \"Danger Zone\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to revert project back to a previous commit in android studio\nI am working on a project in android studio and would like to revert to a previous push. I attempted\nVCS => Git => Reset Head (Hard)\nbut my project in Android Studio is unchanged, likely because I'm doing something wrong. I would like to revert the project in Android Studio to a specific earlier commit that I've pushed and I see on github. I do not care about any changes that I have made since the earlier push.\nAdditionally, I would like this to be done through the GUI within Android Studio if possible."
},
{
"role": "assistant",
"content": "Android Studio Instructions: if you want to do this in Android Studio, press alt + 9 (or Command + 9 on Mac) to open the Version Control panel. Switch to the Log tab and right click on a previous commit. Select Checkout Revision.\n\nCommand line instructions: Open the command line tool you are using.\nGo to the Android app's Git directory (using cd).\nExecute git log and find the previous commit you want to revert to.\ncommit 7c247be6d8975dc88f6cc2631c154786a1f3b79e\nAuthor: John Doe <[email protected]>\nDate: Fri Jun 11 22:37:35 2015 -0400\n\n Some helpful commit message should be here.\n\nIf that is the commit you want to revert to, then execute git checkout 7c247b."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files"
},
{
"role": "assistant",
"content": "NAME git-checkout - Switch branches or restore working tree files"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc --word-diff-regex=<regex>"
},
{
"role": "assistant",
"content": "Use <regex> to decide what a word is, instead of considering\nruns of non-whitespace to be a word. Also implies --word-diff unless it was already enabled. Every non-overlapping match of the\n<regex> is considered a word. Anything between these matches is\nconsidered whitespace and ignored(!) for the purposes of finding\ndifferences. You may want to append |[^[:space:]] to your regular\nexpression to make sure that it matches all non-whitespace characters.\nA match that contains a newline is silently truncated(!) at the\nnewline. For example, --word-diff-regex=. will treat each character as a word\nand, correspondingly, show differences character by character. The regex can also be set via a diff driver or configuration option, see gitattributes or git-config . Giving it explicitly\noverrides any diff driver or configuration setting. Diff drivers\noverride configuration settings."
}
] |