└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # GitCommands 2 | 3 | ####Here is a list of some basic Git commands to get you going with Git 4 | 5 | ### Create 6 | 7 | - Create a new local repository 8 | - `git init` 9 | - Clone an existing repository 10 | - `git clone [your_repository_url] ` 11 | 12 | ### Track chages 13 | 14 | - File status about local repository 15 | - `git status` 16 | - Chages to remote[tracked] files 17 | - `git diff [source_branch] [target_branch]` 18 | 19 | ### Add file 20 | 21 | - Add all changes in commit 22 | - `git add .` 23 | - Add single file in commit 24 | - `git add -p [your_file_name]` 25 | 26 | ### Commit file 27 | 28 | - Commit previously chaged file 29 | - `git commit` 30 | - Commit all local changes 31 | - `git commit -a` 32 | - Add single file in commit 33 | - `git add -p [your_file_name]` 34 | - Amending the most recent commit message in editor 35 | - `git commit --amend` 36 | - Amending the most recent commit message with new message 37 | - `git commit --amend -m "New commit message"` 38 | 39 | ### See history 40 | 41 | - See all commit log details 42 | - `git log` 43 | - See commit log details about single file 44 | - `git log -p [your_file_name]` 45 | - Only the commits of a certain author 46 | - `git log --author=[author_name]` 47 | - Compressed log in one line: 48 | - `git log --pretty=oneline` 49 | - Log details only for changes files 50 | - `git log --name-status` 51 | 52 | ### Command for branch 53 | 54 | - See all branch 55 | - `git branch -av` 56 | - Switch exisiting branch 57 | - `git checkout [your_branch_name]` 58 | - Create new local branch and switch to new branch 59 | - `git checkout -b [your_branch_name]` 60 | - Delete a local branch 61 | - `git branch -d [your_branch_name]` 62 | - Delete a remote branch 63 | - `git branch -dr [your_branch_name]` 64 | - Add tag on current commit 65 | - `git tag [your_tag_name]` 66 | 67 | ### Remote 68 | 69 | - See all remote repository url 70 | - `git remote -v` 71 | - See info about remote repository 72 | - `git remote show [remote_repository_url]` 73 | - Add remote repository 74 | - `git remote add [remote_repository_url]` 75 | - Fetch all branch structure from remote 76 | - `git fetch` 77 | 78 | ### pull 79 | 80 | - Fetch all changes from remote directory 81 | - `git pull` 82 | - `git pull [remote] [branch]` 83 | 84 | ### push 85 | 86 | - Fetch all changes from remote directory 87 | - `git push` 88 | - `git push [remote] [branch]` 89 | - Publish your tags 90 | - `git pull --tags` 91 | 92 | ### merge 93 | 94 | - Merge branch into your current HEAD 95 | - `git merge [your_branch_name]` 96 | - Solve conflics using mergetool 97 | - `git mergetool` 98 | 99 | ### rebase 100 | 101 | - Rebase with HEAD branch 102 | - `git rebase [your_branch_name]` 103 | - Continue rebase after resolving conflicts 104 | - `git rebase --continue` 105 | - Abort rebase 106 | - `git rebase --abort` 107 | 108 | ### reset 109 | 110 | - Discard all changes in your local branch 111 | - `git reset --hard HEAD` 112 | - Discard local branch changes for single file 113 | - `git checkout HEAD [your_file_name]` 114 | - Revert specific commit 115 | - `git revert [commit_hash]` 116 | - Reset your local branch with specific commit forcefully and discard local changes 117 | - `git reset --hard [commit_hash]` 118 | - Reset your local branch with specific commit and discard local changes 119 | - `git reset [commit_hash]` 120 | 121 | - Use colorful git output 122 | - `git config color.ui true` 123 | 124 | 125 | ## References 126 | 127 | - https://help.github.com/ 128 | - https://git-scm.com/doc 129 | --------------------------------------------------------------------------------