Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. Install /Set up GIT
  2.  
  3. sudo apt-get install git # for debian\ubuntu users
  4. brew install git # for Mac users with Homebrew install
  5.  
  6. Tell git who you are i.e Git username setting for every repository on your computer
  7.  
  8. git config --global user.email "abc@example.com"
  9. git config --global user.name "your name"
  10.  
  11. git config --global user.name . #confirm user
  12.  
  13. Setting your Git username for a single repository
  14. Open Terminal.
  15. Change the current working directory to the local repository where you want to configure the name that is associated with your Git commits.
  16. Set a Git username:
  17.  
  18. $ git config user.name "vivek singh"
  19. Confirm that you have set the Git username correctly:
  20.  
  21. $ git config user.name
  22. > vivek singh
  23.  
  24. git config --list #to return list of all user.
  25.  
  26. ~/.gitconfig #look for git config file
  27.  
  28. ~/.gitignore #look for git ignore
  29.  
  30. git config --global color.ui true #To add command to git terminal
  31.  
  32. Git:starting a repository
  33. git init
  34. git status
  35. git add . # add all files
  36. git rm --cached my-file.ts #to remove files from staging area
  37. git reset <file-name>
  38.  
  39. commiting changes to git
  40. git commit -m "comment details"
  41. git commit -a -m "Do something once more" #add modified file and comment them
  42.  
  43. how can you modify a file if you've already committed it?
  44. git reset --soft HEAD^
  45.  
  46. Instead of resetting the HEAD and undoing the last commit, we can rectify a commit by using the "--amend" option when committing to a repository. Just add the remaining file to the staging area and then commit:
  47.  
  48. $ git add file-i-forgot-to-add.html
  49. $ git commit --amend -m "Add the remaining file"
  50.  
  51. #pulling anf pushing from and to repository
  52. git clone <clone>
  53. git pull
  54. git push -u origin master
  55. git remote add origin <link>
  56.  
  57. #git commands for working woth branches
  58. git branch
  59. git branch branch-name #to add new branch
  60. git checkout branch-name
  61. git merge branch-name
  62. git branch -d branch-name
  63.  
  64. git checkout -b development #create and switch to new branch
  65.  
  66. git log #to check all commits in repository
  67.  
  68. git show
  69. Usage: git show [commit]
  70. This command shows the metadata and content changes of the specified commit.
  71.  
  72. git checkout -- #which will checkout all the modified files
  73.  
  74. git reset --hard HEAD #to get rid of all the modifications made to tracked files made so far
  75. // or
  76. git reset --hard
  77.  
  78. git stash #alternate to above reset command
  79. git stash will revert all the files to their previous version but whatever changes were made to these files will be saved in the stash list. This log can be seen using git stash list command.
  80.  
  81. git stash apply stash@{0}
  82.  
  83. git stash save #This command temporarily stores all the modified tracked files.
  84. git stash pop #This command restores the most recently stashed files.
  85. git stash list #This command lists all stashed changesets.
  86. git stash drop #This command discards the most recently stashed changeset.
  87.  
  88. git clean -f -d #lots of untracked files or folders in the repository which you want to remove
  89.  
  90. git revert commitno #to revert committed files
  91. git revert commitno --no-edit
  92.  
  93. git diff #git difference between two commits.
  94.  
  95. git command Alias
  96.  
  97. git add -A && git commit -m "new changes"
  98. You can make an alias to this command in the Git using command below.
  99.  
  100. git config --global alias.c "!git add -A && git commit -m"
  101. This will create a global alias c for command git add -A && git commit -m. Now you can use the command below
  102.  
  103. git c "new changes"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement