Contenu connexe Similaire à Git, A Primer Similaire à Git, A Primer (20) Git, A Primer6. VERIFYING REMOTES (SOURCE)
View remote props
$ git remote v
origin git@mygitserver.com:platform (fetch)
origin git@mygitserver.com:platform (push)
$ git remote show origin
* remote origin
Fetch URL: git@mygitserver.com:platform
Push URL: git@mygitserver.com:platform
HEAD branch: master
Remote branches:
development tracked
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
7. CHECKOUT REMOTE BRANCH
View remote branches
$ git branch r
origin/HEAD > origin/master
origin/development
origin/master
Check-out remote branch 'development'
$ git branch
* master
$ git checkout development
Switched to a new branch 'development'
$ git branch
* development
master
$ git status
on branch development
nothing to commit, working directory clean
9. ADD FILES TO STAGING AREA
Adding files
$ git add .
$ git add A
$ git add all
$ git add js/*.js
$ git add *.txt
Diff
$ git diff
$ git diff staged
12. VIEW COMMIT HISTORY
default log view
$ git log
commit ca82a6dff817ec66f44342007202690a93763949
Author: Praveen Chamarthi [praveenc@netmail.com]
Date: Tue Mar 12 21:52:11 2015 0700
changed the version number
detailed log
$ git log p 1
commit a4ef8f2c37c0408b7c69f66f95c796ea64e4bbaf
Author: debug [debug@netmail.com]
Date: Wed May 13 13:36:11 2015 0400
added readme.txt
diff git a/readme.txt b/readme.txt
new file mode 100644
index 0000000..709087a
/dev/null
+++ b/readme.txt
@@ 0,0 +1 @@
+thiasdfkajsdfadfl;asdfa
13. SYNC CHANGES WITH SERVER
Push & Pull
$ git push (push to remote repo)
$ git fetch (fetch only, no merge)
$ git pull (git fetch + git merge)
git pull = git fetch + git merge
14. GIT BRANCHING
Checkout a remote branch
View remote branches
$ git branch r
origin/HEAD > origin/master
origin/development
origin/master
Checkout remote branch
$ git checkout [branchname]
E.g.
$ git checkout development
15. GIT BRANCHING
Working with local branches
$ git checkout development
$ git branch
* development
master
create local branch using -b flag
$ git checkout b NM3435
Switched to a new branch 'NM3435'
$ git branch
* NM3435
development
master
16. GIT BRANCHING
Merging local branch to upstream branch
$ git checkout development
Switched to branch 'development'
$ git pull
Updating development
Fastforward
$ git merge NM3435
Updating 9e11133..a4ef8f2
Fastforward
readme.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 readme.txt
Deleting a local branch
$ git branch d NM3435
Deleted branch NM3435 (was a4ef8f2).
18. GIT TAGS
Checking out a Tag
$ git checkout tags/5.4.0_HP2
$ git branch a
* (detached from 5.4.0_HP2)
master
remotes/origin/HEAD > origin/master
remotes/origin/develop
remotes/origin/master
$ git checkout b HP2_Fix
Switched to new branch 'HP2_Fix'