-
Notifications
You must be signed in to change notification settings - Fork 8
Git Commands
surmelienes1 edited this page Mar 7, 2022
·
3 revisions
Command Number | Explanation | Git Command |
---|---|---|
1 | We all have pressed the miss key while trying to run a command instantly at least one time before. To save our life, we can enable git autocorrection to directly fix the typos with the help of following command: | git config --global help.autocorrect 1 |
2 | We can count the number of commits in our branch-project with the command: | git rev-list --count |
3 | We can clear unreachable or orphaned git objects from the repository to optimize the use of git repositories, the following command does the job: | git gc --prune=now --aggressive |
4 | We may want to view a file of another branch while working on the current branch. Git has a super easy and practical command for this purpose. Example usage: | git show main:README.md |
5 | We can quickly search anything we want to find in a repo with the following example command: | git rev-list --all |
6 | If you want to test “commit” command without really committing something (for example to test the flow), you can use empty committing: | git commit --allow empty -m 'it works!' |
7 | You can compare commits with a simple command: git diff | git diff $start_commit..$end_commit -- path/to/file |
- The information in this table is credited to the Git Research done by Bahrican Yeşil.
- The sources used in this research are listed below:
- Configuring user information used across all local repositories
Git Task | Explanation | Git Command |
---|---|---|
Setup | Sets a name that is identifiable for credit when review version history | git config --global user.name “[firstname lastname]” |
Setup | Sets an email address that will be associated with each history marker | git config --global user.email “[valid-email]” |
Setup | Sets automatic command line coloring for Git for easy reviewing | git config --global color.ui auto |
- Configuring user information, initializing and cloning repositories
Git Task | Explanation | Git Command |
---|---|---|
Setup & Init | Initializes an existing directory as a Git repository | git init |
Setup & Init | Retrieves an entire repository from a hosted location via URL | git clone [url] |
- Working with snapshots and the Git staging area
Git Task | Explanation | Git Command |
---|---|---|
Stage & Snapshot | Shows modified files in working directory, staged for your next commit | git status |
Stage & Snapshot | Adds a file as it looks now to your next commit (stage) | git add [file] |
Stage & Snapshot | Unstages a file while retaining the changes in working directory | git reset [file] |
Stage & Snapshot | Diff of what is changed but not staged | git diff |
Stage & Snapshot | Diff of what is staged but not yet commited | git diff --staged |
Stage & Snapshot | Commits your staged content as a new commit snapshot | git commit -m “[descriptive message]” |
- Isolating work in branches, changing context, and integrating changes
Git Task | Explanation | Git Command |
---|---|---|
Branch & Merge | Lists your branches. a * will appear next to the currently active branch | git branch |
Branch & Merge | Creates a new branch at the current commit | git branch [branch-name] |
Branch & Merge | Switches to another branch and checks it out into your working directory | git checkout |
Branch & Merge | Merges the specified branch’s history into the current one | git merge [branch] |
Branch & Merge | Shows all commits in the current branch’s history | git log |
- Examining logs, diffs and object information
Git Task | Explanation | Git Command |
---|---|---|
Inspect & Compare | Shows the commit history for the currently active branch | git log |
Inspect & Compare | Shows the commits on branchA that are not on branchB | git log branchB..branchA |
Inspect & Compare | Shows the commits that changed file, even across renames | git log --follow [file] |
Inspect & Compare | Shows the diff of what is in branchA that is not in branchB | git diff branchB...branchA |
Inspect & Compare | Shows any object in Git in human-readable format | git show [SHA] |
- Versioning file removes and path changes
Git Task | Explanation | Git Command |
---|---|---|
Tracking Path Changes | Deletes the file from project and stage the removal for commit | git rm [file] |
Tracking Path Changes | Changes an existing file path and stage the move | git mv [existing-path] [new-path] |
Tracking Path Changes | Shows all commit logs with indication of any paths that moved | git log --stat -M |
- Preventing unintentional staging or commiting of files
Git Task | Explanation | Git Command |
---|---|---|
Ignoring Patterns | Saves a file with desired patterns as .gitignore with either direct string matches or wildcard globs. | logs /.notes pattern/ |
Ignoring Patterns | System wide ignore pattern for all local repositories | git config --global core.excludesfile [file] |
- Retrieving updates from another repository and updating local repos
Git Task | Explanation | Git Command |
---|---|---|
Share & Update | Adds a git URL as an alias | git remote add [alias] [url] |
Share & Update | Fetches down all the branches from that Git remote | git fetch [alias] |
Share & Update | Merges a remote branch into your current branch to bring it up to date | git merge [alias]/[branch] |
Share & Update | Transmits local branch commits to the remote repository branch | git push [alias] [branch] |
Share & Update | Fetches and merges any commits from the tracking remote branch | git pull |
- Rewriting branches, updating commits and clearing history
Git Task | Explanation | Git Command |
---|---|---|
Rewrite History | Applies any commits of current branch ahead of specified one | git rebase [branch] |
Rewrite History | Clears staging area, rewrites working tree from specified commit | git reset --hard [commit] |
- Temporarily storing modified, tracked files in order to change branches
Git Task | Explanation | Git Command |
---|---|---|
Temporary Commits | Saves modified and staged changes | git stash |
Temporary Commits | Lists stack-order of stashed file changes | git stash list |
Temporary Commits | Writes working from top of stash stack | git stash pop |
Temporary Commits | Discards the changes from top of stash stack | git stash drop |
- The information in this part is credited to the Git Research done by Ezgi Aysel Batı.
- The source used in this research is given below:
Group Members
Meeting Notes of 451
Mobile Team Meeting Notes
Back-End Team Meeting Notes
Front-End Team Meeting Notes
Meeting Notes of 352
- Meeting #1 (04.03.2022)
- Meeting #2 (10.03.2022)
- Meeting #3 (17.03.2022)
- Meeting #4 (24.03.2022)
- Meeting #5 (31.03.2022)
- Meeting #5.1 (02.04.2022)
- Meeting #5.2 (05.04.2022)
- Meeting #6 (07.04.2022)
- Meeting #6.1 (12.04.2022)
- Meeting #7 (14.04.2022)
- Meeting #8 (21.04.2022)
- Meeting #9 (01.05.2022)
- Meeting #10 (12.05.2022)
- Practice App Requirements
- Practice App Use Case Diagram
- Practice App Sequence Diagram
- Practice App API Documentation
CMPE451 Milestones
- Will be added when ready