Posted by & filed under Dev Workflow. Edit: 26 July 2014

... (third part and the end)

1. .gitignore for ignoring new files

.gitignore can be in global user scope to affect all projects, there it could be called .gitignore_global_scope or similar, and it must be specified by excludesfile param in .gitconfig file.

</eyes bleeding>
Copyright: Sean Molin

    2. Ignoring tracked files

    git rm --cached file-name-here

    --cached tells git to ignore tracked file and not track it anymore.

    3. Tracking empty directories (not by default) by creating an empty file inside that folder called .gitkepp or similiar

    git add path-to-folder

    So git know to track that empty file inside that folder, therefore track our folder as well.

    4. Branches are "branches" of 1 repository tree, used when 1 working tree working with many repo's branches within 1 project, to try out new code of a branch or revert working tree to a specific branch of repo...

    git branch (new-branch-name)

    To rename branch: git branch -m old-name new-name

    To delete branch (which is "clean"): git branch -d branch-name-here

    To delete branch (which is not clean such as currently on or not merged): git branch -D branch-name-here

    To switch among branches (working tree does not have conflict changes that are not tracked): git checkout branch-name-here

    To create and switch at the same time: git checkout -b branch-name-here

    To show all branches and commits relation: git log --graph --decorate --all

    To compare branches: git diff 1st-branch-name..2nd-branch-name

    To check if branches are included inside another: git branch --merged

    5. Merging is a way to combine code from 2 branches, used when branches meet and love each other after having tested them within working tree.

    From current branch, merge another one into:

    git merge other-branch-name

    Most simply is fast forward and recursive merge, used when there would be no conflicts.

    To force not using ff merge: git merge --no-ff other-branch-name

    To use only ff, not recursive: git merge --ff-only other-branch-name

    To resolve conflicts if any during merge, we need to solider on this phase:

    - Fix files that have conflicts by hand

    - git add that-file-name

    - git commit

    "git commit" without message during resolving conflict phase would be enough.

    Branches should be merged often and reciprocal to avoid far away difference and transformation from love to hatred between any 2 of them.

    5. Stash or temporarily buffer changes that are not staged/tracked. Stash area could be seen as 4th part of GIT beside 3 main parts we knew.

    Put a change to stash area: git stash save "message-here"

    List all stashed changes id: git stash list

    Show one stashed change details: git stash show -p [email protected]{id-here}

    Retrieve one stashed change into working tree:

    - Get and delete: git stash pop [email protected]{id-here}

    - Get only: git stash apply [email protected]{id-here}

    To resolve conflicts if any between stashed change we are getting and working tree, do it as with branch merging.

    To intentionally delete one stashed change: git stash drop [email protected]{id-here}

    6. Remotes are to collaborate with others through remote repositories that are not in local machine.

    7. Hooks are script to auto-do some actions before/after each commits.

    8. Sub-modules are ways to add repo inside another one.



    Comments are closed.