git: patch does not apply
2023-01-07
Question I have a certain patch called my_pcc_branch.patch. When I try to apply it, I get following message: $ git apply --check my_pcc_branch.patch warning: src/main/java/.../AbstractedPanel.java has type 100644, expected 100755 error: patch failed: src/main/java/.../AbstractedPanel.java:13 error: src/main/java/.../AbstractedPanel.java: patch does not apply What does it mean? How can I fix this problem? Answer git apply --reject --whitespace=fix mychanges.patch worked for me. Explanation The --reject option will instruct git to not fail if it cannot determine how to apply a patch, but instead to apply the individual hunks it can apply and create reject files (.…
How can I keep my fork in sync without adding a separate remote?
2023-01-07
Question Let's assume there is a repository someone/foobar on GitHub, which I forked to me/foobar. How do I pull new commits from the parent repository directly to my fork, without having to add a separate remote and remember to pull regularly from there ? The goal is to: git pull to fetch from the parent repository git push to send everything to my fork Answer Open the forked Git repository me/foobar.…
How do I remove the old history from a git repository?
2023-01-05
Question I'm afraid I couldn't find anything quite like this particular scenario. I have a git repository with a lot of history: 500+ branches, 500+ tags, going back to mid-2007. It contains ~19,500 commits. We'd like to remove all of the history before Jan 1, 2010, to make it smaller and easier to deal with (we would keep a complete copy of the history in an archive repository). I know the commit that I want to have become the root of the new repository.…
How to see an HTML page on Github as a normal rendered HTML page to see preview in browser, without downloading?
2023-01-05
Question On http://github.com developer keep the HTML, CSS, JavaScript and images files of the project. How can I see the HTML output in browser? For example this: https://github.com/necolas/css3-social-signin-buttons/blob/master/index.html When I open this it doesn't show the rendered HTML of the code of author. It shows the page as a source code. Is it possible to see it as rendered HTML directly? Otherwise I always need to download the whole ZIP just to see the result.…
Import existing source code to GitHub
2023-01-05
Question How can I import source code from my computer to my GitHub account? Answer If you've got local source code you want to add to a new remote new git repository without 'cloning' the remote first, do the following (I often do this - you create your remote empty repository in bitbucket/github, then push up your source) Create the remote repository, and get the URL such as git@github.com:/youruser/somename.git or https://github.…
Go to particular revision
2023-01-04
Question I cloned a git repository of a certain project. Can I turn the files to the initial state and when I review the files go to revision 2, 3, 4 ... most recent? I'd like to have an overview of how the project was evolving. Answer Before executing this command keep in mind that it will leave you in detached head status Use git checkout <sha1> to check out a particular commit.…
How to 'git pull' without switching branches (git checkout)?
2023-01-04
Question I'm used to running git pull and other commands from within a branch I'm working on. But I have set up a development server that several people work on, so I don't want to have to switch branches when I do it. If I want to update an existing branch on the dev server from the github repository we all use, what would be the right way to do that?…