git clone <remote_location> <clone_name> - Create a duplicate (clone) of remote_location and locally call it clone_name
git remote -v - Display a list of Git project remotes
git fetch - Bring changes in remote master down to origin/master branch (not my local master branch)
git merge origin/master - Bring changes in origin/master branch into my local master branch
Workflow:
- Fetch and merge changes from remote
git fetch
git merge origin/master
- Create branch to work on new stuff
git branch <my_new_branch>
- Work on stuff in my branch and then commit work
git checkout <my_new_branch>
vi mychange.txt
git add mychange.txt
git commit -m "My message"
- Fetch and merge from remote again
git fetch
git merge origin/master
- Push my branch up to the remote for review
git push origin <my_new_branch>
[Edit]
The excellent Mark Moser suggests the following shortcut:
git pull
Instead of:
git fetch
git merge origin/master
[/Edit]
Wednesday, September 28, 2016
Git - branches
git branch - Which branch am I on?
git branch <new_branch> - Create a new branch
git checkout <branch_name> - Switch to different branch
git merge <branch_name> - Merge branch_name into my current branch?
git branch -d <branch_name> - Delete the branch no longer needed
git branch <new_branch> - Create a new branch
git checkout <branch_name> - Switch to different branch
git merge <branch_name> - Merge branch_name into my current branch?
git branch -d <branch_name> - Delete the branch no longer needed
Tuesday, September 27, 2016
Git refresher
git init - Initializes my directory for a Git project
Git project has three parts:
1 - Working Directory - Where I create, edit, delete, and organize files
2 - Staging Area - Where I list changes I make to the working directory
3 - Repository - Where Git permanently stores those changes as different versions of the project
git status - Check status of changed files
git add filename - Adds file to Git project so Git watches for changes
git add filename1 filename2 - Add multiple files to Git project
git diff filename - Identifies changes within the file
git commit -m "Message describing commit"
git log - View log of commits
git show HEAD - Displays the message for the HEAD commit plus all the file changes that were committed.
HEAD = The commit I am currently on
git checkout HEAD filename - Revert filename back to the HEAD commit
git reset HEAD filename - Unstage (reset) filename from staging area.
Useful for when I accidentally added a file to the staging area and do not want to commit it.
get reset <SHA> - Rewind back to commit identified by SHA value. SHA value is first 7 characters.
SHA values can be seen in the git log (use "git log" to view)
Git project has three parts:
1 - Working Directory - Where I create, edit, delete, and organize files
2 - Staging Area - Where I list changes I make to the working directory
3 - Repository - Where Git permanently stores those changes as different versions of the project
git status - Check status of changed files
git add filename - Adds file to Git project so Git watches for changes
git add filename1 filename2 - Add multiple files to Git project
git diff filename - Identifies changes within the file
git commit -m "Message describing commit"
git log - View log of commits
git show HEAD - Displays the message for the HEAD commit plus all the file changes that were committed.
HEAD = The commit I am currently on
git checkout HEAD filename - Revert filename back to the HEAD commit
git reset HEAD filename - Unstage (reset) filename from staging area.
Useful for when I accidentally added a file to the staging area and do not want to commit it.
get reset <SHA> - Rewind back to commit identified by SHA value. SHA value is first 7 characters.
SHA values can be seen in the git log (use "git log" to view)
Thursday, September 22, 2016
Powershell - Read SQL Log
Import-Module SQLPS -DisableNameChecking
$server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList "serverName"
# ReadErrorLog() returns a dataTable object
$d = $server.ReadErrorLog()
foreach ($r in $d.Rows)
{
Write-Host "============================"
Foreach ($c in $d.Columns)
{
Write-Host $c.ColumnName "=" $r[$c]
}
}
---
ReadErrorLog(#)
If you provide a number, it reads that particular SQL log number. (Eg - SQL log numbers 1 through 6).
$server = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList "serverName"
# ReadErrorLog() returns a dataTable object
$d = $server.ReadErrorLog()
foreach ($r in $d.Rows)
{
Write-Host "============================"
Foreach ($c in $d.Columns)
{
Write-Host $c.ColumnName "=" $r[$c]
}
}
---
ReadErrorLog(#)
If you provide a number, it reads that particular SQL log number. (Eg - SQL log numbers 1 through 6).
Labels:
PowerShell,
SQL
Subscribe to:
Posts (Atom)