Changes in GitPrimer
Editor Comment
Added useful links
Revision Differences of Revision 12
Since we're planning to move to git eventually, I'll start collecting notes on this page. This should be a user's guide by the time we're done. ¶¶
[TOC] ¶
¶
# Comparison with Bazaar ¶
¶
Action | bzr | git ¶
-------- | -------- | -------- ¶
Switch to trunk | `cd ../trunk` | `git checkout master` ¶
Update trunk and merge into local branch | `cd ../trunk`; `bzr pull lp:widelands`; `cd ../<branch>`; `bzr merge ../trunk`; `bzr commit -m "Merged trunk."` | `git pull --rebase upstream master`; `git push origin <branch> --force` ¶
Show branches, with the current one highlighted | Use operating system to list directories | `git branch` ¶
Delete remote branch | Use Launchpad interface | `git push origin --delete <branch_name>` ¶
Delete local branch | Use operating system to delete directory | `git branch -d <branch_name>` ¶
Undo all changes | `bzr revert` | `git checkout .` ¶
Undo changes to a file | `bzr revert <file>` | `git checkout <file>` ¶
Get a remote branch and switch to it | `bzr branch <remote_branch_name> <new_local_branch>`; `cd <new_local_branch>` | `git checkout -b <new_local_branch> <remote_location>/<remote_branch_name>` ¶
¶
See also [Merging in bzr: The git approach vs the bzr approach](http://toykeeper.net/tutorials/bzr-vs-git/) ¶
¶
# Workflow ¶
¶
## Getting the code ¶
¶
[![fork_and_clone.png](/wlmedia/wlimages/fork_and_clone.png)](/wlmedia/wlimages/fork_and_clone.png) ¶
¶
## Working on your code ¶
¶
[![git_commit_cycle.png](/wlmedia/wlimages/git_commit_cycle.png)](/wlmedia/wlimages/git_commit_cycle.png) ¶
¶
## Synchonizing with the main repository / master branch ¶
¶
### Merging ¶
¶
[![git_merge_forkflow.png](/wlmedia/wlimages/git_merge_forkflow.png)](/wlmedia/wlimages/git_merge_forkflow.png) ¶
¶
### Rebasing ¶
¶
[![git_rebase_forkflow.png](/wlmedia/wlimages/git_rebase_forkflow.png)](/wlmedia/wlimages/git_rebase_forkflow.png) ¶
¶
# Checking out into subdirectories ¶
¶
Since our bottleneck is compile time rather than disk space, we will want to be able to check out into subdirectories, just like Bazaar does it. There are 2 ways of doing this: ¶
¶
1. Clone the full repository into a new directory and set up the remotes each time. This will support submodules (we are currently not using submodules, so don't worry about this). ¶
2. Use `git worktree` ([manual](https://git-scm.com/docs/git-worktree) [blog](https://blog.github.com/2015-07-29-git-2-5-including-multiple-worktrees-and-triangular-workflows/)). This command will create a separate copy of submodules too, but [can handle only 1 level](https://stackoverflow.com/questions/31871888/what-goes-wrong-when-using-git-worktree-with-git-submodules). ¶
¶
# Useful Links ¶
¶
* [Official git documentation](https://git-scm.com/doc) ¶
* [Getting started with GitHub](https://help.github.com/en/categories/getting-started-with-github)