Total Pageviews

2016/08/09

[Git] Frequently Used Command

1. how to show file change list?
 
 
 
 
 
 
 
 
 
albert@albert-PC MINGW64 /d/git/issue-webapp (master)
$ git status
On branch master
Your branch is behind 'origin/master' by 6 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   src/app/journal/journal.list.component.ts
        modified:   src/app/journal/journal.list.html


2. How to create a branch from master? (given your branch name after -b)

albert@albert-PC MINGW64 /d/git/issue-webapp (master)
$ git checkout -b fix#165468
       src/app/journal/journal.list.component.ts
       src/app/journal/journal.list.html
Switched to a new branch 'fix#165468'


3. How to discard changes? (assign the file path after git checkout)

albert@albert-PC MINGW64 /d/git/issue-webapp (fix#165468)
$ git checkout  src/app/journal/journal.list.component.ts


4. How to change from my local branch to master?


albert@albert-PC MINGW64 /d/git/issue-webapp (fix#165468)
$ git checkout master


5. How to add all changed files and commit to local? (remember to add comments as you do commit)
albert@albert-PC MINGW64 /d/git/issue-webapp (fix#165468)
$ git add --all

albert@albert-PC MINGW64 /d/git/issue-webapp (fix#165468)
$ git commit -m 'fix #165468'
[fix#165468 dbec729] fix #165468
 2 files changed, 25 insertions(+), 5 deletions(-)


6. How to push commits made on your local branch to a remote repository? (assign your branch name after origin)
 albert@albert-PC MINGW64 /d/git/issue-webapp (fix#165468)
$ git push origin fix#165468


7. How to synchronize my local repository with remote repository?
albert@albert-PC MINGW64 /d/git/issue-webapp (master)
$ git pull --rebase upstream master
From https://github.com/ChunghwaTelecom/issue-webapp
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> upstream/master
First, rewinding head to replay your work on top of it...
Fast-forwarded master to b393bd26111dbe2335bf1fb5d9cf3cb110c278ca.


8. How to list values of all configuration? 

albert@albert-PC MINGW64 /d/git/issue-webapp (master)
$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true


9. 
How to configure remote.upstream.url to https://gitlab.com/ChunghwaTelecom/rakr-chrome-extension.git ?
albert@albert-PC MINGW64 /d/git/issue-webapp (master)
$ git config remote.upstream.url https://gitlab.com/ChunghwaTelecom/rakr-chrome-extension.git


10. Check commit history 
git log --pretty=oneline -10




No comments: