- How to add Git system to a project
- Enter the project folder
- git init, a .git folder will be added
- How to configure git
- git config --global user.name "Lin", set the user name
- git config --global user.email lchen@ecsu.edu, set the value for user.email
- git config --global core.editor vim
- git config --global commit.template /home/lin/Documents/Git/template, add a commit template
- git config --global excludesfile /home/lin/Documents/Git/ignore, add a global gitignore file
- How to get the help information of a command
- git help config, get the help information of config
- What are the three stages in git
- modified, files changed but not commited, working directory
- staged, files added, index in git directory
- commited, files commited, in .git/object
- How to create a shared repository
- mkdir rep.git, create a git folder
- chgrp -R groupName rep.git, change the group
- chmod 2770 rep.git, make the folder readable and writable for users in the group
- cd rep.git, enter rep.git
- git init --bare --shared=group, files readable and writable for all users in the group
- cd .git/hooks, mv post-update.sample post-update
- How to add files in a projects to be monitored by git system
- How to remove a file from tracking
- git reset HEAD -- [fileName]
- git rm --cached [fileName]
- How to stage file
- How to commit
- git commit
- git commit -m message
- git commit -am message
- How to get a copy from server
- How to show a single file in a branch, commit
- git show [branchName]:[fileName]
- git show [commit]:[fileName]
- How to show the work tree of a branch, or commit
- git ls-tree [commit]
- git show [branchName]^{tree}
- git show [commit]^{tree}
- How to checkout a single file
- git checkout [branchName] -- [fileName]
- git checkout [commit] -- [fileName]
- How to undo all changes made since last commit
- git checkout -f
- git reset --hard HEAD
- How to compare two commit
- git diff [commit_1] [commit_2]
- git diff [branch_1]...[branch_2], changes that occurred on the branch_2 since branch_1 start off
- How to rewind to a commit
- git reset --hard [commit], get rid of the commits after it
- How to show all branches
- How to show all branches in gitk
- git log --graph --all
- gitk -all
- How to list the remote branches
- git ls-remote
- git remote show [repName]
- How to remove a remote branch
- git push origin --delete [remoteBranchName], remove both the local and remote branch
- git branch -r -d origin/b_2, remove the local remote branch
- How to add a branch to a previous commit
- git branch [branchName] [commit]
- How to show all tracking branches
- How to list all remote repositories
- How to add a remote repository
- git remote add [repName] [url]
- How to remove a remote repository
- How to merge a remote branch to the current branch
- fetch
- git fetch [repName] [repBranchName]
- check the branch to validate the content
- git merge [branchName], merge the target branch to the current branch
- pull
- git pull [repName] [repBranchName]
- How to check the unmerged files
- git diff --name-only --diff-filter=U
- git status
- How to deposite the code to a remote repository
- git push [repName] [localBranch]:[remoteBranch]
- How to create a tag
- anotate tag
- git tag -a v1.2 9fceb02
- git tag -a v1.0 -m message
- lightweight tag
- How to check the information of a tag
- git tag, list all tags
- git show [tagName]
- How to push tags to the remote repository
- git push origin [tagName], push a specific tag to the remote repository
- git push origin --tags, push all tags
- How to checkout a tag
- git checkout v1.0
- git checkout -b b_4
- How to alias a git command
- git config --global alias.unstage "reset HEAD --"
- git config --global alias.ls '!ls', alias an external command
- How to know the commit that HEAD points to
- gitg
- git log --graph --all --decorate
- git log --oneline --decorate
- How to show the web-based commit
- How to use github to collaborate with team members
- fork + pull request
- add collaborators to a repository
- organization
- What the README file should contain in github
- What the project is for
- How to configure and install it
- An example of how to use it or get it running
- The license that the project is offered under
- How to contribute to it
- How to list the files in the index
- How to list all commits in a branch
- git rev-list [branchName]
- How to show the HEAD commits of a branch
- git rev-parse [branchName]
- How to show the commit information of a specific commit
- git cat-file -p [commit or tag]
- How to check the reflog information
- How to relative refer a commit
- ^, the first parent of a commit
- ^^, the parent of the first parent of a commit
- ~n, the nth ancestor of the specific commit
- ^{type}, refer to an object type name
- [commit]:[fileNmae], refer to a specific file
- :n:[fileName], the nth staged file in the index
- What are object types in git
- blob, tree, commit, and tag
- How to figure out a range of commits
- git log origin/master..HEAD, all commits that are unreachable from origin/master but reachable from HEAD
- git log refA refB --not refC, reachable from refA and refB but not from refC
- git log master...experiment, reachable from either of them but not from both
- How to check when lines were introduced
- git blame -L 12,22 [fileName]
- What is submodule and how to use submodule to manage your project
- Sometimes, your project may contain several libraries. Each of those libraries is an individual project or third-party module. To keep each of those libraries indepent and cooprate with the main project, we use submodule to manage the project.
- Add a submodule to the main project
- git submodule add [repUrl]
- .gitmodules will be added in the main project
- .git/config will be updated
- the sub module folder will be taken as a special commit instead of a regular subdirectory or file
- Each submodule is indpendent from the main project, which has it own repository, instead of combining the content of main project and the content of submodule, the repository of the main project does not contain the content of the submodule
- Take each submodule as an indepent project, push all modules if changed before pushing the main project
- Clone a main project containing submodules
- git clone --recursive [repUrl]
- git submodule init, git submodule update, in the main project folder
- How to use bundle to tranfer repository
- git bundle create repo.bundle HEAD master
- git bundle verify repo.bundle
- git fetch repo.bundle [bundleBranch]:[localBranchName], fetch from a bundle
- git clone repo.bundle -b master, clone from a bundle
- How to setup github in Eclipse