- Cheat sheet
- Git better explained
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.
- 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:
After adding it to https://github.com/settings/ssh I had no problems…
Pushed a bunch of branches with:
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…
First thing in the morning you do is:
This pulls the latest version without any merges.
creating a branch and pushing it to master….
1 2 3 4 5 6 7
1 2 3
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