messages
listlengths 3
3
|
---|
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "For an Amazon S3 bucket deployment from GitHub how do I fix the error AccessControlListNotSupported: The bucket does not allow ACLs?\n\nI have the following access policy set on an IAM user in my AWS account. The policy references the bucket name which is \"xo-staging\".\n{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"AccessToGetBucketLocation\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:GetBucketLocation\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::*\"\n ]\n },\n {\n \"Sid\": \"AccessToWebsiteBuckets\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"s3:PutBucketWebsite\",\n \"s3:PutObject\",\n \"s3:PutObjectAcl\",\n \"s3:GetObject\",\n \"s3:ListBucket\",\n \"s3:DeleteObject\"\n ],\n \"Resource\": [\n \"arn:aws:s3:::xo-staging\",\n \"arn:aws:s3:::xo-staging/*\"\n ]\n },\n {\n \"Sid\": \"AccessToCloudfront\",\n \"Effect\": \"Allow\",\n \"Action\": [\n \"cloudfront:GetInvalidation\",\n \"cloudfront:CreateInvalidation\"\n ],\n \"Resource\": \"*\"\n }\n ]\n}\n\nI'm deploying a Gatsby application from my local machine to Github where I am using Github Actions to run a build and deploy script.\nIn my package.json file I have set \"deploy\" to the value of gatsby-plugin-s3 deploy --yes; export AWS_PAGER=\\\"\\\"; aws cloudfront create-invalidation --distribution-id E5FDMTLPHUTLTL --paths '/*'; in my workflows.yml file I have set \"deploy\" to npm run deploy.\nIn Github my build succeeds but my deploy fails. The error I get tells me \"AccessControlListNotSupported: The bucket does not allow ACLs\".\nI've checked the actual bucket permissions in AWS and tried selecting different options, but always the same error message returns. In other words, I have tried removing all blocks on public access and ACLs but still the problem persists.\nPlease can someone suggest what I might need to change to get this full deploy working?"
},
{
"role": "assistant",
"content": "Adding Screenshots to the answer provided by @rudieros\n\nGo to Bucket > Permissions Tab\n\n\nScroll to Object Ownership and click on Edit.\n\n\nChange the settings as below."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git production/staging server workflow\nCurrently my website (production server) already have a lot of code in it.\nAnd now I want to start using Git for my projects and setup a staging server for my team.\nCan anybody give me any advise?\nHere is the picture in my mind:\n Production - Production server which already have codes\n ↑ \n Staging - New staging server, will install Trac too\n ↗↙ ↖↘ \n Developer1 Developer2 - Local development \n\nMy question is, how should I start? \nHere are some steps in my mind:\n\ndo a git init in production server (is this safe?) \nclone the repo from production to staging server\ndevelopers clone the repo from the staging to their local machine\npush files to the staging server after finish changing\nwhen staging is ready, push everything to the production\n\nDoes this work flow makes sense, or there are some better way to do it?\nWhat if I only want to change one file?\nDoes origin/master has anything to do with it in this process?? \nWho is the origin? am I going to end up having multiple origins??\nAlso, when should a developer use branch in this case?"
},
{
"role": "assistant",
"content": "It's better to use master branch only for Production and development branch for Staging. Each developer should create local branch to add new features and then merge with development branch. If you're new to a git, try to use - http://github.com/nvie/gitflow There is also good picture describing git branching model - http://nvie.com/posts/a-successful-git-branching-model/"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --compact-summary"
},
{
"role": "assistant",
"content": "Output a condensed summary of extended header information such\nas file creations or deletions (\"new\" or \"gone\", optionally \"+l\"\nif it’s a symlink) and mode changes (\"+x\" or \"-x\" for adding\nor removing executable bit respectively) in diffstat. The\ninformation is put between the filename part and the graph\npart. Implies --stat ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission -v <n> --reroll-count=<n>"
},
{
"role": "assistant",
"content": "Mark the series as the <n>-th iteration of the topic. The\noutput filenames have v<n> prepended to them, and the\nsubject prefix (\"PATCH\" by default, but configurable via the --subject-prefix option) has ` v<n>` appended to it. E.g. --reroll-count=4 may produce v4-0001-add-makefile.patch file that has \"Subject: [PATCH v4 1/20] Add makefile\" in it. <n> does not have to be an integer (e.g. \"--reroll-count=4.4\",\nor \"--reroll-count=4rev2\" are allowed), but the downside of\nusing such a reroll-count is that the range-diff/interdiff\nwith the previous version does not state exactly which\nversion the new iteration is compared against."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options notes.rewriteMode"
},
{
"role": "assistant",
"content": "When copying notes during a rewrite (see the\n\"notes.rewrite.<command>\" option), determines what to do if\nthe target commit already has a note. Must be one of overwrite , concatenate , cat_sort_uniq , or ignore .\nDefaults to concatenate . This setting can be overridden with the GIT_NOTES_REWRITE_MODE environment variable."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-checkout - Switch branches or restore working tree files --ignore-skip-worktree-bits"
},
{
"role": "assistant",
"content": "In sparse checkout mode, git checkout -- <paths> would\nupdate only entries matched by <paths> and sparse patterns\nin $GIT_DIR/info/sparse-checkout . This option ignores\nthe sparse patterns and adds back any files in <paths> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to delete a stash created with git stash create?\nGit stash seems to do a lot of what I want, except that it is a little hard to script, as the if you have no changes, then git stash; git stash pop will do something different than if you do have changes in your repository.\nIt appears that git stash create is the answer to that problem, and everything works, except for one thing… I can't get rid of the created stash. Is there any way to get rid of the stash?\nTo make it 100% clear what I am doing:\nCreate the stash:\n~/tmp/a(master) $ git stash create \n60629375d0eb12348f9d31933dd348ad0f038435\n~/tmp/a(master) $ git st\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# new file: b\n#\n~/tmp/a(master) $ git reset --hard\nHEAD is now at 555d572 log message\n\nUse the stash:\n~/tmp/a(master) $ git apply 60629375d0eb12348f9d31933dd348ad0f038435\nfatal: can't open patch '60629375d0eb12348f9d31933dd348ad0f038435': No such file or directory\n~/tmp/a(master) $ git stash apply 60629375d0eb12348f9d31933dd348ad0f038435\n# On branch master\n# Changes to be committed:\n# (use \"git reset HEAD <file>...\" to unstage)\n#\n# new file: b\n#\n\nDelete the stash: (except that this last bit doesn't work)\n~/tmp/a(master) $ git stash drop !$\ngit stash drop 60629375d0eb12348f9d31933dd348ad0f038435\n'60629375d0eb12348f9d31933dd348ad0f038435' is not a stash reference"
},
{
"role": "assistant",
"content": "git stash drop takes no parameter - which drops the top stash - or a stash reference which looks like: stash@{n} which n nominates which stash to drop. You can't pass a commit id to git stash drop.\ngit stash drop # drop top hash, stash@{0}\ngit stash drop stash@{n} # drop specific stash - see git stash list\n\nDropping a stash will change the stash@{n} designations of all stashes further down the stack.\nI'm not sure why you think need to drop a stash because if you are using stash create a stash entry isn't created for your \"stash\" so there isn't anything to drop."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Deploying a Git subdirectory in Capistrano\nMy master branch layout is like this:\n/ <-- top level\n/client <-- desktop client source files\n/server <-- Rails app\nWhat I'd like to do is only pull down the /server directory in my deploy.rb, but I can't seem to find any way to do that. The /client directory is huge, so setting up a hook to copy /server to / won't work very well, it needs to only pull down the Rails app."
},
{
"role": "assistant",
"content": "Without any dirty forking action but even dirtier !\nIn my config/deploy.rb :\nset :deploy_subdir, \"project/subdir\"\n\nThen I added this new strategy to my Capfile :\nrequire 'capistrano/recipes/deploy/strategy/remote_cache'\n\nclass RemoteCacheSubdir < Capistrano::Deploy::Strategy::RemoteCache\n\n private\n\n def repository_cache_subdir\n if configuration[:deploy_subdir] then\n File.join(repository_cache, configuration[:deploy_subdir])\n else\n repository_cache\n end\n end\n\n def copy_repository_cache\n logger.trace \"copying the cached version to #{configuration[:release_path]}\"\n if copy_exclude.empty? \n run \"cp -RPp #{repository_cache_subdir} #{configuration[:release_path]} && #{mark}\"\n else\n exclusions = copy_exclude.map { |e| \"--exclude=\\\"#{e}\\\"\" }.join(' ')\n run \"rsync -lrpt #{exclusions} #{repository_cache_subdir}/* #{configuration[:release_path]} && #{mark}\"\n end\n end\n\nend\n\n\nset :strategy, RemoteCacheSubdir.new(self)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Are dependent pull requests in GitHub possible?\n\nCurrently I am working on a really big pull request. In order to keep code reviews somehow manageable, the idea was to split the complete pull request into isolated parts which, however, depend on each other.\nAn example would be:\n\nPull request 1: Create interfaces: Interface A & B and restructure code.\nPull request 2: Interface A implementation and Tests (depends on pull request 1).\nPull request 3: Interface B implementation and Tests (depends on pull request 2).\nPull request 4: Mixed test of Implementations (depends on 2 + 3).\n\nIs there a way in GitHub to file all four pull requests at the same time reflecting the dependencies?"
},
{
"role": "assistant",
"content": "Update 2022: While GitHub still has no native support for dependent/stacked pull requests, a few tools now exist that make it easier to manage a GitHub-friendly hierarchy of branches. My favorite is ghstack, which takes a stack of commits and turns each one into its own branch that GitHub can understand without losing PR history. You can then edit, reorder, split, and drop commits using interactive rebase and the PRs will be updated accordingly.\n\nAs far as I can see, this is impossible, and in my opinion it's one of the major downsides of GitHub compared with other code review tools. Gerrit automatically sets up dependent code reviews when you push commits that depend on each other, and in Phabricator it's more of a pain, but still possible.\nIt's also good to keep in mind that there multiple ways that people use GitHub PRs. The normal open source collaboration way is to fork a repo and submit a cross-repo pull request, but in other cases (e.g. within an organization), you might submit pull requests for diffs all within the same repository. I think within a single repository it's more reasonable to get something along the lines of dependent pull requests, since you can set up the commit/branch structure within that repo.\nHere's a blog post that describes how to get some advantages of dependent pull requests, which I think requires all commits to be in the same repo:\nhttp://graysonkoonce.com/stacked-pull-requests-keeping-github-diffs-small/\nA summary:\n\nTo submit 5 dependent pull requests, create a 5-level-deep branch hierarchy and submit each PR as as that branch based on the previous branch.\nTo update review 2 of 5, push an update to branch 2, then do 3 merge operations to integrate the changes into reviews 3, 4, and 5.\nYou need to land all changes at once, since GitHub doesn't support updating the target branch of PRs. In the example, all 5 code reviews were landed as a single commit. GitHub now supports updating the base branch of a PR, so the PRs can be landed one at a time.\n\nThat approach seems to work ok for giant changes that are best reviewed in smaller pieces (although maintaining an n-level-deep branch hierarchy is a pain compared with something like git rebase -i), but it doesn't really allow for a \"code review pipeline\" where you can have dependent diffs in different stages of review and can land earlier ones as they're reviewed.\nSome other internet resources that seem to also call out the limitation:\nhttps://www.quora.com/Is-there-a-good-system-for-adding-multiple-pull-requests-to-GitHub\nhttps://muffinresearch.co.uk/how-do-you-deal-with-dependent-branches-on-github/\nMy understanding is that people using GitHub PRs generally just try to structure their workflow to not rely on dependent code reviews. Some examples:\n\nInstead of breaking up a change into independently-reviewable incremental steps, submit it as a monolithic code review that will land all at once. GitHub still lets you split code reviews up into multiple commits that the reviewer can view, but they can't be approved/landed independently.\nTry to structure your work so you make changes in unrelated parts of the code, and put them on independent branches that you can use to submit independent PRs. You can still keep a local branch with all changes applied using cherry-picking or other approaches.\nIf you have a change that depends on an outstanding PR, simply wait for the PR to get accepted and merged before submitting the new PR. You could mention somewhere that you have another PR that depends on that one, and maybe that will motivate the code reviewer to get to that one earlier."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clone - Clone a repository into a new directory -u <upload-pack> --upload-pack <upload-pack>"
},
{
"role": "assistant",
"content": "When given, and the repository to clone from is accessed\nvia ssh, this specifies a non-default path for the command\nrun on the other end."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-branch"
},
{
"role": "assistant",
"content": "List, create, or delete branches"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to send pull request on Git\nWe have recently migrated to Git from SVN. We have setup a bare repository on one machine in our LAN network and cloned on other machines. Now when anyone do the changes and commits we want that he sends the pull request to the bare repo (by telling or emailing or any other way) after that one will go through the changes and pull it on bare repository (same as it works on GitHub).\nDo we need to install any interface or there is some commands in Git itself?"
},
{
"role": "assistant",
"content": "Both Git (the software) and GitHub (the web service) have a concept called \"pull request\", and unfortunately they are not exactly the same thing.\nNative Git\nThe native Git request-pull command has a very short manual page with the following one-sentence description:\n\nSummarizes the changes between two commits to the standard output, and includes the given URL in the generated summary.\n\nThis is a fairly low-level command that generates a short summary of changes that is suitable for posting to a mailing list. Other users can use the URL published in this \"pull request\" to manually pull changes into their own repository.\nGitHub Pull Requests\nWhen using the GitHub web service, a Pull Request is a full-featured interactive collaboration tool. A GitHub pull request has:\n\na more detailed description of the changes than just the individual commit summaries\nnotifications automatically sent to users who have chosen to watch the project\nan online review interface where others can comment on proposed changes\ndiscussion comments for recording conversations about commits\ncentral management of pull requests so they won't get lost\n\nIt is worth noting that Linus has his own opinion on the relative utility of these two features.\nConclusion\nThe two \"pull request\" features described above are similar in spirit but completely different in implementation. In particular, the git request-pull command cannot be used to create a new Pull Request on GitHub. You have several choices if you want to support \"pull request\" type functionality:\n\nUse GitHub. This definitely involves the least effort, but if your project is not public you'll have to pay GitHub to host a private repository. Some people might not be comfortable with this choice.\nUse Gerrit. Gerrit is an open-source server program you can download that provides many features similar to those available in GitHub. It is especially well suited to collaborative code reviews.\nUse git request-pull and a mailing list. Using this method requires a lot more discipline from your engineers, as it's easy to misplace or mishandle mailing list messages. There is no central accountability associated with this method."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "moving changed files to another branch for check-in\nThis often happens to me: I write some code, go to check in my changes, and then realize I'm not in the proper branch to check in those changes. However I can't switch to another branch without my changes reverting. Is there a way to move changes to another branch to be checked in there?"
},
{
"role": "assistant",
"content": "Updated Answer\nNo need to use stash command. uncommitted changes do not belong to any branch so just use git checkout -b <new-branch>\n\nOrginal Answer\ngit stash is your friend.\nIf you have not made the commit yet, just run git stash. This will save away all of your changes.\nSwitch to the branch you want the changes on and run git stash pop.\nThere are lots of uses for git stash. This is certainly one of the more useful reasons.\nAn example:\n# work on some code\ngit stash\ngit checkout correct-branch\ngit stash pop"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Preferred Github workflow for updating a pull request after code review\n\nI've submitted a change to an Open Source project on Github, and received code review comments from one of the core team members.\nI would like to update the code taking into account the review comments, and re-submit it. What is the best workflow for doing this? From my limited knowledge of git/github, I could do any of the following:\n\nUpdate the code as a new commit, and add both the initial and updated commit to my pull request.\nSomehow (??) rollback the old commit from my repository, and create a single new commit containing everything, then raise a pull request for that?\ngit commit has an amend feature, but I've heard that you shouldn't use it after you've pushed the commit outside of your local repository? In this case I have made the change on my local PC and pushed to my github branch of the project. Would this be OK to use 'amend'?\nSomething else?\n\nIt seems like option 2/3 would be nice, as the open source project would only have one commit in their history which would implement everything, but I'm not sure how to do this.\nNote: I don't know if this affects the answer or not, but I didn't make the changes in a separate branch, I just did a commit on top of master"
},
{
"role": "assistant",
"content": "To update a pull request\nTo update a pull request (point #1), the only thing you need to do is checkout the same branch the pull request is from and push to it again:\ncd /my/fork\ngit checkout master\n...\ngit commit -va -m \"Correcting for PR comments\"\ngit push\n\nOptional - Cleaning commit history\nYou may be asked to squash your commits together so that the repository history is clean, or yourself want to remove intermediary commits which distract from \"the message\" in your pull request (point #2). For example if your commit history looks like this:\n$ git remote add parent [email protected]:other-user/project.git\n$ git fetch parent\n$ git log --oneline parent/master..master\ne4e32b8 add test case as per PR comments\neccaa56 code standard fixes as per PR comments\nfb30112 correct typos and fatal error\n58ae094 fixing problem\n\nIt's a good idea to squash things together so they appear as a single commit:\n$ git rebase -i parent/master \n\nThis will prompt you to choose how to rewrite the history of your pull request, the following will be in your editor:\npick 58ae094 fixing actual problem\npick fb30112 correct typos\npick eccaa56 code standard fixes\npick e4e32b8 add test case as per PR comments\n\nFor any commit you want to be part of the previous commit - change pick to squash:\npick 58ae094 fixing actual problem\nsquash fb30112 correct typos\nsquash eccaa56 code standard fixes\nsquash e4e32b8 add test case as per PR comments\n\nAnd close your editor. Git will then rewrite the history and prompt you to provide a commit message for the one combined commit. Amend accordingly and your commit history will now be concise:\n$ git log --oneline parent/master..master\n9de3202 fixing actual problem\n\nPush that to your fork:\n$ git push -f\nCounting objects: 19, done.\nDelta compression using up to 4 threads.\nCompressing objects: 100% (5/5), done.\nWriting objects: 100% (11/11), 978 bytes, done.\nTotal 11 (delta 9), reused 7 (delta 6)\nTo [email protected]:me/my-fork.git\n f1238d0..9de3202 HEAD -> master\n\nand your pull request will contain a single commit, incorporating all changes previously split into several commits.\nChanging history on public repos is a bad thing\nRewriting history and using git push -f on a branch that, potentially, someone else has already cloned is a bad thing - it causes the repository's history and that of the checkout to diverge.\nHowever, amending the history of your fork to correct the change you are proposing to be integrated into a repository - is a good thing. As such have no reservations squashing \"noise\" out of your pull requests.\nA note on branches\nIn the above I show the pull request as having come from the master branch of your fork, there's nothing wrong with that necessarily but it does create certain limitations such as, if this is your standard technique, only being able to have one PR open per repository. It's a better idea though to create a branch for each individual change you wish to propose:\n$ git branch feature/new-widgets\n$ git checkout feature/new-widgets\n...\nHack hack hack\n...\n$ git push\n# Now create PR from feature/new-widgets"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github committing (push) gist\n\nI cannot understand this.\nI have created a gist. Then I run\n$ mkdir mygist\n$ cd mygist\n$ git init\n$ git pull [email protected]:869085.git\nThen I add files, change files and try to commit.\n$ git add .\n$ git commit -a -m \"Better comments\"\nThen I do not know how to send it back to github and commit this git."
},
{
"role": "assistant",
"content": "It's probably easiest if you just start by cloning the gist, so that origin (a \"remote\" that refers to the original repository) is set up for you. Then you can just do git push origin master. For example:\ngit clone [email protected]:869085.git mygist\ncd mygist\n# Make your changes...\ngit add .\ngit commit -m \"Better comments\"\ngit push origin master\n\nHowever, if you don't want to redo your changes, you can do:\ncd mygist\ngit remote add origin [email protected]:869085.git\ngit fetch origin\n# Push your changes, also setting the upstream for master:\ngit push -u origin master\n\nStrictly speaking, the git fetch origin and -u argument to git push origin master are optional, but they will helpfully associate the upstream branch master in origin with your local branch master."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Access to a file or folder on heroku server\nWhen I deploy my application on Heroku server, the server generate an app automatically and I found on my resource a git url. Example: [email protected]:myapp-ss-1338.git. How can I access this url to view source code or folder via a web browser?"
},
{
"role": "assistant",
"content": "heroku run bash is the best way to see what is actually deployed to dynos. As for the git repo you should treat it more like a way to deploy your app (and so therefore ephemeral) than a place to store your code.\nThere is no way to view what is in that repo from your web browser.\nIf you want to get at the files in the Heroku repo you can do so by doing a git clone [repo address]."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I change the default author and committer in the Eclipse Git plugin?\nI am using the Git plugin for Eclipse. I have several authors and committers which are displayed when I start typing in those fields.\nHow can I provide changes to this list, or remove some author or committer?\nAlso, I want to set my default author and committer which will be displayed by default."
},
{
"role": "assistant",
"content": "Click Window > Preferences > Team > Git > Configuration\nClick Add Entry and enter the key value pairs:\n\nKey: user.name\nValue: YourUsernameHere\nAnd\nKey: user.email\nValue: YourEmailHere"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to leave a GitLab project not owned by me?\n\nIf I had contributed in a project, for which I am not an owner or administrator, how can I get myself out of that project? I do not find the leave button as documented in issue 744.\nhttps://gitlab.com/gitlab-org/gitlab-ce/merge_requests/744\nThe project owner has stopped responding to me and I badly want myself out of it. Please help."
},
{
"role": "assistant",
"content": "Updated answer for 2020:\nLeaving a group automatically removes you from all projects added by that group. \nAt the top menu chose Groups\\Your Groups. Select the group you want to leave and press leave."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "giteveryday - A useful minimum set of commands for Everyday Git CVS-style shared repository."
},
{
"role": "assistant",
"content": "$ grep git /etc/group (1) git:x:9418:alice,bob,cindy,david\n$ cd /home/devo.git\n$ ls -l (2) lrwxrwxrwx 1 david git 17 Dec 4 22:40 HEAD -> refs/heads/master\n drwxrwsr-x 2 david git 4096 Dec 4 22:40 branches\n -rw-rw-r-- 1 david git 84 Dec 4 22:40 config\n -rw-rw-r-- 1 david git 58 Dec 4 22:40 description\n drwxrwsr-x 2 david git 4096 Dec 4 22:40 hooks\n -rw-rw-r-- 1 david git 37504 Dec 4 22:40 index\n drwxrwsr-x 2 david git 4096 Dec 4 22:40 info\n drwxrwsr-x 4 david git 4096 Dec 4 22:40 objects\n drwxrwsr-x 4 david git 4096 Nov 7 14:58 refs\n drwxrwsr-x 2 david git 4096 Dec 4 22:40 remotes\n$ ls -l hooks/update (3) -r-xr-xr-x 1 david git 3536 Dec 4 22:40 update\n$ cat info/allowed-users (4) refs/heads/master\talice\\|cindy\nrefs/heads/doc-update\tbob\nrefs/tags/v[0-9]*\tdavid place the developers into the same git group. and make the shared repository writable by the group. use update-hook example by Carl from Documentation/howto/\nfor branch policy control. alice and cindy can push into master, only bob can push into doc-update.\ndavid is the release manager and is the only person who can\ncreate and push version tags."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to get the last modification date of a file in a git repo?\nI'm trying to find a command to get the last modified date of a file in a local git repo.\nI have created the repo and done one commit. I only had to edit one file and will commit it, but I was wondering what the last modification data of the file in the repo is (not the commit date).\nI only have the command line, and git log ./path/to/filename.php only gives me the commit date"
},
{
"role": "assistant",
"content": "The correct way to do this is to use git log as follows.\ngit log -1 --pretty=\"format:%ci\" /path/to/repo/anyfile.any\n-1 restricts it to the very last time the file changed\n%ci is just one of the date formats you can choose from others here at https://git-scm.com/docs/pretty-formats"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs %<|( <M> )"
},
{
"role": "assistant",
"content": "make the next placeholder take at least until Mth\ndisplay column, padding spaces on the right if necessary.\nUse negative M values for column positions measured\nfrom the right hand edge of the terminal window."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git & Intellij, How do I commit only parts of a changed file\nI can't seem to commit only a fraction of the changes in a file, it seems to be all of the file or nothing, I'm using Git with Intellij, is it possible?\nThanks."
},
{
"role": "assistant",
"content": "Update - 2/2018:\nThe first EAP build for 2018.1 has landed and it's HERE! It is implemented as checkboxes for each hunk, so you can selectively check on them before making the commit. Enjoy!\nUpdate - 12/2017:\nWell 2017.3 was just released and this didn't make it in. So let's hope for 2018.1.\nUpdate - 11/2017:\nThis has been 'in progress' for months now. The 2017.3 EAP releases have been coming out for a while but this issue hasn't been finished yet. With no updates to the issue other than people asking when it will be done, I'm thinking this will slip to the 2018 release.\nUpdate - 2017:\nThis issue has been open for years as noted in some of the comments. But it is now in progress and sheduled to land in 2017.3 which is currently in EAP release and should be available this fall. So now, four years after this was asked, you will soon be able to actually do it right in the IDE."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Setting git default flags on commands\nI want to know if there is a way to set a flag by default for git command. Specifically, I want to set the --abbrev-commit flag so that when executing git log, I want to execute git log --abbrev-commit.\nUnlike the question \"is there any way to set a flag by default for a git command?\", there is apparently not a configuration flag for adding --abbrev-commit to git log. Furthermore, the git manual states that I cannot create an alias: \"To avoid confusion and troubles with script usage, aliases that hide existing git commands are ignored\"\nMy third option is to invent a new alias like glog=log --abbrev-commit in my .gitconfig file. But I'd rather not invent my own DSL with new commands. \nIs there another way to achieve it so that the abbrev-commit flag is set by default??"
},
{
"role": "assistant",
"content": "Since git version 1.7.6, git config has gained a log.abbrevCommit option which can be set to true. Thus the answer is upgrade to at least 1.7.6 (current as of this writing is 1.7.11.4) and use:\ngit config --global log.abbrevCommit true"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-request-pull - Generates a summary of pending changes"
},
{
"role": "assistant",
"content": "DESCRIPTION Generate a request asking your upstream project to pull changes into\ntheir tree. The request, printed to the standard output,\nbegins with the branch description, summarizes\nthe changes, and indicates from where they can be pulled. The upstream project is expected to have the commit named by <start> and the output asks it to integrate the changes you made\nsince that commit, up to the commit named by <end> , by visiting\nthe repository named by <URL> ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-rev-list - Lists commit objects in reverse chronological order --remotes[=<pattern>]"
},
{
"role": "assistant",
"content": "Pretend as if all the refs in refs/remotes are listed\non the command line as <commit> . If <pattern> is given, limit\nremote-tracking branches to ones matching given shell glob.\nIf pattern lacks ? , * , or [ , /* at the end is implied."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-reset - Reset current HEAD to the specified state --pathspec-from-file=<file>"
},
{
"role": "assistant",
"content": "Pathspec is passed in <file> instead of commandline args. If <file> is exactly - then standard input is used. Pathspec\nelements are separated by LF or CR/LF. Pathspec elements can be\nquoted as explained for the configuration variable core.quotePath (see git-config ). See also --pathspec-file-nul and\nglobal --literal-pathspecs ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I disable Git Credential Manager for Windows?\nI notice that in the latest version of Git, the default is now to popup a \"Git Credential Manager for Windows\" dialog instead of prompting me for me password at the Bash prompt every time.\nI really hate this behaviour. How can I just disable it and go back to entering the password at the Bash shell every time?\nBy the way, I don't want Git caching my credentials in any way, whether through Windows credentials or some internal daemon. I want to disable all credential caching."
},
{
"role": "assistant",
"content": "OK, I discovered that you need to either avoid checking the \"Git Credential Manager\" checkbox during the Git for Windows installer, or (after installation) run the Bash shell as Administrator and use git config --edit --system to remove the helper = manager line so that it is no longer registered as a credential helper.\nFor bonus points, use git config --edit --global and insert:\n[core]\n askpass =\n\nTo disable the OpenSSH credentials popup too."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: How can I find a commit that most closely matches a directory?\nSomeone took a version (unknown to me) of Moodle, applied many changes within a directory, and released it (tree here).\nHow can I determine which commit of the original project was most likely edited to form this tree?\nthis would allow me to form a branch at the appropriate commit with this patch. Surely it came from either the 1.8 or 1.9 branches, probably from a release tag, but diffing between particular commits doesn't help me much.\nPostmortem Update: knittl's answer got me as close as I'm going to get. I first added my patch repo as the remote \"foreign\" (no commits in common, that's OK), then did diffs in loops with a couple format options. The first used the --shortstat format:\nfor REV in $(git rev-list v1.9.0^..v1.9.5); do \n git diff --shortstat \"$REV\" f7f7ad53c8839b8ea4e7 -- mod/assignment >> ~/rdiffs.txt; \n echo \"$REV\" >> ~/rdiffs.txt; \ndone;\n\nThe second just counted the line changes in a unified diff with no context:\nfor REV in $(git rev-list v1.9.0^..v1.9.5); do \n git diff -U0 \"$REV\" f7f7ad53c8839b8ea4e7 -- mod/assignment | wc -l >> ~/rdiffs2.txt;\n echo \"$REV\" >> ~/rdiffs2.txt; \ndone;\n\nThere were thousands of commits to dig through, but this one seems to be the closest match."
},
{
"role": "assistant",
"content": "you could write a script, which diffs the given tree against a revision range in your repository.\nassume we first fetch the changed tree (without history) into our own repository:\ngit remote add foreign git://…\ngit fetch foreign\n\nwe then output the diffstat (in short form) for each revision we want to match against:\nfor REV in $(git rev-list 1.8^..1.9); do\n git diff --shortstat foreign/master $REV;\ndone\n\nlook for the commit with the smallest amount of changes (or use some sorting mechanism)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I arrange repositories into folders on Github?\n\nI am new to git and what I am doing now is to upload all my recent projects as repositories to github. There are a lot of different projects like webdesign, wordpress themes and different types of applications. And some of these also belong to bigger projects because they were about testing some stuff as a different application.\nThe problem is that I have a confusing amount of repositories online now. How can I group related github repositories in a folder structure? Is there a feature providing any ability to order and structure or even tag repositories on github?"
},
{
"role": "assistant",
"content": "Update Dec. 2023: it's happening! (kind of)\n\nNew Organization Repositories List Feature Preview (Dec. 2023)\nIn October, we launched the beta of Repository Custom Properties, enabling you to attach key-value pairs to repositories in your organizations.\nAmong many scenarios, one of the key components we had envisioned was the ability to filter your repository properties.\nMaking it easier to find exactly the set of repositories you were looking for.\nStarting today, you can enable a new list view for repositories.\nThis update improves accessibility and performance and introduces a new filter bar supporting properties.\nTo enable select New organization repositories view option in the feature preview dialog.\n\nLearn more about managing customer properties for your organization and managing rulesets for your organization.\nHead over to the community discussions to share your feedback.\n\n\nUpdate Sept. 2023: the same GitHub Community Issue #4174: \"Support repository categories\" adds from the Customer Support:\n\nGuy (GitHub Support)\nSep 15, 2023, 11:04AM UTC\nHi Tom:\nI understand, I've added your comments about the lack of this feature being a blocker for your org to our internal customer feedback tracker.\nRequests for It have been made by some quite large Enterprise orgs since at least 2014, and the Product Managers have never been persuaded to implement It, so I don't think it's likely they will change their minds any time soon, unfortunately.\nCheers,\nGuy\n\nSo no project folder structure for now (2023).\n\nUpdate Dec. 2021:\n\nLists are now available as a public beta \n\n\nLists level up the starring experience by making it easy to organize and curate your favorite repositories on GitHub.\nYou can create public lists that appear on your stars page at https://github.com/USERNAME?tab=stars.\nLists are available to everyone except enterprise managed users.\n\n\nHowever (June 2022), as illustrated by Wyck in GitHub Community Issue #4174: Support repository categories, the presentation is still lacking:\n\nif I click the topic button, it shows me a list of all public repos marked with that same topic keyword.\nInstead, I'd prefer if there was a way to view only repos within my organization marked with that topic.\nI'd also like to see a top-level list of all topic that have been marked on any repos within my private organization, to serve as a top-level directory or table-of-contents of repos in my organization.\n\n\nOriginal answer:\nOn GitHub itself, you cannot group your repos by \"folder\", unless you create organizations.\nSee SublimeText, for instance, as a group of all sublimeText packages repos.\nBut that won't support a nested folder organization. For now (June 2017), that only supports a nested team organization structure.\n\nUpdate Aug. 2020: the README project allows you to add a profile page... in which you can list and organize your repositories any way you want. But that is a manual process (editing the page).\n\nUpdate February 2019: you now have the concept of project:\nSee \"User owned projects—your personal workspace \"\n\nYou can also link up to 5 repositories to your project board. Linking repositories will limit the scope of the search to those linked repositories, so you can quickly narrow down any new issues you haven’t yet added to the project board\n\n\nGitHub also supports tags now (in the form of topics).\n\nOriginal answers 2012:\nAnother solution is for you to define repositories which reference other repos, declared as submodules.\nThat way, when you are cloning one of the repos (which references other repos), called \"parent repos\", they will be cloned in their own directory, with a sub-directory per submodules.\nIt won't be visually apparent on your GitHub account itself (as it will still contains a large list of repos, even larger with the parent repos), but by cloning one parent repo, you will get back all its associated submodules in it.\n\nThe issue 302 mentioned in the comments by AnneTheAgile in 2014 just references now (Nov. 2018) tbnorth/github_repo_tags\n\nThe small python program in this repository uses the GitHub API to get a list of your repos. and add their name, description, and URL, to a new repo., by default called repo_tags. Initially each “issue” is tagged unclassified, but you can tag them as you please, using regular issue tagging.\nWhen re-run, repo_tags.py only creates issues for repos. that weren't already covered by an issue."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Remove tracking branches no longer on remote\nIs there a simple way to delete all tracking branches whose remote equivalent no longer exists?\nExample:\nBranches (local and remote)\n\nmaster\norigin/master\norigin/bug-fix-a\norigin/bug-fix-b\norigin/bug-fix-c\n\nLocally, I only have a master branch. Now I need to work on bug-fix-a, so I check it out, work on it, and push changes to the remote. Next I do the same with bug-fix-b.\nBranches (local and remote)\n\nmaster\nbug-fix-a\nbug-fix-b\norigin/master\norigin/bug-fix-a\norigin/bug-fix-b\norigin/bug-fix-c\n\nNow I have local branches master, bug-fix-a, bug-fix-b. The Master branch maintainer will merge my changes into master and delete all branches he has already merged.\nSo the current state is now:\nBranches (local and remote)\n\nmaster\nbug-fix-a\nbug-fix-b\norigin/master\norigin/bug-fix-c\n\nNow I would like to call some command to delete branches (in this case bug-fix-a, bug-fix-b), which are no longer represented in the remote repository.\nIt would be something like the existing command git remote prune origin, but more like git local prune origin."
},
{
"role": "assistant",
"content": "git remote prune origin prunes tracking branches not on the remote.\ngit branch --merged lists branches that have been merged into the current branch.\nxargs git branch -d deletes branches listed on standard input.\nBe careful deleting branches listed by git branch --merged. The list could include master or other branches you'd prefer not to delete.\nTo give yourself the opportunity to edit the list before deleting branches, you could do the following in one line:\ngit branch --merged >/tmp/merged-branches && \\\n vi /tmp/merged-branches && xargs git branch -d </tmp/merged-branches"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Alter repository directory structure using sparse checkout\nWith the new sparse checkout feature in Git 1.7.0, is it possible to just get the contents of a subdirectory like how you can in SVN? I found this example, but it preserves the full directory structure. Imagine that I just wanted the contents of the 'perl' directory, without an actual directory named 'perl'.\n-- EDIT --\nExample:\nMy git repository contains the following paths\nrepo/.git/\nrepo/perl/\nrepo/perl/script1.pl\nrepo/perl/script2.pl\nrepo/images/\nrepo/images/image1.jpg\nrepo/images/image2.jpg\nrepo/doc/\nrepo/doc/readme.txt\nrepo/doc/help.txt\n\nWhat I want is to be able to produce from the above repository this layout:\nrepo/.git/\nrepo/script1.pl\nrepo/script2.pl\n\nHowever with the current sparse checkout feature, it seems like it is only possible to get\nrepo/.git/\nrepo/perl/script1.pl\nrepo/perl/script2.pl\n\nwhich is NOT what I want."
},
{
"role": "assistant",
"content": "You still need to clone the whole repository, which will have all the files. You could use the --depth flag to only retrieve a limited amount of history.\nOnce the repository is cloned, the read-tree trick limits your \"view\" of the repository to only those files or directories that are in the .git/info/sparse-checkout file.\nI wrote a quick script to help manage the sparseness, since at the moment it is a bit unfriendly:\n#!/bin/sh\necho > .git/info/sparse-checkout\nfor i in \"$@\"\ndo\n echo \"$i\" >> .git/info/sparse-checkout\ndone\ngit read-tree -m -u HEAD\n\nIf you save this script as git-sparse.sh into the path reported by calling git --exec-path, then you can run git sparse foo/ bar/ to only \"checkout\" the foo and bar directories, or git sparse '*' to get everything back again."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-revert - Revert some existing commits revert.reference"
},
{
"role": "assistant",
"content": "Setting this variable to true makes git revert behave\nas if the --reference option is given."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Getting the difference between two repositories\nHow can we get the difference between two git repositories?\nThe scenario:\nWe have a repo_a and repo_b. The latter was created as a copy of repo_a. There have been parallel development in both the repositories afterwards. Is there a way we can list the differences of the current versions of these two repositories?"
},
{
"role": "assistant",
"content": "In repo_a:\ngit remote add -f b path/to/repo_b.git\ngit remote update\ngit diff master remotes/b/master\ngit remote rm b"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options skippedCherryPicks"
},
{
"role": "assistant",
"content": "Shown when git-rebase skips a commit that has already\nbeen cherry-picked onto the upstream branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "GitLab: Editing the merge request description triggers a merge request hook being sent\n\nFor my repository on GitLab I have a Merge Request Hook configured which triggers a build on a Jenkins CI machine. The hooks works as expected when a merge request is opened.\nThe webhook is configured with the following triggers:\n\nURL: https://example.com/project/ExampleApp_merge_requests\nPush events: Enabled\nMerge request events: Enabled\nEnable SSL verification: Off\n\nLately, when I edit the description of the merge requests then the hook also notifies the CI machine.\nHere is an example POST request:\nRequest headers:\nContent-Type: application/json\nX-Gitlab-Event: Merge Request Hook\n\nRequest body:\n{\n \"object_kind\": \"merge_request\",\n \"event_type\": \"merge_request\",\n \"user\": {\n \"name\": \"User Name\",\n \"username\": \"username\",\n \"avatar_url\": \"https://gitlab.example.com/uploads/-/system/user/avatar/145/avatar.png\"\n },\n \"project\": {\n \"id\": 39,\n \"name\": \"app\",\n \"description\": \"Lorem ipsum.\",\n \"web_url\": \"https://gitlab.example.com/projects/app\",\n \"avatar_url\": \"https://gitlab.example.com/uploads/-/system/project/avatar/39/app.png\",\n \"git_ssh_url\": \"[email protected]:projects/app.git\",\n \"git_http_url\": \"https://gitlab.example.com/projects/app.git\",\n \"namespace\": \"projects\",\n \"visibility_level\": 0,\n \"path_with_namespace\": \"projects/app\",\n \"default_branch\": \"develop\",\n \"ci_config_path\": null,\n \"homepage\": \"https://gitlab.example.com/projects/app\",\n \"url\": \"[email protected]:projects/app.git\",\n \"ssh_url\": \"[email protected]:projects/app.git\",\n \"http_url\": \"https://gitlab.example.com/projects/app.git\"\n },\n \"object_attributes\": {\n \"assignee_id\": null,\n \"author_id\": 5,\n \"created_at\": \"2019-03-19 16:42:28 UTC\",\n \"description\": \"- s. https://fabric.io/development/projects/apps/com.example.app/issues/5974e5ffbe077a4dcc044254?time=last-thirty-days\\r\\n- Lorem ipsum.\",\n \"head_pipeline_id\": 7473,\n \"id\": 9258,\n \"iid\": 844,\n \"last_edited_at\": \"2019-03-20 09:00:21 UTC\",\n \"last_edited_by_id\": 145,\n \"merge_commit_sha\": null,\n \"merge_error\": null,\n \"merge_params\": {\n \"force_remove_source_branch\": \"1\"\n },\n \"merge_status\": \"can_be_merged\",\n \"merge_user_id\": null,\n \"merge_when_pipeline_succeeds\": false,\n \"milestone_id\": null,\n \"source_branch\": \"fix/random\",\n \"source_project_id\": 39,\n \"state\": \"opened\",\n \"target_branch\": \"develop\",\n \"target_project_id\": 39,\n \"time_estimate\": 0,\n \"title\": \"Fix random\",\n \"updated_at\": \"2019-03-20 09:00:21 UTC\",\n \"updated_by_id\": 145,\n \"url\": \"https://gitlab.example.com/projects/app/merge_requests/844\",\n \"source\": {\n \"id\": 39,\n \"name\": \"app\",\n \"description\": \"Lorem ipsum.\",\n \"web_url\": \"https://gitlab.example.com/projects/app\",\n \"avatar_url\": \"https://gitlab.example.com/uploads/-/system/project/avatar/39/app.png\",\n \"git_ssh_url\": \"[email protected]:projects/app.git\",\n \"git_http_url\": \"https://gitlab.example.com/projects/app.git\",\n \"namespace\": \"projects\",\n \"visibility_level\": 0,\n \"path_with_namespace\": \"projects/app\",\n \"default_branch\": \"develop\",\n \"ci_config_path\": null,\n \"homepage\": \"https://gitlab.example.com/projects/app\",\n \"url\": \"[email protected]:projects/app.git\",\n \"ssh_url\": \"[email protected]:projects/app.git\",\n \"http_url\": \"https://gitlab.example.com/projects/app.git\"\n },\n \"target\": {\n \"id\": 39,\n \"name\": \"app\",\n \"description\": \"Lorem ipsum.\",\n \"web_url\": \"https://gitlab.example.com/projects/app\",\n \"avatar_url\": \"https://gitlab.example.com/uploads/-/system/project/avatar/39/app.png\",\n \"git_ssh_url\": \"[email protected]:projects/app.git\",\n \"git_http_url\": \"https://gitlab.example.com/projects/app.git\",\n \"namespace\": \"projects\",\n \"visibility_level\": 0,\n \"path_with_namespace\": \"projects/app\",\n \"default_branch\": \"develop\",\n \"ci_config_path\": null,\n \"homepage\": \"https://gitlab.example.com/projects/app\",\n \"url\": \"[email protected]:projects/app.git\",\n \"ssh_url\": \"[email protected]:projects/app.git\",\n \"http_url\": \"https://gitlab.example.com/projects/app.git\"\n },\n \"last_commit\": {\n \"id\": \"cdda6f7d200468955ecbd224f0437932db607087\",\n \"message\": \"Fix random\\n\\n\",\n \"timestamp\": \"2019-03-20T08:45:40Z\",\n \"url\": \"https://gitlab.example.com/projects/app/commit/cdda6f7d200468955ecbd224f0437932db607087\",\n \"author\": {\n \"name\": \"User Name\",\n \"email\": \"username\"\n }\n },\n \"work_in_progress\": false,\n \"total_time_spent\": 0,\n \"human_total_time_spent\": null,\n \"human_time_estimate\": null,\n \"action\": \"update\"\n },\n \"labels\": [\n {\n \"id\": 22,\n \"title\": \"Bug fix\",\n \"color\": \"#FF0000\",\n \"project_id\": null,\n \"created_at\": \"2018-10-19 09:55:26 UTC\",\n \"updated_at\": \"2018-11-05 15:17:08 UTC\",\n \"template\": false,\n \"description\": \"\",\n \"type\": \"GroupLabel\",\n \"group_id\": 15\n }\n ],\n \"changes\": {\n \"description\": {\n \"previous\": \"s. https://fabric.io/development/projects/apps/com.example.app/issues/5974e5ffbe077a4dcc044254?time=last-thirty-days\\r\\nLorem ipsum.\",\n \"current\": \"- s. https://fabric.io/development/projects/apps/com.example.app/issues/5974e5ffbe077a4dcc044254?time=last-thirty-days\\r\\n- Lorem ipsum.\"\n },\n \"last_edited_at\": {\n \"previous\": \"2019-03-19 16:42:50 UTC\",\n \"current\": \"2019-03-20 09:00:21 UTC\"\n },\n \"last_edited_by_id\": {\n \"previous\": 5,\n \"current\": 145\n },\n \"updated_at\": {\n \"previous\": \"2019-03-20 08:52:38 UTC\",\n \"current\": \"2019-03-20 09:00:21 UTC\"\n },\n \"updated_by_id\": {\n \"previous\": 5,\n \"current\": 145\n }\n },\n \"repository\": {\n \"name\": \"app\",\n \"url\": \"[email protected]:projects/app.git\",\n \"description\": \"Lorem ipsum.\",\n \"homepage\": \"https://gitlab.example.com/projects/app\"\n }\n}\n\nResponse headers:\nServer: nginx/1.10.3 (Ubuntu)\nDate: Wed, 20 Mar 2019 09:00:21 GMT\nTransfer-Encoding: chunked\nConnection: close\nX-Content-Type-Options: nosniff\n\nThe Jenkins plugin looks like this:\n\nOn the Jenkins machine the following GitLab plugins are installed:\n\n\nJenkins GitLab OAuth Plugin\nJenkins GitLab Hook Plugin\nJenkins GitLab Logo Plugin\nGitLab Merge Request Builder Plugin\nGitLab Plugin\n\nHow can I configure that a POST request is only sent to the CI machine when I create or update the branch of the pull request?"
},
{
"role": "assistant",
"content": "Under triggers (Settings -> integrations) perform the below:\n\nEnable push events (optional branch name - Branch is created via push events even before MR is possible)\nEnable MR event triggers in your project repo \n\n\nThis URL will be triggered when a merge request is created/updated/merged\n\n\nIn Jenkins Plugin configuration - \n\nCheck \"Push Events\" (Any commits by way of direct Push or Creation)\nUn-check \"Opened Merge Request Events\"\nCheck \"Accepted Merge Request Events\" (Any commits by way of Merge Request)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-reset - Reset current HEAD to the specified state --keep"
},
{
"role": "assistant",
"content": "Resets index entries and updates files in the working tree that are\ndifferent between <commit> and HEAD .\nIf a file that is different between <commit> and HEAD has local\nchanges, reset is aborted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "push --force-with-lease by default\nI just learned about git push --force-with-lease. It's pretty awesome. But, of course, I don't use force that often, and so I'm worried that I might forget about this nifty feature the next time I need it.\nIs there a way to configure git so git push -f will automatically use --force-with-lease unless I intentionally override it with --no-force-with-lease?\n(I can't imagine ever wanting to use force without lease!)"
},
{
"role": "assistant",
"content": "There currently is no way to configure git to always use force-with-lease instead of force. As such the next best available option is, as so often, to create an alias which serves this purpose.\nEDIT This is still true in May 2022. But git 2.30 added an additional option force-if-includes which makes force-with-lease even safer; checkout this in-depth answer if you want to understand the reasoning.\nCreate an alias\nTo create an alias one would use git config --global alias.<alias-name> <command>, in our case I would suggest something similar to this.\ngit config --global alias.pushfwl \"push --force-with-lease\"\n\nThis will create an entry in your global .gitconfig file (which you can usually find in your home directory). After this you can use git pushfwl to force-with-lease.\nGet your hands dirty\nAlternatively you could decide to implement this feature yourself! If you aren't sure where to start, you might want to take a look at the documentation directory in the git repository. Here you can find the coding guidelines and information on how to submit patches.\nYou can find all these links and more on the official community page."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-tag - Create, list, delete or verify a tag object signed with GPG RFC 2822"
},
{
"role": "assistant",
"content": "The standard date format as described by RFC 2822, for example Thu, 07 Apr 2005 22:13:13 +0200 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "'git diff' between a remote and local repository\n\nI am trying to diff my local file with a GitHub repository before I submit a pull request, so I can see what will show up. Is there an accurate way of doing this?\nI assume GitHub's compare tool manipulates Git's diff."
},
{
"role": "assistant",
"content": "To compare a local working directory against a remote branch, for example origin/master:\n\ngit fetch origin master\nThis tells git to fetch the branch named 'master' from the remote named 'origin'. git fetch will not affect the files in your working directory; it does not try to merge changes like git pull does. \ngit diff --summary FETCH_HEAD\nWhen the remote branch is fetched, it can be referenced locally via FETCH_HEAD. The command above tells git to diff the working directory files against FETCHed branch's HEAD and report the results in summary format. Summary format gives an overview of the changes, usually a good way to start. If you want a bit more info, use --stat instead of --summary. \ngit diff FETCH_HEAD -- mydir/myfile.js\nIf you want to see changes to a specific file, for example myfile.js, skip the --summary option and reference the file you want (or tree).\n\nAs noted, origin references the remote repository and master references the branch within that repo. By default, git uses the name origin for a remote, so if you do git clone <url> it will by default call that remote origin. Use git remote -v to see what origin points to.\nYou may have more than one remote. For example, if you \"fork\" a project on GitHub, you typically need a remote referencing the original project as well as your own fork. Say you create https://github.com/yourusername/someproject as a fork of https://github.com/theoriginal/someproject. By convention, you would name the remote to the original repo upstream, while your own fork would be origin. If you make changes to your fork on GitHub and want to fetch those changes locally, you would use git fetch origin master. If the upstream has made changes that you need to sync locally before making more changes, you would use git fetch upstream master."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options imap.host"
},
{
"role": "assistant",
"content": "A URL identifying the server. Use an imap:// prefix for non-secure\nconnections and an imaps:// prefix for secure connections.\nIgnored when imap.tunnel is set, but required otherwise."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "how to delete all commit history in github? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nMake the current commit the only (initial) commit in a Git repository?\n\n (19 answers)\n \n\nClosed 8 years ago.\n\n\n\nI want to delete all commit history but keep the code in its current state because, in my commit history, there are too many unused commits.\nHow can I do it?\nIs there any git command can do this?\ngit filter-branch ?\ngit rebase ?\n... \n\nMy code is hosted on github.com."
},
{
"role": "assistant",
"content": "Deleting the .git folder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:\n\nCheckout/create orphan branch (this branch won't show in git branch command):\ngit checkout --orphan latest_branch\n\n\nAdd all the files to the newly created branch:\ngit add -A\n\n\nCommit the changes:\ngit commit -am \"commit message\"\n\n\nDelete main (default) branch (this step is permanent):\ngit branch -D main\n\n\nRename the current branch to main:\ngit branch -m main\n\n\nFinally, all changes are completed on your local repository, and force update your remote repository:\ngit push -f origin main\n\n\n\nPS: This will not keep your old commit history around. Now you should only see your new commit in the history of your git repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Attempting push on git and receiving \"could not read Username for 'https://github.com': terminal prompts disabled\"\nI'm using Visual Studio, and the GitHub Extension. I am able to sign in, then clone my team's repository, and then pull changes successfully.\nWhen it comes time to push my changes back to remote, I get a blank command prompt appear on the screen briefly, and then the following errors in the output window:\n\nError encountered while pushing to the remote repository: Git failed with a fatal error. \nfatal: AggregateException encountered. One or more errors occurred. \nerror: cannot spawn askpass: No such file or directory \nfatal: could not read Username for 'https://github.com': terminal prompts disabled\n\nEDIT: pushing via the command line works, as does pushing via the GitHub desktop application, just not within this extension.\nAny ideas why this might be happening? I can't see why it needs the Username given that I have signed into the extension."
},
{
"role": "assistant",
"content": "As per my comment. You can include your username in the remote URL (similar to FTP).\nExample without password (SSH):\ngit remote set-url origin [email protected]/username/repo.git\nExample with password (https)\nhttps://name:[email protected]/username/repo.git\nSource: Git push requires username and password\nUpdated 5/14/2018 to correct github.org to github.com in the original answer"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Is there a way to just commit one file type extension from a folder?\nI have a folder with a lot of stuff and I would like just to commit \".c\" extension files. Is there a command to do this or do I need to add each file name manually?"
},
{
"role": "assistant",
"content": "For me, just git add *.c didn't work. I encountered fatal error like this:\ngit add *.php\nThe following paths are ignored by one of your .gitignore files:\nwp-config.php\nUse -f if you really want to add them.\nfatal: no files added\n\nSo, in this variant git tried to add ignored files.\nBut such variant:\ngit add \\*.php\n\nworked flawlessly.\nBy the way, you can do git diff the same way:\ngit diff -- \\*.php"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --tags[=<pattern>]"
},
{
"role": "assistant",
"content": "Pretend as if all the refs in refs/tags are listed\non the command line as <commit> . If <pattern> is given, limit\ntags to ones matching given shell glob. If pattern lacks ? , * ,\nor [ , /* at the end is implied."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Trying to understand wincred with git for windows - confused\nWhile following a git tutorial, I've made my first push over https today to a remote on git hub, the tutorial mentions the following command to avoid having to keep typing in password details:\ngit config --global credential.helper wincred\n\nMy question is how is this working as a concept? it is the first time I have come across a credential helper. I'm not sure how it works with Windows and Git, where is it being stored and how does it authenticate when I push or pull?\nI've tried to search for this online but haven't found any information that explains this in a simple way for someone who is a beginner."
},
{
"role": "assistant",
"content": "If you use wincred for credential.helper, git is using the standard windows Credential Manager to store your credentials.\nYou can view the Credential Manager from your Control Panel settings."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git push takes forever\nWhen I am trying to push to my remote git repository, but it is taking forever and nothing happens. I waited for so long, but push is never getting finished. My OS is Ubuntu 12.10. Thank you."
},
{
"role": "assistant",
"content": "Try using the --verbose option to see what actually happens. Even if you did small changes, some internal things might cause git to push a lot more data. \nHave a look at git gc. It cleans up your local repository and might speed up things, depending on you issue. Backup strongly advised."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker --literal-pathspecs"
},
{
"role": "assistant",
"content": "Treat pathspecs literally (i.e. no globbing, no pathspec magic).\nThis is equivalent to setting the GIT_LITERAL_PATHSPECS environment\nvariable to 1 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gittutorial"
},
{
"role": "assistant",
"content": "A tutorial introduction to Git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git: Clone from a branch other than master\n\nI am trying to pull from a repository in Github. But I don't want to clone the master branch. I want to clone some other branch. When I try git clone <url>, I get the files from the master branch. What should I do?\nAlso, suppose the code is updated in the repository and I want to get the latest code, should I again use git clone ? Because the size of the project is huge. Also if I make changes to the project locally, and then I again use git clone, will the changes I made still be there? What if I don't want changes to be there?\nI am not even sure if git clone is the right command. git pull or git fetch?\nI am sorry, I am very new to git."
},
{
"role": "assistant",
"content": "Try this:\ngit init\ngit fetch url-to-repo branchname:refs/remotes/origin/branchname\n\nEDIT\nA better solution:\ngit clone -b mybranch --single-branch git://sub.domain.com/repo.git"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_MERGE_VERBOSITY"
},
{
"role": "assistant",
"content": "A number controlling the amount of output shown by\nthe recursive merge strategy. Overrides merge.verbosity.\nSee git-merge"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to resolve git's \"not something we can merge\" error\nI just encountered a problem when merging a branch into master in git. First, I got the branch name by running git ls-remote. Let's call that branch \"branch-name\". I then ran git merge branch-name command and got the following result:\nfatal: branch-name - not something we can merge\n\nHow do I resolve this error?"
},
{
"role": "assistant",
"content": "As shown in How does \"not something we can merge\" arise?, this error can arise from a typo in the branch name because you are trying to pull a branch that doesn't exist.\nIf that is not the problem (as in my case), it is likely that you don't have a local copy of the branch that you want to merge. Git requires local knowledge of both branches in order to merge those branches. You can resolve this by checking out the branch to merge and then going back to the branch you want to merge into.\ngit checkout branch-name\ngit checkout master\ngit merge branch-name\n\nThis should work, but if you receive an error saying\nerror: pathspec 'remote-name/branch-name' did not match any file(s) known to git.\n\nyou need to fetch the remote (probably, but not necessarily, \"origin\") before checking out the branch:\ngit fetch remote-name"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to set up a git project to use an external repo submodule?\n\nI'd like to create a repo which pulls in a remote repo.\nFor example, let's say jQuery as a submodule:\ngit://github.com/jquery/jquery.git\n\nWhat would be the process of creating a repo with jQuery as a submodule and adding my own external as a remote repo.\nAlso once this is setup, if I push / pull to my own remote, will the external remain intact?"
},
{
"role": "assistant",
"content": "You have a project -- call it MyWebApp that already has a github repo\nYou want to use the jquery repository in your project\nYou want to pull the jquery repo into your project as a submodule.\n\nSubmodules are really, really easy to reference and use. Assuming you already have MyWebApp set up as a repo, from terminal issue these commands:\ncd MyWebApp\ngit submodule add git://github.com/jquery/jquery.git externals/jquery\n\nThis will create a directory named externals/jquery* and link it to the github jquery repository. Now we just need to init the submodule and clone the code to it: \ngit submodule update --init --recursive\n\nYou should now have all the latest code cloned into the submodule. If the jquery repo changes and you want to pull the latest code down, just issue the submodule update command again. Please note: I typically have a number of external repositories in my projects, so I always group the repos under an \"externals\" directory.\nThe online Pro Git Book has some good information on submodules (and git in general) presented in an easy-to-read fashion. Alternately, git help submodule will also give good information. Or take a look at the Git Submodule Tutorial on the git wiki.\nI noticed this blog entry which talks about submodules and compares them to Subversion's svn:externals mechanism: http://speirs.org/blog/2009/5/11/understanding-git-submodules.html \n* As a best practice, you should always place your submodules in their own directory, such as Externals. If you don't, your root project directory can become very cluttered very fast."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-mergetool - Run merge conflict resolution tools to resolve merge conflicts mergetool.<tool>.trustExitCode"
},
{
"role": "assistant",
"content": "For a custom merge command, specify whether the exit code of\nthe merge command can be used to determine whether the merge was\nsuccessful. If this is not set to true then the merge target file\ntimestamp is checked, and the merge is assumed to have been successful\nif the file has been updated; otherwise, the user is prompted to\nindicate the success of the merge."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-format-patch - Prepare patches for e-mail submission --notes[=<ref>] --no-notes"
},
{
"role": "assistant",
"content": "Append the notes (see git-notes ) for the commit\nafter the three-dash line. The expected use case of this is to write supporting explanation for\nthe commit that does not belong to the commit log message proper,\nand include it with the patch submission. While one can simply write\nthese explanations after format-patch has run but before sending,\nkeeping them as Git notes allows them to be maintained between versions\nof the patch series (but see the discussion of the notes.rewrite configuration options in git-notes to use this workflow). The default is --no-notes , unless the format.notes configuration is\nset."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-reset"
},
{
"role": "assistant",
"content": "Reset current HEAD to the specified state"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Git pushing to remote GitHub repository as wrong user\n\nI have a work GitHub account and a personal one. First I used the personal one for test projects, then I moved on and did a repository with the other account on the same computer.\nNow I wanted to create a new repository on my personal account again, I changed the global and local user.name, and did a new ssh key pair, entered in the GitHub setup page. Then I set up the directory\ngit init\ngit remote add origin <url>\ngit push origin\n\nbut that now tells me\n\nERROR: Permission to personaluser/newrepo.git denied to \n\nI have no idea how the other account is connected to this one. .git/config shows no workusername related things.\nIf you're using Windows 10 take your time to read the Rajan's answer."
},
{
"role": "assistant",
"content": "this sounds very similar to my current work set up. it seems that you already have set up your separate ssh-keys so you also need to create a ~/.ssh/config file and populate it with information similar to this:\nHost work.github.com\n HostName github.com\n User WORK_GITHUB_USERNAME\n PreferredAuthentications publickey\n IdentityFile ~/.ssh/id_work_rsa\n IdentitiesOnly yes\n\nHost personal.github.com\n HostName github.com\n User PERSONAL_GITHUB_USERNAME \n PreferredAuthentications publickey\n IdentityFile ~/.ssh/id_personal_rsa\n IdentitiesOnly yes\n\nEvery property sounds pretty self explanatory but the IdentitiesOnly one. I won't try to explain what that is for, but that is in my current setup and works fine.\nIt's also worth noting that the Host URL is just a pointer to grab the correct user settings and does not have any affect on getting the files correctly to your target HostName url.\nNow you just need to make sure your origin (or any remote in general) url match the correct Host url in your respective repos depending on your user name. If you already have existing personal repos, you can edit that repo's .git/config file in your text editor:\n[remote \"origin\"]\n fetch = +refs/heads/*:refs/remotes/origin/*\n url = [email protected]:PERSONAL_GITHUB_USERNAME/project.git\n\nor do it via command line:\ngit remote set-url origin [email protected]:PERSONAL_GITHUB_USERNAME/project.git\n\nLikewise to your work one:\n[remote \"origin\"]\n fetch = +refs/heads/*:refs/remotes/origin/*\n url = [email protected]:your_work_organization/project.git\n\nor again, via command line:\ngit remote set-url origin [email protected]:your_work_organization/project.git\n\nOf course, you can always set one of your Host urls in your ~/.ssh/config file as just\nHost github.com\n\nI only used work.github.com to see the config relationships easier.\nOnce these are all set, you should be able to push to each respective remote.\nEDIT\nOne thing to note that I just found out myself is that if you ever set global git config values for your user.email value (and i'm guessing user.name would send a different value as well), git will show your commits as that email user. To get around this, you can override the global git config settings within your local repository:\n$ git config user.name \"John Doe\"\n$ git config user.email [email protected]\n\nThis should now send up commits as the correct user for that repo."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --find-copies-harder"
},
{
"role": "assistant",
"content": "For performance reasons, by default, -C option finds copies only\nif the original file of the copy was modified in the same\nchangeset. This flag makes the command\ninspect unmodified files as candidates for the source of\ncopy. This is a very expensive operation for large\nprojects, so use it with caution. Giving more than one -C option has the same effect."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Why is the meaning of “ours” and “theirs” reversed with git-svn\nI use git-svn and I noticed that when I have to fix a merge conflict after performing a git svn rebase, the meaning of the --ours and --theirs options to e.g. git checkout is reversed. That is, if there's a conflict and I want to keep the version that came from the SVN server and throw away the changes I made locally, I have to use ours, when I would expect it to be theirs.\nWhy is that?\nExample:\nmkdir test\ncd test\nsvnadmin create svnrepo\nsvn co file://$PWD/svnrepo svnwc\ncd svnwc\necho foo > test.txt\nsvn add test.txt\nsvn ci -m 'svn commit 1'\ncd ..\ngit svn clone file://$PWD/svnrepo gitwc\ncd svnwc\necho bar > test.txt \nsvn ci -m 'svn commit 2'\ncd ..\ncd gitwc\necho baz > test.txt \ngit commit -a -m 'git commit 1'\ngit svn rebase\n\ngit checkout --ours test.txt\ncat test.txt \n# shows \"bar\" but I expect \"baz\"\n\ngit checkout --theirs test.txt\ncat test.txt \n# shows \"baz\" but I expect \"bar\""
},
{
"role": "assistant",
"content": "That seems consistent with what a rebase does.\n\ngit svn rebase will fetch revisions from the SVN parent of the current HEAD and rebases the current (uncommitted to SVN) work against it.\n\ngit rebase does mention:\nNote that a rebase merge works by replaying each commit from the working branch on top of the <upstream> branch.\nBecause of this, when a merge conflict happens:\n\nthe side reported as ours is the so-far rebased series, starting with <upstream>,\nand theirs is the working branch.\nIn other words, the sides are swapped.\n\n\n\n\ngit rebase replays each commit from the working branch on top of the <upstream> branch.\n\nIf you reconcile both definitions:\n\nthe commits coming from SVN are the ones on top of which local Git commits are replayed. They are part of the \"so-far rebased series\", and are referenced as \"our\" (in your case, the test.txt file with bar content)\nthe working branch (containing Git commits unknown to SVN, in your case, the test.txt file with baz content) is \"their\", and each of those local Git commits are being replayed.\n\nIn other words, SVN or not:\n\nthe \"<upstream>\" branch (on top of which anything is replayed, and which is part of the so far \"rebased commits\") is \"ours\".\nwhat is being replayed (the working branch) is \"theirs\".\n\n\nGood mnemonic tip by CommaToast:\n\nwhatever HEAD's pointing to is \"ours\"\n\n(and the first thing a git rebase upstream does is to check out the upstream branch on top of which you want to rebase: HEAD refers to upstream -- ours now.)\nThis does not contradict:\n\nthis answer, where a git checkout --ours codefile.js selects a file from master during a git rebase master\nthis answer, where master, the upstream branch you are rebasing onto, is referenced as \"ours\"\n\n\nThe confusion is likely coming from the role of the working branch in a classic git merge.\nWhen you are merging:\n\nthe \"working branch\" is the one containing what is \"so far merged\", and is considered as \"our\",\nwhile the other commit represent what is being -- not replayed but -- merge on top of the working branch, and considered as \"their\".\n\nAs the git rebase man page mentions, a merge during a rebase means the side are swapped.\n\nAnother way to say the same thing is to consider that:\n\nwhat we have on the checked out branch is 'ours',\nwhat we had (and is being merged or replayed) is 'theirs'.\n\n\nOn a merge:\nx--x--x--x--x(*) <- current branch B ('*'=HEAD)\n \\\n \\\n \\--y--y--y <- other branch to merge\n\n, we don't change the current branch 'B', so what we have is still what we were working on (and we merge from another branch)\nx--x--x--x--x---------o(*) MERGE, still on branch B\n \\ ^ /\n \\ ours /\n \\ /\n --y--y--y--/ \n ^\n their\n\n\nBut on a rebase, we switch side (as in git switch, mentioned in git rebase man page) because the first thing a rebase does is to check out the upstream branch! (to replay the current commits on top of it)\nx--x--x--x--x(*) <- current branch B\n \\\n \\\n \\--y--y--y <- upstream branch\n\nA git rebase upstream will first change HEAD of B to the upstream branch HEAD (hence the switch of 'ours' and 'theirs' compared to the previous \"current\" working branch.)\nx--x--x--x--x <- former \"current\" branch, new \"theirs\"\n \\\n \\\n \\--y--y--y(*) <- upstream branch with B reset on it, \n new \"ours\", to replay x's on it\n\n, and then the rebase will replay 'their' commits on the new 'our' B branch:\nx--x..x..x..x <- old \"theirs\" commits, now \"ghosts\", available through reflogs\n \\\n \\\n \\--y--y--y--x'--x'--x'(*) <- branch B with HEAD updated (\"ours\")\n ^\n |\n upstream branch\n\n\nThe only extra step with git svn rebase is that a svn \"fetch\" is performed first on the Git remote branch representing SVN commits.\nYou have initially:\nx--x--x--x--x(*) <- current branch B, \"ours\" for now.\n \\ \n \\\n \\--y--y--y <- SVN tracking branch, \"theirs for now\"\n\n, you first update the SVN tracking branch with new commits coming from SVN\nx--x--x--x--x(*) <- current branch B, still \"ours\", not for long\n \\ \n \\\n \\--y--y--y--y'--y' <- SVN tracking branch updated\n\n, then you switch the current branch to the SVN side (which becomes \"ours\")\nx--x--x--x--x <- for \"B\", now \"their\" during the rebase\n \\ \n \\\n \\--y--y--y--y'--y'(*) <- SVN tracking branch updated, and branch B: \n now \"ours\" (this is \"what we now have\")\n\n, before replaying the commits you were working on (but which are now \"theirs\" during that rebase)\nx--x..x..x..x <- old \"theirs\" commits, now \"ghosts\", available through reflogs\n \\\n \\\n \\--y--y--y--y'--y'--x'--x'--x'(*) <- branch B with HEAD updated (\"ours\")\n ^\n |\n upstream SVN tracking branch"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Heroku: \"No default language could be detected for this app\" error thrown for node app\nI am learning NodeJS and the course I'm following has several projects, arranged by sections. I have all the projects under one main folder, which is also a git repository.\nEach of these subfolders in the main folder is a node project by itself, complete with package.json and related dependencies in node_modules. The problem is when I tried to push the node app in one such folder(todo-api) to heroku, I get the following error - \nremote: Compressing source files... done.\nremote: Building source:\nremote: \nremote: ! No default language could be detected for this app.\nremote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.\nremote: See https://devcenter.heroku.com/articles/buildpacks\nremote: \nremote: ! Push failed\nremote: Verifying deploy...\nremote: \nremote: ! Push rejected to agile-forest-32749.\nremote: \nTo https://git.heroku.com/agile-forest-32749.git\n ! [remote rejected] master -> master (pre-receive hook declined)\nerror: failed to push some refs to 'https://git.heroku.com/agile-forest-32749.git'\n\nThis is the directory structure for the project - \n\nI decided to refactor out the todo-api subfolder into a new project all by itself, and this time the push to Heroku works just fine - \n\nI don't understand why I get the \"no default language\" error, especially when the node app is exactly the same in both places. Any thoughts?"
},
{
"role": "assistant",
"content": "Heroku has a set of default buildpacks, used when it needs to detect the language of your app.\nIn order to do that detection, it runs the bin/detect command of each of those default buildpacks, until one of them returns a 0 exit code.\nThis is the command for the node buildpack.\nAs you can see, it requires a package.json to be located at the root of your app, not in a subfolder.\nThis is the difference causing your build to fail. You need to put your app at the root of your git repository."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker -C <path>"
},
{
"role": "assistant",
"content": "Run as if git was started in <path> instead of the current working\ndirectory. When multiple -C options are given, each subsequent\nnon-absolute -C <path> is interpreted relative to the preceding -C\n<path> . If <path> is present but empty, e.g. -C \"\" , then the\ncurrent working directory is left unchanged. This option affects options that expect path name like --git-dir and --work-tree in that their interpretations of the path names would be\nmade relative to the working directory caused by the -C option. For\nexample the following invocations are equivalent: git --git-dir=a.git --work-tree=b -C c status\ngit --git-dir=c/a.git --work-tree=c/b status"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Undo git update-index --assume-unchanged <file>\nI have run the following command to ignore watching/tracking a particular directory/file:\ngit update-index --assume-unchanged <file>\n\nHow can I undo this, so that <file> is watched/tracked again?"
},
{
"role": "assistant",
"content": "To get undo/show dir's/files that are set to assume-unchanged run this:\ngit update-index --no-assume-unchanged <file>\n\nTo get a list of dir's/files that are assume-unchanged run this in a unix shell:\ngit ls-files -v | grep '^h'\n\nor in a PowerShell:\ngit ls-files -v | Select-String -CaseSensitive '^h'"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I merge my local uncommitted changes into another Git branch?\nHow can I do the following in Git?\nMy current branch is branch1 and I have made some local changes. However, I now realize that I actually meant to be applying these changes to branch2. Is there a way to apply/merge these changes so that they become local changes on branch2 without committing them on branch1?"
},
{
"role": "assistant",
"content": "Since your files are not yet committed in branch1:\ngit stash\ngit checkout branch2\ngit stash pop\n\nor\ngit stash\ngit checkout branch2\ngit stash list # to check the various stash made in different branch\ngit stash apply x # to select the right one\n\nAbove is the longer more explicit version of rbento's answer:\ngit stash\ngit stash branch branch2\n\nIt uses:\n\ngit stash branch <branchname> [<stash>] \n\nCreates and checks out a new branch named <branchname> starting from the commit at which the <stash> was originally created,\napplies the changes recorded in <stash> to the new working tree and index.\n\nIf that succeeds, and <stash> is a reference of the form stash@{<revision>}, it then drops the <stash>.\nThis is useful if the branch on which you ran git stash push has changed enough that git stash apply fails due to conflicts.\nSince the stash entry is applied on top of the commit that was HEAD at the time git stash was run, it restores the originally stashed state with no conflicts.\n\n\nAs commented by benjohn (see git stash man page):\n\nTo also stash currently untracked (newly added) files, add the argument -u, so:\n\ngit stash -u"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git clone https/ssl error [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow can I make git accept a self signed certificate?\n\n (20 answers)\n \n\nClosed 8 years ago.\n\n\n\nI have installed the ssl certificate and key in my git server. But am getting error when i try to clone via https from my mysysgit. Earlier it was working fine with http. Unable to identify where it is failing\n$ git clone https://server.name/git/testing.git\nCloning into 'testing'...\n* Couldn't find host server.name in the _netrc file; using defaults\n* About to connect() to server.name port 443 (#0)\n* Trying server.name...\n* Adding handle: conn: 0x274fd60\n* Adding handle: send: 0\n* Adding handle: recv: 0\n* Curl_addHandleToPipeline: length: 1\n* - Conn 0 (0x274fd60) send_pipe: 1, recv_pipe: 0\n* Connected to server.name(server.name) port 443 (#0)\n* successfully set certificate verify locations:\n* CAfile: C:\\Users\\user1\\AppData\\Local\\Programs\\Git/bin/curl-ca-bundle.crt\n CApath: none\n* SSL certificate problem: self signed certificate\n* Closing connection 0\nfatal: unable to access 'https://server.name/git/testing.git/': SSL certificate problem: self signed certificate"
},
{
"role": "assistant",
"content": "If you are getting an error while doing a git clone, then above needs to be changed to:\ngit config --global http.sslVerify false"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How to make git diff --ignore-space-change the default\nI could probably setup an alias, but it seems like I should be able to set this as an option in the config file, only I don't see anyway to do it.\nI only want the --ignore-space-change when I'm doing diff, not when I'm doing apply or anything else. I'm trying to make the diff easier to understand by not cluttering it with with extraneous +/- lines that have no real changes on them."
},
{
"role": "assistant",
"content": "You could use git alias or bash alias if you are using shell-available OS.\n\ngit alias : Run this command to add alias:\ngit config --global alias.dfw 'diff --ignore-space-change'\nHere --ignore-space-change can be abbreviated to -w.\nTo use the alias: git dfw\n\nbash alias : Run this command to add bash alias:\necho \"alias gitdfw='git diff --ignore-space-change'\">>~/.profile\nOpen a new terminal and you can directly run gitdfw to achieve the same."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Make git undo any whitespace-only changes?\nIs there an easy way to automatically do a git checkout on any file that only has whitespace changes? I'm dealing with both Windows and some code generation that's run from Eclipse, so I get newline changes and whitespace changes that are clogging up my workflow with noise, and making it difficult to track actual changes.\nEven just a nice way to report which files have real changes and which don't would be a start, rather than having to do a diff -w for each one"
},
{
"role": "assistant",
"content": "If your changes are not staged\nTo stage changes that are not just whitespace changes, you can do:\ngit diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero -\nAfterwards, to remove all unstaged changes (those changes that differ only in whitespace), you can do:\ngit checkout .\nIf your changes are staged\nUnstage your changes by doing a git reset --mixed and continue from the top of this answer. Note that mixed is the default mode and can be omitted."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects ="
},
{
"role": "assistant",
"content": "for a ref that was up to date and did not need pushing."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What should be in my .gitignore for an Android Studio project?\nWhat files should be in my .gitignore for an Android Studio project?\nI've seen several examples that all include .iml but IntelliJ docs say that .iml must be included in your source control."
},
{
"role": "assistant",
"content": "Updated to Android Studio 3.0\nPlease share missing items in comments.\nA late answer but this alternative answer was not right for us ...\nSo, here's our gitignore file:\n#built application files\n*.apk\n*.ap_\n*.aab\n \n# files for the dex VM\n*.dex\n \n# Java class files\n*.class\n \n# generated files\nbin/\ngen/\n \n# Local configuration file (sdk path, etc)\nlocal.properties\n \n# Windows thumbnail db\nThumbs.db\n \n# OSX files\n.DS_Store\n \n# Android Studio\n*.iml\n.idea\n#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.\n.gradle\nbuild/\n.navigation\ncaptures/\noutput.json \n \n#NDK\nobj/\n.externalNativeBuild\n\nSince Android Studio 2.2 and up to 3.0, new projects are created with this gitignore file:\n*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n.externalNativeBuild\n\nDeprecated - for older project format, add this section to your gitignore file:\n\n/*/out\n/*/*/build\n/*/*/production\n*.iws\n*.ipr\n*~\n*.swp\n\nThis file should be located in the project's root folder and not inside the project's module folder.\nEdit Notes:\n\nSince version 0.3+ it seems you can commit and push *.iml and build.gradle files. If your project is based on Gradle: in the new open/import dialog, you should check the \"use auto import\" checkbox and mark the \"use default gradle wrapper (recommended)\" radio button. All paths are now relative as @George suggested.\n\nUpdated answer according to @128KB attached source and @Skela suggestions"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker GIT_OPTIONAL_LOCKS"
},
{
"role": "assistant",
"content": "If this Boolean environment variable is set to false, Git will complete any requested operation without\nperforming any optional sub-operations that require taking a lock.\nFor example, this will prevent git status from refreshing the\nindex as a side effect. This is useful for processes running in\nthe background which do not want to cause lock contention with\nother operations on the repository. Defaults to 1 ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can I mark a GIT remote as read only? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nGit: Set up a fetch-only remote?\n\n (5 answers)\n \n\nClosed 9 years ago.\n\n\n\nI have read/write access to a repo on GitHub. I have a local clone of that repo. I'd like to be able to pull changes from that remote, but I should never push changes to it.\nIs there a way I can mark the remote as read-only so I never accidentally type in the wrong command and push to it?"
},
{
"role": "assistant",
"content": "You could shut off default pushes via\ngit config push.default nothing\n\nor for stronger protection on a specific remote you could break pushes to that remote entirely by e.g. \ngit config remote.origin.pushurl \"you really didn't want to do that\""
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-bugreport - Collect information for user to file a bug report"
},
{
"role": "assistant",
"content": "DESCRIPTION Collects information about the user’s machine, Git client, and repository\nstate, in addition to a form requesting information about the behavior the\nuser observed, and stores it in a single text file which the user can then\nshare, for example to the Git mailing list, in order to report an observed\nbug. The following information is requested from the user: Reproduction steps Expected behavior Actual behavior The following information is captured automatically: git version --build-options uname sysname, release, version, and machine strings Compiler-specific info string A list of enabled hooks $SHELL Additional information may be gathered into a separate zip archive using the --diagnose option, and can be attached alongside the bugreport document to\nprovide additional context to readers. This tool is invoked via the typical Git setup process, which means that in some\ncases, it might not be able to launch - for example, if a relevant config file\nis unreadable. In this kind of scenario, it may be helpful to manually gather\nthe kind of information listed above when manually asking for help."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-push - Update remote refs along with associated objects push.default"
},
{
"role": "assistant",
"content": "Defines the action git push should take if no refspec is\ngiven (whether from the command-line, config, or elsewhere).\nDifferent values are well-suited for\nspecific workflows; for instance, in a purely central workflow\n(i.e. the fetch source is equal to the push destination), upstream is probably what you want. Possible values are: nothing - do not push anything (error out) unless a refspec is\ngiven. This is primarily meant for people who want to\navoid mistakes by always being explicit. current - push the current branch to update a branch with the same\nname on the receiving end. Works in both central and non-central\nworkflows. upstream - push the current branch back to the branch whose\nchanges are usually integrated into the current branch (which is\ncalled @{upstream} ). This mode only makes sense if you are\npushing to the same repository you would normally pull from\n(i.e. central workflow). tracking - This is a deprecated synonym for upstream . simple - push the current branch with the same name on the remote. If you are working on a centralized workflow (pushing to the same repository you\npull from, which is typically origin ), then you need to configure an upstream\nbranch with the same name. This mode is the default since Git 2.0, and is the safest option suited for\nbeginners. matching - push all branches having the same name on both ends.\nThis makes the repository you are pushing to remember the set of\nbranches that will be pushed out (e.g. if you always push maint and master there and no other branches, the repository you push\nto will have these two branches, and your local maint and master will be pushed there). To use this mode effectively, you have to make sure all the\nbranches you would push out are ready to be pushed out before\nrunning git push , as the whole point of this mode is to allow you\nto push all of the branches in one go. If you usually finish work\non only one branch and push out the result, while other branches are\nunfinished, this mode is not for you. Also this mode is not\nsuitable for pushing into a shared central repository, as other\npeople may add new branches there, or update the tip of existing\nbranches outside your control. This used to be the default, but not since Git 2.0 ( simple is the\nnew default)."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Should XCSharedData be checked into Git Repo for Xcode project?\nI just made some changes and I see a pending file that has not been added to the repo. The filenames path is */xcshareddata/IDEWorkspaceChecks.plist. Can someone explain the reason for this file and why or why not it needs to be added to the repo?"
},
{
"role": "assistant",
"content": "The files in xcshareddata/ should be added to the repo (but not the ones in xcuserdata/):\n\nXcode 9.3 adds a new IDEWorkspaceChecks.plist file to a workspace's shared data, to store the state of necessary workspace checks. Committing this file to source control will prevent unnecessary rerunning of those checks for each user opening the workspace. (37293167)\n\nhttps://developer.apple.com/library/archive/releasenotes/DeveloperTools/RN-Xcode/Chapters/Introduction.html\n\nRegarding Xcode 9 and newer, the only line you really need in your .gitignore is:\nxcuserdata/\n\nNothing else for Xcode 9+. Whatever other lines you have in your .gitignore should be only added for your specific needs, not because you found an obsolete .gitignore sample on the internet. :)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc blocks"
},
{
"role": "assistant",
"content": "Blocks of moved text of at least 20 alphanumeric characters\nare detected greedily. The detected blocks are\npainted using either the color.diff.{old,new}Moved color.\nAdjacent blocks cannot be told apart."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Setting Visual Studio Code as my Mac's default editor (including editing Git commits)\nI am trying to configure my Mac Book Pro (OSX El Capitan 10.11.1) to use Visual Studio Code as its default editor. I have created a ~/.bash_profile file with the following two lines\nvscode () { VSCODE_CWD=\"$PWD\" open -n -b \"com.microsoft.VSCode\" --args $* ;}\nexport VISUAL=open\\ -n\\ -b\\ \"com.microsoft.VSCode\"\n\nThis works for some things: I can type vscode test.txt at the bash terminal and up pops test.txt in Visual Studio Code, and if I run the command env I see VISUAL=open -n -b com.microsoft.VSCode in the list. I can even just type $VISUAL and Visual Studio Code opens on a new empty file.\nBut if I type git commit I get the following error\n\nerror: cannot run com.microsoft.vscode: No such file or directory\n error: unable to start editor 'com.microsoft.vscode' Please supply the\n message using either -m or -F option. \n\nSo I have succeeded inasmuch as git is trying to open Visual Studio Code for me to edit my commit message but it is then failing.\nWhat X should I use in the line export VISUAL=X in my ~/.bash_profile file to enable git to open Visual Studio Code for commit messages?\n(N.B. How to use Visual Studio Code as Default Editor for Git is not a duplicate since Gary is on a Windows PC.)"
},
{
"role": "assistant",
"content": "Add export EDITOR=\"code -w\" to your shell's profile or rc file\n(For example, your bash profile is accessible via open ~/.bash_profile)\nThis requires you to have the code binary already in your path.\nIf you don't have that, or don't know if you do, simply go into vscode, enter CMD + SHIFT + P, type code and click Shell Command: Install 'code' command in PATH.\nAlso, very helpful comment by pompalini below,\n\nremember to \"refresh\" terminal by closing and opening it again or resourcing your bash profile by running source ~/.bash_profile. Only then will the new changes in .bash_profile apply to your terminal."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Locate Git installation folder on Mac OS X\nI'm just curious, Where Git get installed (via DMG) on Mac OS X file system?"
},
{
"role": "assistant",
"content": "Is it in your PATH? If so just run which git in the terminal and it will tell you."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --src-prefix=<prefix>"
},
{
"role": "assistant",
"content": "Show the given source prefix instead of \"a/\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I fetch a branch on someone else's fork on GitHub? [duplicate]\nThis question already has answers here:\n \n \n\n\n\n\nHow to pull remote branch from somebody else's repo\n\n (8 answers)\n \n\nClosed 7 years ago.\n\n\n\nI've forked from a repo on GitHub. I want to get the code from a branch on another user's fork. \nMust I clone this user's whole repo to a separate local repo or can I do something like git checkout link_to_the_other_users_branch?"
},
{
"role": "assistant",
"content": "$ git remote add theirusername [email protected]:theirusername/reponame.git\n$ git fetch theirusername\n$ git checkout -b mynamefortheirbranch theirusername/theirbranch\n\nNote that there are multiple \"correct\" URIs you can use for the remote when you add it in the first step.\n\n[email protected]:theirusername/reponame.git is an SSH-based URI\nhttps://github.com/theirusername/reponame.git is an HTTPS URI\n\nWhich one you prefer to use will depend on your situation. GitHub has a help article explaining the difference and helping you choose: Choosing a URL for your remote repository"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-show - Show various types of objects minimal"
},
{
"role": "assistant",
"content": "Spend extra time to make sure the smallest possible diff is\nproduced."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-branch - List, create, or delete branches --unset-upstream"
},
{
"role": "assistant",
"content": "Remove the upstream information for <branchname>. If no branch\nis specified it defaults to the current branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Copy a git repo without history\nI have a private repository on GitHub that I want to make public. However, some of the initial commits contain information that I don't want to publicize (hard-coded credentials, etc).\nWhat is the easiest route to make the latest commit public (I don't really need or want the previous commits in the public repository) without including some or all of the commit history?"
},
{
"role": "assistant",
"content": "You can limit the depth of the history while cloning:\n--depth <depth>\nCreate a shallow clone with a history truncated to the specified \nnumber of revisions.\n\nUse this if you want limited history, but still some."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Trying to commit Git files but getting :: fatal: LF would be replaced by CRLF in <some file in repo>\nWhen I try to commit some changed files, I get the following error message with TortoiseGit\nfatal: LF would be replaced by CRLF in <some file in the repo>\nNow, before I get the usual LF vs CRLF answers, I know and understand what the debate is about. Secondly, I've also set my global settings to:\ncore.autocrlf true\nThird, I've got a .gitattributes file.\nSo I -want- to make sure or files are forced to have CRLF.\nWhat I don't understand is that it's saying FATAL and blocking me from continuing. A Warning? Sure! Do I know what I'm trying to do? I do! \nI just want it to convert silently and STFU.\nAlternatively, if it's forced to BLOCK me, is there a way I can update all files in the repo to be CRLF, so this warning is no longer issued?\nThese repos are private, so they will never be developed outside of Windows + Visual Studio. \nHow can I proceed?"
},
{
"role": "assistant",
"content": "You might want to set core.safecrlf to \"warn\", if you want only warning and not a fatal error.\nFrom \"git config\" mange page:\ncore.safecrlf\n\nIf true, makes git check if converting CRLF is reversible when end-of-line conversion is active. Git will verify if a command modifies a file in the work tree either directly or indirectly.\n For example, committing a file followed by checking out the same file should yield the original file in the work tree. If this is not the case for the current setting of core.autocrlf, git will reject the file.\n The variable can be set to \"warn\", in which case git will only warn about an irreversible conversion but continue the operation.\nCRLF conversion bears a slight chance of corrupting data.\n When it is enabled, git will convert CRLF to LF during commit and LF to CRLF during checkout.\nA file that contains a mixture of LF and CRLF before the commit cannot be recreated by git.\n For text files this is the right thing to do: it corrects line endings such that we have only LF line endings in the repository.\nBut for binary files that are accidentally classified as text the conversion can corrupt data.\nIf you recognize such corruption early you can easily fix it by setting the conversion type explicitly in .gitattributes.\n Right after committing you still have the original file in your work tree and this file is not yet corrupted. You can explicitly tell git that this file is binary and git will handle the file appropriately.\nUnfortunately, the desired effect of cleaning up text files with mixed line endings and the undesired effect of corrupting binary files cannot be distinguished.\n In both cases CRLFs are removed in an irreversible way. For text files this is the right thing to do because CRLFs are line endings, while for binary files converting CRLFs corrupts data.\n\nI prefer identifying the exact files or types of file I want to force the eol with .gitattributes files only (with core.eol settings, which you have), and leave autocrlf to false.\nIn case of text fiels with mixed eol, this blog post suggests, for instance, to:\n\nIf you have Notepad++ installed in your computer, simply follow these steps.\n\nOpen the file that is having the Fatal issue.\nClick Edit -> EOL Conversion then select Windows Format or to any that you’re having an issue committing. \n\n\n\nWarning, if you have Git 2.17 or 2.18: a regression introduced in 8462ff4 (\"convert_to_git(): safe_crlf/checksafe becomes int conv_flags\", 2018-01-13, Git 2.17.0) back in Git 2.17 cycle caused autocrlf rewrites to produce a warning message despite setting safecrlf=false.\nSee commit 6cb0912 (04 Jun 2018) by Anthony Sottile (asottile).\n(Merged by Junio C Hamano -- gitster -- in commit 8063ff9, 28 Jun 2018)"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker gitattributes"
},
{
"role": "assistant",
"content": "Defining attributes per path"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "How do I commit only some files?\nI have two projects. One is the \"official\" project and the second is a light modification (some files added). I created new branch and I put new files to them. But in during development some files common to both branches is changed.\nHow do I commit only these files?"
},
{
"role": "assistant",
"content": "I suppose you want to commit the changes to one branch and then make those changes visible in the other branch. In git you should have no changes on top of HEAD when changing branches.\nYou commit only the changed files by:\ngit commit [some files]\n\nOr if you are sure that you have a clean staging area you can\ngit add [some files] # add [some files] to staging area\ngit add [some more files] # add [some more files] to staging area\ngit commit # commit [some files] and [some more files]\n\nIf you want to make that commit available on both branches you do \ngit stash # remove all changes from HEAD and save them somewhere else\ngit checkout <other-project> # change branches\ngit cherry-pick <commit-id> # pick a commit from ANY branch and apply it to the current\ngit checkout <first-project> # change to the other branch\ngit stash pop # restore all changes again"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Using someone else's repo as a Git Submodule on GitHub\nI am trying to find out if it is possible to use someone else's repository (or branch of a repository) as a Submodule in your own Git repository. Documentation on github itself is either missing, or I'm not using the right terminology to look for it. If this isn't the preferred way to go about including a public repository as a shared library within ones git project, suggestions as an alternative best practice would be appreciated."
},
{
"role": "assistant",
"content": "Yes, you can add any repository as a submodule in your project. Just do:\ngit submodule add git://github.com/whomsoever/whatever.git\n\n... in the top level of your repository. This is indeed the easiest way with git to use some existing useful repository within your own. For more information on submodules, you could look at:\n\nPro Git's section on submodules\nThe quite readable bit in the git manual\nThe section on submodules in the git community book\n\nUpdate: as jfountain points out below, if you want to add the submodule at a subdirectory path (or with a name different from the default) you can supply that as an additional parameter to that command, e.g.:\ngit submodule add git://github.com/whomsoever/whatever.git foo/bar"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can't make git stop tracking package-lock.json\nWith npm v5 here is now package-lock.json file being created after npm install\nIt is recommended to commit this file, but I have issue that this file is different for some reason between my dev machine and my server. Even if I push that file to repo, after npm install on server, file changes.\nSo now I'm attempting to make git untrack this file. After following numerous answers from other questions, I seem to have almost managed to do so, it's not tracked on dev machine, doesn't appear in the repo itself, but after I pull code to server and make npm install, it appears in modified files.\nFile is in .gitignore, but server git for some reason ignores it.\ngit check-ignore -v -n package-lock.json\n:: package-lock.json\ngit check-ignore -v -n --no-index package-lock.json\n.gitignore:10:package-lock.json package-lock.json \nPossibly relevant info:\nDev machine: Windows 10.\nServer: Ubuntu 14.04.\nI'm pulling code to server using tags."
},
{
"role": "assistant",
"content": "You need to remove it from your repo (git rm package-lock.json) in order for git to stop tracking it.\n.gitignore only works for untracked files. If you have a tracked file that is also in your .gitignore, the fact that the file is tracked overrides the fact that it is also in .gitignore."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-log - Show commit logs --author-date-order"
},
{
"role": "assistant",
"content": "Show no parents before all of its children are shown, but\notherwise show commits in the author timestamp order."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Contributing to project on github, how to \"rebase my pull request on top of master\"\n\nOk so I an contributing to a project on github. The project on github is upstream, my forked repo on github is origin, and my local repo on my computer.\ngit checkout -b feature\n# Working on feature\ngit commit -a -m 'only commit on feature'\n\nthen I submit a pull request \ngit push origin master\n\nThe pull request is reviewed and a unrelated change needs to be made. Someone else makes a commit and merge into upstream/master\nNow I am asked by the upstream maintainer to \"rebase my pull request on top of master\"\nThis is my story (insert Law and Order sound effect).....\nI did not make any changes to the pull request and its still the same commit on branch feature. \ngit checkout master\ngit fetch upstream\ngit checkout feature\ngit rebase master\n=> \"Current branch feature is up to date.\"\ngit push origin feature\n=> \"Everything up-to-date\"\n\nI don't understand. How is this possible when I know that someone committed and merged to upstream/master after I pushed my pull request to origin/feature?\nCan anyone tell me what the correct procedure should be in this situation?"
},
{
"role": "assistant",
"content": "You only show a fetch on the upstream repo. That doesn't actually update any of your local branches. It only updates your knowledge of upstream. You'd need to ensure upstream/master is fully merged into your master, like with a git pull, prior to rebasing onto master, or more simply just rebase onto upstream/master.\nI.e:\ngit checkout master\ngit pull upstream master\ngit checkout feature\ngit rebase master\n\nor\ngit checkout feature\ngit fetch upstream master\ngit rebase upstream/master\n\nUpdate:\nAfter fixing your local feature branch, you'll need to push it back to origin to finish updating the pull request. Since you've pushed feature once already, you can't simply push again because a rebase changes history, and it's no long a fast-forward. Normally, whan a push fails with a \"non-fast-forward\", you'd resolve it by doing a pull, but a pull will just combine the two divergent histories, which is definitely not what you want. That would mean your old (pre rebase) feature branch would be combined with the new (post rebase) one. You want to overwrite origin/feature with the state of the new feature branch, dumping any record of the old one. That means you'll want to force the push to happen, even though it's not a fast-forward, using git push -f origin feature. Note: force pushing is dangerous, and you can lose commits with it. Only use it if you're absolutely sure you know what you're doing, like right here, where you intentionally want to drop the old, useless commits in the pre-rebase feature branch."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options transfer.bundleURI"
},
{
"role": "assistant",
"content": "When true , local git clone commands will request bundle\ninformation from the remote server (if advertised) and download\nbundles before continuing the clone through the Git protocol.\nDefaults to false ."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "django migrations - workflow with multiple dev branches\nI'm curious how other django developers manage multiple code branches (in git for instance) with migrations.\nMy problem is as follows:\n- we have multiple feature branches in git, some of them with django migrations (some of them altering fields, or removing them altogether)\n- when I switch branches (with git checkout some_other_branch) the database does not reflect always the new code, so I run into \"random\" errors, where a db table column does not exist anymore, etc...\nRight now, I simply drop the db and recreate it, but it means I have to recreate a bunch of dummy data to restart work. I can use fixtures, but it requires keeping track of what data goes where, it's a bit of a hassle.\nIs there a good/clean way of dealing with this use-case? I'm thinking a post-checkout git hook script could run the necessary migrations, but I don't even know if migration rollbacks are at all possible."
},
{
"role": "assistant",
"content": "Migrations rollback are possible and usually handled automatically by django.\nConsidering the following model:\nclass MyModel(models.Model):\n pass\n \n\nIf you run python manage.py makemigrations myapp, it will generate the initial migration script.\nYou can then run python manage.py migrate myapp 0001 to apply this initial migration.\nIf after that you add a field to your model:\nclass MyModel(models.Model): \n my_field = models.CharField()\n \n\nThen regenerate a new migration, and apply it, you can still go back to the initial state. Just run\npython manage.py migrate myapp 0001 and the ORM will go backward, removing the new field.\nIt's more tricky when you deal with data migrations, because you have to write the forward and backward code.\nConsidering an empty migration created via python manage.py makemigrations myapp --empty,\nyou'll end up with something like:\n# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import models, migrations\n\ndef forward(apps, schema_editor):\n # load some data\n MyModel = apps.get_model('myapp', 'MyModel')\n \n while condition:\n instance = MyModel()\n instance.save()\n \ndef backward(apps, schema_editor):\n # delete previously loaded data\n MyModel = apps.get_model('myapp', 'MyModel')\n \n while condition:\n instance = MyModel.objects.get(myargs)\n instance.delete()\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('myapp', '0003_auto_20150918_1153'),\n ]\n\n operations = [ \n migrations.RunPython(forward, backward),\n ]\n \n\nFor pure data-loading migrations, you usually don't need the backward migration.\nBut when you alter the schema and update existing rows\n(like converting all values in a column to slug), you'll generally have to write the backward step.\nIn our team, we try to avoid working on the same models at the same time to avoid collision.\nIf it is not possible, and two migration with the same number (e.g 0002) are created,\nyou can still rename one of them to change the order in which they will be applied (also remember to update\nthe dependencies attribute on the migration class to your new order).\nIf you end up working on the same model fields at the same time in different features,\nyou'll still be in trouble, but it may mean these features are related and should be handled\ntogether in a single branch.\nFor the git-hooks part, it's probably possible to write something, Assuming your are on branch mybranch\nand want to check out another feature branch myfeature:\n\nJust before switching, you dump the list of currently applied migrations into\na temporary file mybranch_database_state.txt\nThen, you apply myfeature branch migrations, if any\nThen, when checking back mybranch, you reapply your previous database state\nby looking to the dump file.\n\nHowever, it seems a bit hackish to me, and it would probably be really difficult to handle properly all scenarios:\nrebasing, merging, cherry-picking, etc.\nHandling the migrations conflicts when they occurs seems easier to me."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-filter-branch - Rewrite branches"
},
{
"role": "assistant",
"content": "SYNOPSIS git filter-branch [--setup <command>] [--subdirectory-filter <directory>]\n\t[--env-filter <command>] [--tree-filter <command>]\n\t[--index-filter <command>] [--parent-filter <command>]\n\t[--msg-filter <command>] [--commit-filter <command>]\n\t[--tag-name-filter <command>] [--prune-empty]\n\t[--original <namespace>] [-d <directory>] [-f | --force]\n\t[--state-branch <branch>] [--] [<rev-list-options>…]"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What are the consequences of using receive.denyCurrentBranch in Git?\nI have a Git repository. I have cloned the repository and can commit my local changes. When I push my changes to the server it works.\nAs soon as I create a branch, I checkout the branch, commit my work and then checkout the master branch. I then merge my local changes into the master branch. When I try to push to the server I get the following exception:\nWelcome to Git (version 1.7.11-preview20120620)\n\nRun 'git help git' to display the help index.\nRun 'git help <command>' to display help for specific commands.\n\n$ git push origin master:master\n Counting objects: 9, done.\n Delta compression using up to 4 threads.\n Compressing objects: 100% (7/7), done.\n Writing objects: 100% (8/8), 13.68 KiB, done.\n Total 8 (delta 2), reused 1 (delta 0)\n Unpacking objects: 100% (8/8), done.\n remote: error: refusing to update checked out branch: refs/heads/master\n remote: error: By default, updating the current branch in a non-bare repository\n remote: error: is denied, because it will make the index and work tree inconsistent\n remote: error: with what you pushed, and will require 'git reset --hard' to match\n remote: error: the work tree to HEAD.\n remote: error:\n remote: error: You can set 'receive.denyCurrentBranch' configuration variable to\n\n remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into\n\n remote: error: its current branch; however, this is not recommended unless you\n remote: error: arranged to update its work tree to match what you pushed in some\n\n remote: error: other way.\n remote: error:\n remote: error: To squelch this message and still keep the default behaviour, set\n\n remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.\n To c:/jGit\n ! [remote rejected] master -> master (branch is currently checked out)\n error: failed to push some refs to 'c:/gitRepository'\n\nOne solution is to run the following command:\ngit config receive.denyCurrentBranch ignore\n\nAfter this it works, but I would like to know why I need to use this option. Is this the only option? What are the consequences of doing this?\nWhat I would really like to do is create branches, merge them into the master branch and then push my changes to the server."
},
{
"role": "assistant",
"content": "Why Git won't let you push to non-bare repositories\nThe original poster says:\n\nOne solution is to run the following command:\ngit config receive.denyCurrentBranch ignore\n\nAfter this it works, but I would like to know why I need to use this\n option. Is this the only option? What are the consequences of doing\n this?\n\nAs I point out in my answer to a similar question, since Git version 1.6.2, Git won't let you push to a non-bare repository by default. This is because the git push command only updates the branch and HEAD references on the remote repository. What it doesn't do is also update the working-copy and staging-area in that non-bare remote.\nAs a consequence, when you use git status in the remote repo, you'll see that the repo's previous state is still present in the working copy (and staged in the index):\n$ git status\nOn branch master\nChanges to be committed:\n (use \"git reset HEAD <file>...\" to unstage)\n\n new file: previous-state.txt\n\nIf you look at the error message that you got when you first tried to push to your non-bare remote repo with the receive.denyCurrentBranch setting set to the default refuse value, you'll see that the message tells you basically the same thing:\nerror: refusing to update checked out branch: refs/heads/master\nerror: By default, updating the current branch in a non-bare repository\nerror: is denied, because it will make the index and work tree inconsistent\nerror: with what you pushed, and will require 'git reset --hard' to match\nerror: the work tree to HEAD.\nerror:\nerror: You can set 'receive.denyCurrentBranch' configuration variable to\nerror: 'ignore' or 'warn' in the remote repository to allow pushing into\nerror: its current branch; however, this is not recommended unless you\nerror: arranged to update its work tree to match what you pushed in some\nerror: other way.\n\nYou should really just push to bare Git repositories\nAs pointed out in some of the other answers, you shouldn't really be pushing to a non-bare repository, for the reasons I pointed out above, and which Git itself is telling you.\nSo like what this answer states, a simple way to convert an existing non-bare repo to a bare one is to simply reclone it as a bare repo:\ngit clone --bare old-repo\n\nOr you could try messing around with the core.bare config setting, as detailed in this answer."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Github Pull Requests template not showing\nI wanted to create custom Pull Requests template for my Github repo (internal version in my company and not on Github.com), so I followed instructions on this link. I followed below steps:\n\nCreated the new template file in the location: [my-repo]/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md.\nMerged this new file into master.\nCreated a new branch from master, commited some changes into new branch.\nCreated a new Pull Request to master, but the template did not show up.\n\nCreating the new PR did not show up the template I had created. Similar steps for creating new issue templates work fine, but PR templates arent working. I would like to add different templates inside PULL_REQUEST_TEMPLATE folder in order to create multiple pull request templates like feature template, bug-fix template etc. My PR template markdown has the following in it:\n---\nname: Design Review\nabout: Design Review issue template\n\n---\n\n# PR Change Description\nThis PR is to add a new vendor type."
},
{
"role": "assistant",
"content": "You must create templates on the repository's default branch. Templates created in other branches are not available for collaborators to use.\nNOTE: If your PullRequest Template is not applied on every new PR you create it could mostly be due to the following reasons\n\nEither PR template doesn't exist at all in any of the branches.\nOr it is present in non-default branch\n\nYou can store your pull request template in the repository's visible root directory, the docs folder, or the hidden .github directory. Pull request template filenames are not case sensitive, and can have an extension such as .md or .txt."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-credential"
},
{
"role": "assistant",
"content": "Retrieve and store user credentials"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Files showing as modified directly after a Git clone\nI'm having an issue with a repository at the moment, and though my Git-fu is usually good, I can't seem to solve this issue.\nWhen I clone this repository, then cd into the repository, git status shows several files as changed. Note: I haven't opened the repository in any editor or anything.\nI tried following this guide: http://help.github.com/dealing-with-lineendings/, but this didn't help at all with my issue.\nI have tried git checkout -- . many times, but it seems not to do anything.\nI'm on a Mac, and there are no submodules in the repository itself.\nThe filesystem is \"Journaled HFS+\" filesystem on the Mac and is not case-sensitive. The files are one-line and about 79 KB each (yes, you heard right), so looking at git diff isn't particularly helpful. I have heard about doing git config --global core.trustctime false which might help, which I will try when I get back to the computer with the repository on it.\nI changed details of filesystem with facts! And I tried the git config --global core.trustctime false trick which didn't work very well."
},
{
"role": "assistant",
"content": "I had the same problem on the Mac after cloning a repository. It would assume all files had been changed.\nAfter running git config --global core.autocrlf input, it was still marking all files as changed. After looking for a fix I came across .gitattributes file in the home directory which had the following.\n* text=auto\n\nI commented it out and any other cloned repositories from now on were working fine."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-clean - Remove untracked files from the working tree -d"
},
{
"role": "assistant",
"content": "Normally, when no <pathspec> is specified, git clean will not\nrecurse into untracked directories to avoid removing too much.\nSpecify -d to have it recurse into such directories as well.\nIf a <pathspec> is specified, -d is irrelevant; all untracked\nfiles matching the specified paths (with exceptions for nested\ngit directories mentioned under --force ) will be removed."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git - the stupid content tracker git-notes"
},
{
"role": "assistant",
"content": "Add or inspect object notes"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Automatic version number both in setup.py (setuptools) AND source code?\nSITUATION:\nI have a python library, which is controlled by git, and bundled with distutils/setuptools. And I want to automatically generate version number based on git tags, both for setup.py sdist and alike commands, and for the library itself.\nFor the first task I can use git describe or alike solutions (see How can I get the version defined in setup.py (setuptools) in my package?).\nAnd when, for example, I am in a tag '0.1' and call for 'setup.py sdist', I get 'mylib-0.1.tar.gz'; or 'mylib-0.1-3-abcd.tar.gz' if I altered the code after tagging. This is fine.\nTHE PROBLEM IS:\nThe problem comes when I want to have this version number available for the library itself, so it could send it in User-Agent HTTP header as 'mylib/0.1-3-adcd'.\nIf I add setup.py version command as in How can I get the version defined in setup.py (setuptools) in my package?, then this version.py is generated AFTER the tag is made, since it uses the tag as a value. But in this case I need to make one more commit after the version tag is made to make the code consistent. Which, in turns, requires a new tag for further bundling.\nTHE QUESTION IS:\nHow to break this circle of dependencies (generate-commit-tag-generate-commit-tag-...)?"
},
{
"role": "assistant",
"content": "You could also reverse the dependency: put the version in mylib/__init__.py, parse that file in setup.py to get the version parameter, and use git tag $(setup.py --version) on the command line to create your tag.\ngit tag -a v$(python setup.py --version) -m 'description of version'\n\nIs there anything more complicated you want to do that I haven’t understood?"
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-config - Get and set repository or global options diff.dstPrefix"
},
{
"role": "assistant",
"content": "If set, git diff uses this destination prefix. Defaults to \"b/\"."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-am - Apply a series of patches from a mailbox --no-utf8"
},
{
"role": "assistant",
"content": "Pass -n flag to git mailinfo (see git-mailinfo )."
}
] |
[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "git-diff - Show changes between commits, commit and working tree, etc -w --ignore-all-space"
},
{
"role": "assistant",
"content": "Ignore whitespace when comparing lines. This ignores\ndifferences even if one line has whitespace where the other\nline has none."
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.