How can set an older commit to be HEAD?

Here is what you can do: git checkout <branch-to-modify-head> git reset –hard <commit-hash-id-to-put-as-head> git push -f If you don’t force the push, git will throw this error: Updates were rejected because the tip of your current branch is behind. Note that this will tamper your git history, so another way of doing this is revert …

Read more

Git pushing to remote GitHub repository as wrong user

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: Host work.github.com HostName github.com User WORK_GITHUB_USERNAME PreferredAuthentications publickey IdentityFile ~/.ssh/id_work_rsa IdentitiesOnly yes Host personal.github.com HostName github.com User …

Read more

Export only modified and added files with folder structure in Git

git diff-tree -r –no-commit-id –name-only –diff-filter=ACMRT $commit_id git diff-tree -r $commit_id: Take a diff of the given commit to its parent(s) (including all subdirectories, not just the top directory). –no-commit-id –name-only: Do not output the commit SHA1. Output only the names of the affected files instead of a full diff. –diff-filter=ACMRT: Only show files added, …

Read more

What is the difference between git push.default=current and push.default=upstream?

You’ve summarized the difference in your question. upstream pushes to the configured upstream branch, while current assumes the upstream branch has the same name as the current local branch, and pushes to that specific name. In reality, there’s no reason to assume a local branch’s upstream tracking branch has the same name as the local …

Read more

How can I automatically deploy my app after a git push ( GitHub and node.js)?

Example in PHP: Navigate to github into your github repository add click “Admin” click tab ‘Service Hooks’ => ‘WebHook URLs’ and add http://your-domain-name/git_test.php then create git_test.php <?php try { $payload = json_decode($_REQUEST[‘payload’]); } catch(Exception $e) { exit(0); } //log the request file_put_contents(‘logs/github.txt’, print_r($payload, TRUE), FILE_APPEND); if ($payload->ref === ‘refs/heads/master’) { // path to your site …

Read more