push local code to new created repo
$ git init
$ vim .gitignore
$ git add -A
$ git commit -m "init"
$ git remote add origin https://etaf@github....
$ git push origin master
remote file from git repo
$ git rm file
$ git rm -r dir
added but not commit, rm file added:
force replace local code with server code:
$ git reset --hard
$ git pull origin master
cheate a new branch and switch to it:
$ git checkout -b branch-name
push local branch to remote server:
$ git push origin branch-name
fetch remote branch from remote server:
replace local branch with server branch:
$ git reset --hard HEAD~3 # HEAD~3 means rollback 3 commit versions
$ git pull
if you make a mistake when using: git reset --hard , then the commits before it would lose(see git log), how to recover them ?
$ git reflog
$ git reset --hard <sha>