Mesird

Git basic usage

basic

git status show status of current branch

git add make unstaged file staged (append filename)

git diff show what you’ve changed but not yet staged (append filename)

git commit commit staged files

git rm remove and stage this removal

git mv move or rename a file

git log viewing commit history

Option Description of Output
%H Commit hash
%h Abbreviated commit hash
%T Tree hash
%t Abbreviated tree hash
%P Parent hashes
%p Abbreviated parent hashes
%an Author name
%ae Author email
%ad Author date (format respects the —date=option)
%ar Author date, relative
%cn Committer name
%ce Committer email
%cd Committer date
%cr Committer date, relative
%s Subject

author is the person who modifies the file, committer is who make the commit

config

git config –global user.username show or modify git global username

git config –global user.email show or modify git global email

git config –global core.editor change git editor (vim or emacs)

git config –global alias.co checkout using co to replace checkout, e.g. git co

branching

git branch show local branch list

git checkout [branch-name] switch to the particular branch, this command will move HEAD pointer to the current branch

git merge [branch-name] merge the particular branch to current branch

git mergetool open a visual conflict resolving tool

git ls-remote [remote-name] show full list of remote references