Some git command.

 

// initial repository

$ git init

// information

$ git status
$ git log --stat

// before commit

$ git checkout -- [filename] ( give up edit, edited to unedit )
$ git add [filename]
$ git add .
$ git reset HEAD [filename] ( give up add, stage to unstage )

// commit

$ git commit -m '[message]'
$ git reset --soft HEAD^ ( give up commit )

// push/pull

$ git pull origin ( = fetch + merge )
$ git fetch origin
$ git push A B ( push A <- B )

// branch

$ git branch [branch name] ( add branch )
$ git checkout [branch name] ( move to branch )
$ git branch -D [branch name] ( force delete branch )

// merge

$ checkout A
+ $ merge B ( A -> B )

$ git merge B --no-ff ( commit log )

// SSL

$ export GIT_SSL_NO_VERIFY=true
$ git clone [.git url]

// remote

$ git remote show origin
$ git remote add origin [url]
$ git remote rename origin [new remote]
$ git push origin :[branch name] (delete remote branch)

$ git remote prune origin (update remote branch to local)
$ git remote set-url origin [url] (re-set origin)



// submodule

$ git submodule update --init --recursive (update submodule)
$ git submodule init
$ git submodule add [url] [path to submodule]

// revert

$ git revert [branch name] ( cancel branch action )


// Q&A

Q: pull origin error : 'origin' does not appear to be a git repository...
A: $ git remote add origin [url]
   $ git fetch origin


Q: git ssl certificate problem...
A: $ export GIT_SSL_NO_VERIFY=true
   $ git config --global http.sslverify false

相关文章