Hack hack hack...

An open journal-- some of it written for you, but most of it is for me.

GitHub

  • Cheat sheet
  • Git better explained
  • Scott Chacon of github

  • Git fetch versus git pull

    • In the simplest terms, git pull does a git fetch followed by a git merge.
    • You can do a git fetch at any time to update your local copy of a remote branch. This operation never changes any of your own branches and is safe to do without changing your working copy. I have even heard of people running git fetch periodically in a cron job in the background (although I wouldn’t recommend doing this).
    • A git pull is what you would do to bring your repository up to date with a remote repository.
  • Fetch and merge, don’t pull

  • Misc

    • I had not added my SSH key for the new Mac Air so that was preventing me from pushing. It gave me no issue with pulling or cloning, only pushing. The SSH was accessed by typing:
1
cat .ssh/id_rsa.pub

After adding it to https://github.com/settings/ssh I had no problems…

Pushed a bunch of branches with:

1
git push origin <name of the branch>

I could check what was in the repo and what had been pushed to the remote using the command: git branch with the all flag…

1
git branch -a

First thing in the morning you do is: - git fetch

This pulls the latest version without any merges.

creating a branch and pushing it to master….

1
2
3
4
5
6
7
♕ git co -b authentication
♕ git add .
♕ git commit -m 'message'
♕ git push origin authentication
♕ git co master
♕ git merge authentication --no-ff
♕ git push
1
2
git pull --rebase #=> if the remote has merges, rewind and then move back forward
git reset --hard HEAD #=> go to the last checkout (HEAD of the branch) without the warnings (hard)
1
2
3
♕ git co master
♕ git revert 3904d0354fcbcad023de4763a86ed0601e54cbe7
♕ git revert 3e872eed44eeab51fef966475661ab73ca851090

Pruning

With git remote prune origin I can remove the remote branches that are not any more on the remote.

Cleaning up local branches

Use this gem git branch --merged master | grep -v master | xargs git branch -d from.

Removing a file with confidential info

Suppose you want to remove a file (containing confidential information or copyright violation) from all commits:

git filter-branch --tree-filter 'rm filename' HEAD

Comments