-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3aab3e
commit 574ee38
Showing
1 changed file
with
10 additions
and
19 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,8 +79,7 @@ git clone https://github.com/praqma-training/git-katas.git # Clone this rep | |
# Git (user and repo level) configurations | ||
git config --local user.name "Repo-level Username" # For setting a local git repo level user name. | ||
git config --local user.email "[email protected]" # For setting a local git repo level user email. | ||
# --system -> System level git config stored in /etc/gitconfig | ||
# --global -> User level git config stored in ~/.gitconfig | ||
# --global -> User level git config stored in <user-home>/.gitconfig for e.g. ~/.gitconfig | ||
# --local -> repo level config stored in repo's main dir under .git/config | ||
|
||
|
||
|
@@ -100,9 +99,7 @@ git commit -a # Make a new commit and automatically "a | |
git commit -am "I still do!" # A combination of the above | ||
git commit --amend # Re-do the commit message of the previous commit (don't do this after pushing!) | ||
# We _never_ change "public history" | ||
|
||
git reset <commit_hash> # Undo all commits after <commit_hash> (local changes are preserved) | ||
git reset --soft <file> # Unstage a staged file leaving in working directory without losing any changes. | ||
git reset --soft [commit_hash] # Unstage a staged file leaving in working directory without losing any changes. | ||
# --hard mode would discard all changes to given file. | ||
|
||
# Configuring a different editor | ||
|
@@ -116,31 +113,20 @@ git reset --soft <file> # Unstage a staged file leaving in worki | |
- or for instance Notepad++: | ||
`git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"` | ||
|
||
# Re/moving files under version control | ||
git rm <path/to/the/file> # remove file and stage the change to be committed. | ||
git mv <source/file> <destination/file> # move/rename file and stage the change to be committed. | ||
|
||
|
||
# See history | ||
git log # Show commit logs | ||
git log --oneline # Formats commits to a single line (shorthand for --pretty=oneline --abbrev-commit ) | ||
git log --graph # Show a graph commits and branches | ||
git log --pretty=fuller # To see commit log details with author and committer details, if any different. | ||
git log --follow <file> # List history of given file. | ||
git log branch2..branch1 # Show commits present on branch1 compared to branch1 | ||
git log --follow <file> # List the history of a file beyond renames | ||
git log branch2..branch1 # Show commits reachable from branch1 but not from branch2 | ||
|
||
# Deferring | ||
git stash # Stash (store temporarily) changes in working branch and enable checkingout a new branch | ||
git stash list # List stored stashes. | ||
git stash apply <stash> # Apply given <stash>, or if none given the latest from stash list. | ||
|
||
# Tagging | ||
|
||
|
||
git tag # List tags | ||
git tag -l "name*" # List tags that are named <name> | ||
git tag -a "v1.0" -m "comment - v1.0" # Creating annotated tag that creates checksum for the commit including verbose tagger details. | ||
git tag -d "v1.0" # Delete given tag in local repo | ||
|
||
# Working with Branches | ||
git branch my-branch # Create a new branch called my-branch | ||
|
@@ -157,9 +143,14 @@ git rebase master # Rebase current branch on top of master branch | |
git remote # Show your current remotes | ||
git remote -v # Show your current remotes and their URLs | ||
git push # Publish your commits to the upstream master of your currently checked out branch | ||
git push -u origin my-branch # To push newly created branch to remote repo. | ||
git push -u origin my-branch # Push newly created branch to remote repo setting up to track remote branch from origin. | ||
# No need to specify remote branch name, for e.g., when doing a 'git pull' on that branch. | ||
git pull # Pull changes from the remote to your currently checked out branch | ||
|
||
# Re/moving files under version control | ||
git rm <path/to/the/file> # remove file and stage the change to be committed. | ||
git mv <source/file> <destination/file> # move/rename file and stage the change to be committed. | ||
|
||
# Aliases - it's possible to make aliases of frequently used commands | ||
# This is often done to make a command shorter, or to add default flags | ||
|
||
|