Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git cmd #13

Open
etaf opened this issue Aug 17, 2014 · 0 comments
Open

git cmd #13

etaf opened this issue Aug 17, 2014 · 0 comments

Comments

@etaf
Copy link
Owner

etaf commented Aug 17, 2014

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:

$ git rm --cached file

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:

$ git fetch origin

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant