User Tools

Site Tools


howto:github

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howto:github [2020/07/01 22:00] Wulf Rajekhowto:github [2023/05/29 11:55] (current) – external edit 127.0.0.1
Line 66: Line 66:
 </code> </code>
  
 +===== Removing git history =====
 +<code>
 +git checkout --orphan newBranch
 +git add -A  # Add all files and commit them
 +git commit
 +git branch -D master  # Deletes the master branch
 +git branch -m master  # Rename the current branch to master
 +git push -f origin master  # Force push master branch to github
 +git gc --aggressive --prune=all     # remove the old files
  
 +#rename url on github.com if desired, then update the url:
 +git remote set-url origin newURL
 +</code>
 +
 +===== Rebase with fork master =====
 +Example fork of repo mainuser/interestingrepo to myuser/interestingrepo
 +<code>
 +git clone git@github.com:myuser/interestingrepo.git
 +cd interestingrepo
 +git remote add upstream git@github.com:mainuser/interestingrepo.git
 +</code>
 +
 +To update:
 +<code>
 +git fetch upstream
 +git rebase upstream/master
 +</code>
 +
 +===== Change last commit message =====
 +
 +<code>
 +git commit --amend -m "New message"
 +git push --force repository-name branch-name
 +</code>
 +
 +===== Git Credentials =====
 +
 +<code>git config credential.helper store</code>
 +then:
 +<code>
 +git push http://example.com/repo.git
 +Username: <type your username>
 +Password: <type your password>
 +
 +[several days later]
 +git push http://example.com/repo.git
 +[your credentials are used automatically]
 +</code>
 +
 +Passwords stored in plain text, each on their own line in URL format:
 +<code ~/.git-credentials>
 +https://user:pass@example.com
 +</code>
 +
 +===== Forceful undo last commit =====
 +<code>
 +git reset --hard HEAD^
 +git push origin -f
 +</code>
howto/github.1593637217.txt.gz · Last modified: 2023/05/29 11:53 (external edit)