1 2 3 4 5 6 7 8
- It’s important to note that the fetch command pulls the data to your local repository — it doesn’t automatically merge it with any of your work or modify what you’re currently working on. You have to merge it manually into your work when you’re ready.
- The git pull command to automatically fetch and then merge a remote branch into your current branch.
You can delete a remote branch using the rather obtuse syntax ‘$ git push [remotename] :[branch]’. If you want to delete your serverfix branch from the server, you run the following:
$ git push origin <:branch name>
$ git branch -d <branch name>
In Git, there are two main ways to integrate changes from one branch into another: the merge and the rebase.
$ git rebase master
It works by going to the common ancestor of the two branches (the one you’re on and the one you’re rebasing onto), getting the diff introduced by each commit of the branch you’re on, saving those diffs to temporary files, resetting the current branch to the same commit as the branch you are rebasing onto, and finally applying each change in turn.
Important: Do not rebase commits that you have pushed to a public repository.
Git rebase onto
- this allows you to pop off the commit at a specific SHA and throw that onto another branch. This was incredibily useful for a branch with a screwed up history that you’d like to put on master or something. Good write up here
Git real review
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
- Checkout Los Techie’s suggestion on amending something without writing a message. I aliased this in my dotfiles which makes it extra fancy.
Removing a file
git rm file1.txt git commit -m "remove file1.txt"
To remove it from the repo AND keep in the local file system:
git rm --cached file.txt
This will create a new branch based on an revision:
♕ git co -b new-branch-name old-branch-name
What is a reasonable number of commits per branch? How often do you commit? Working on the same file… strategies? fast forward vs no fast forward