Skip to content

Added a section on git mv and updated cheatsheet.md accordingly #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Git for Collaboration is aimed at the second week students of the course, or tho
* [Making Changes](#changes)
* [Merging with Master](#merging)
* [Merge Conflicts](#conflicts)
* [Changing File Structure](#changing-file-structure)
4. [Introducing Github Flow](#github-flow)

#### [Git for Collaboration](#git-collaboration)
Expand Down Expand Up @@ -276,6 +277,39 @@ Do you see the lines at the top. The first section is labelled `HEAD` those are
Afterwards git status, add the files in red, commit, and push. Then make a pull request to master like before and merge. Don't forget to update your local master branch, and delete the merged branch in Github and in your local repo. It is good to keep your working environments clean and organised.


<a id="changing-file-structure" name="changing-file-structure"></a>
### Changing File Structure
Imagine you're working on a project that's getting bigger in size. As new files are added, it makes sense to group some of them into folders. For example, it's a good idea to keep all CSS files in one folder, JS files in another etc.

Let's assume you've just cloned a repository structured like this:
```
index.html
stylesheet.css
script.js
```

However, you'd prefer to split these into folders like:
```
css/stylesheet.css
js/script.js
index.html
```

In order to achieve this, `git mv` command comes in handy. Using it to move files *ensures preserving history* of the files you work on. To change file structure like above (and create new folders at the same time) use command:
```
mkdir css && git mv stylesheet.css ./css
mkdir css && git mv script.js ./js
```
(This glues `mkdir` and `git mv` commands together with `&&` operator).

Basic function usage is
```
git mv <source> <destination>
```
The command also takes optional parameters. To find out more, refer to [documentation](http://git-scm.com/docs/git-mv).



<a name="github-flow" id="github-flow"></a>
## Github Flow
Github flow is what most teams at Founders & Coders follow. It is simple and effective.
Expand Down
3 changes: 3 additions & 0 deletions cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@

##### Deleting a branch
git branch -d <branch name>

##### Moving files while preserving git history
git mv <source> <destination>