Skip to content

Latest commit

 

History

History
77 lines (67 loc) · 2.32 KB

Github_Tips.org

File metadata and controls

77 lines (67 loc) · 2.32 KB

Github Tips

add File

git add Name

edit and Push

Directly Edit local file then commit, push.

How to know where I am

change last commit without new push

  • Change last push

git add . git commit –amend git push –force branch

delete Remote Item

git rm –cache Name

get Newest Edition from Web

git fetch origin

push Branch

  • git push origin wil_sws

overwrite one branch to another

  • Stackoverflow
  • For example, branch email and staging, copy everything in staging to email and overwrite it.

$ git checkout email $ git tag old-email-branch # this is optional $ git reset –hard staging $ git merge -s ours origin/email $ git push origin email

ignore everything but …

# Ignore everything
*
# but
!script.pl
!.gitignore

delete branch

  • git branch -d <branch_name>
  • git push origin –delete <branch_name> (or git push origin :<branch_name>)

roll back

  • git reflog show (find revision hash)
  • git checkout <revision> .

undo a commit

  • git reset –hard HEAD^1
  • edit & commit or
    • git rm –cached badfile
  • edit & git commit –amend

manually merge

  • git pull (will auto merge unconflict parts)
  • edit conflict file (edit file with <<< >>> )
  • git add & commit

delete remote file

  • git rm –cached ‘merge-*’ : delete remote file start with merge-
  • git commit & push

about git commit -a

  • ‘-a’ will auto add the modified file which was git add before

but for new file, we have to add, or create alias

git reset

Tags

  • list all tags git tag -l

repo rename

  • git remote set-url origin new_url