FANDOM


References

command description remark
git-clone
git-status
git-add
git-commit
git-push
git-pull
git-log Show commit logs git log master -3
git-branch List, create, or delete branches
git-tag Create, list, delete or verify a tag object signed with GPG
git-remote Manage set of tracked repositories
git-checkout Switch branches or restore working tree files
git-diff Show changes between commits, commit and working tree, etc
git-rebase Reapply commits on top of another base tip
git-reset --hard Resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded.
git-clean Remove untracked files from the working tree
git-config Get and set repository or global options git config --get core.autocrlf
git config core.autocrlf false
gitignore ($HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore)

Readings

Revision

Status

Remote

Branch

Checkout

Tag

Subtree

Diff

Workflow

Tools

Typical Usage

Adding new items, committing and pushing them

$ git status .                    // identifies added, modified or untracked items under current local directory
$ git add .                       // updates index
$ git status .                    // confirms the changes to be committed
$ git commit -m "message ..."     // commits changes into local repository
$ git status .                    // confirms all changes are committed
$ git push                        // pushes changes in local repository onto the remote repository

When the HEAD of 'origin/master' has changed since the last sync, '$ git push' would fail with messages including fast-forwards. Then,

$ git pull --rebase
...
may need manual merge.
...
$ git push

Working with remote repositories

$ git remote -v          // lists tracking repositories
$ git remote add upstream https://github.com/jpmorganchase/quorum.git     // add a new remote repository to track
$ git branch -r          // lists branches in tracking repositories

Working with branches or tags

$ git branch                                 // lists branches
$ git branch -a                              // lists both local and remote-tracking branches
$ git branch -avv                            // lists all branches showing hash and upstream branch if any
$ git tag                                    // lists tags
$ git branch 2.0.2-ext v2.0.2                // creates a new branch(2.0.2-ext) from a tag(v2.0.2)
$ git checkout release-1.1                   // updates working tree to release-1.1
$ git checkout -b gh-pages origin/gh-pages   // copies remote branch to local repository
$ git push origin advanced:advanced          // creates remote branch 'origin/advanced' from local branch 'advanced'
$ git push origin --tags                     // pushes all local tags to remote 'origin'

Tracking changes

$ git log master -3                          // lists 3 recent commits for master branch
$ git log v2.0.2 -3                          // lists 3 last commits before the tag of 'v2.0.2'
$ git log origin/master -1                   // lists last commit of remote branch 'origin/master'
$ git log upstream/master -1                 // lists last commit of remote branch 'upstream/master'

Removing uncommitted changes on tracked files in the working tree

$ git reset --hard          // resets the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded.

Removing untracked files and directories in the working tree

$ git clean -ndx          // -n: dry run, -d: directory also, -x: skip gitignore
...
$ git clean -ffdx         // -ff: force including files manged by different Git repository
...

For more, refer

Removing committed changes

@TODO

Creating and pushing tag

$ git tag -a v1.0 -m "Ready to offer externally"
...
$ git push origin v1.0
...

Companions

GitHub

GitHub Pages

EGit

Gitorious

  • Desc : Git hosting and collaboration software that you can install yourself
  • License : GNU Affero General Public License

GitLab

Gogs