Last active
September 28, 2015 19:38
-
-
Save linktoming/1486599 to your computer and use it in GitHub Desktop.
Git Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. To Setup Git: | |
$git --version | |
$git config --global user.name "Your Name" | |
$git config --global user.email "Your Email Address" | |
$git config --global color.ui "auto" | |
$git config --global alias.co checkout | |
$git config --global core.editor "mate -w" | |
2. To Generate SSH Key for SSH Connection: | |
$ssh-keygen -t rsa -C"mingofdlut@gmail.com" | |
2.1 To Check the SSH Key: | |
$cd ~/.shh | |
$ls | |
3. To create repository and commit | |
$mkdir newproject | |
$cd newproject | |
$git init | |
$touch Readme.txt | |
$git status | |
$git add Readme.txt | |
$git status | |
$git commit -m'this is a comments or message for the commitment' | |
$git commit -a -m'add to stage and commit for edition, insertion and some other modifications' | |
4. Add changes | |
4.1 Add addition & modification of files | |
$git add . | |
4.2 Add deletion of files | |
$git add . -A | |
5. Clone, Pull and Push a Repository (through SSH, HTTP, GIT, FILE) | |
$git clone git://github.com/matthewmccullough/hellogitworld.git | |
$git pull branchname | |
$git fetch branchname | |
$git merge branchname/master | |
$git push origin master | |
$git push origin localbranch | |
6. Check the log | |
$git log | |
$git log --pretty=oneline | |
$git log 6c0d1 | |
$git log 6c0d1..edsfc | |
$git log 6c0d1^..6c0d1 | |
$git log 6c0d1^^^..6c0d1 | |
$git log 6c0d1^^^..6c0d1 | |
$git log head | |
$git log head^^^..head | |
7. Some useful command | |
7.1 Show last commit's detail | |
$git show | |
$git log head^^^..head -p | |
$git diff | |
8. Branch | |
$git branch mybranch | |
$git checkout mybranch | |
$git checkout -b mybranch | |
$git checkout master | |
$git checkout mybranch | |
$git checkout master | |
$git merge mybranch | |
$git branch -d mybranchToBeDelete | |
$git branch | |
$git branch -a | |
$git branch --set-upstream rrrtim origin/rrrtim | |
$git checkout 6fa10e46556a6 | |
$git branch name | |
$git checkout -b branchname 6fa10e46556a6 | |
8.1 Merge Branch | |
$git push | |
$git branch -d aBranch | |
$git merge origin/aRemoteBranch | |
$git push origin master | |
8.2 Delete Remote Branch | |
$git push origin :square_video_test | |
9. Git remote | |
$git remote | |
$git remote add anotherAccess https://git.....git | |
$git remote -v | |
10. Tagging | |
$git tag TagName | |
$git push --tags | |
$git tag -a TagName | |
$git checkout TagName | |
11. Remove file from being tracked (after this, add the file to .gitignore) | |
$ git rm --cached ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate | |
$ git commit -m "Removed file that shouldn't be tracked" | |
12. Rollback to last commit | |
$ git reset --hard HEAD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment