Showing posts with label version control. Show all posts
Showing posts with label version control. Show all posts

11.13.2013

Perforce Cheat Sheet

1. New client spec for workspace
$ p4 client
2. Populate workspace with files from server
$ p4 sync
$ p4 sync * - only files from current dir
$ p4 sync ... - current path, all folders and files underneath
$ p4 sync -f filename - force the sync, override no clobber (lose all local changes)
$ p4 sync @490807 - sync to changelist number
$ p4 sync @=490807 - sync only the files revised within that changelist
3. Check out a file for edit
$ p4 edit filename
4. See checked out files
$ p4 opened
$ p4 have filename - what version you have
$ p4 filelog filename - check history
5. View local changes
$ p4 diff
$ p4 diff filename | p4c.rb - colored diff
$ p4 diff -db filename - disregard whitespace
$ p4 diff -t filename - even though files aren't text
6. Create new changelist
$ p4 change
$ p4 change -u changelist_number - update submitted changelist
7. Add files for addition to the depot
$ p4 add
$ p4 add -c change_number -f filenames - add files to changelist
$ p4 add -f filenames - add files to default changelist
$ p4 add -c change_number * */* - add files in current dir and next dir to default changelist
$ "find . -type f | p4 -x - add" - cmd inside quotes would find all files in a directory structure and add them all in
8. Get info about a changelist, listing files that are included
$ p4 describe change_number
9. Get a list of your changes
$ p4 changes -u username
$ p4 changes -u username -s pending
10. Discard changes made to open files
$ p4 revert -c change_number - reverts only those files in the specified changelist
$ p4 revert filename - reverts only this file
11. Submit changes for code review
$ /auto/tools/bin/post-review change_number
12. Checkin your changes
$ p4 submit
$ p4 submit -c change_number
13. Delete pending changelist
$ p4 changes -u username -s pending
$ p4 revert -c 12345 //... - revert all files in my pending changelist 12345
$ p4 change -d 12345 - delete the now-empty changelist
14. Print detailed information about file revisions.
$ p4 filelog filename
15. Add opened files to a specific changelist
$ p4 reopen -c 431494 */*
16. Get specific change information
$ p4 changes //prod/main/...\@445029,445029
Change 445029 on 2014/08/10 by sdc@main:sdc 'Integrate change 444241 from 5.'
17. Move (or rename) a file from one location to another
$ p4 move deploy/deploy_change util/deploy_change
18. Move a directory
$ p4 edit 5.5/*/baseline.xml
$ p4 move 5.5/... 5.5_old/...
18. Take a peek at the branches available
$ p4 branches | grep "5\.6\.0"
19. Delete file
$ p4 delete filename
20. Change file type into executable
$ p4 edit -t +x watchdog

11.11.2013

Git Cheat Sheet

1. Initial git configuration
$ git config --global --add user.name "Sam Dela Cruz"
$ git config --global --add user.email "samdc@mail.com"
2. Verify configuration
$ git config --global --list
user.name=Sam Dela Cruz
user.email=samdc@mail.com
3. Tell git which files are not be be version controlled
$ vi .gitignore
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/log/*.log
/tmp
4. Initialize repository
$ git init
5. Add all files
$ git add .
6. Commit
$ git commit -m "Project Scaffold"
============
Searching
============

1. History of code changes...
$ git log -L :start_perfcloud_run:./api/api/orchestrator/tasks/job_tasks.py

3.18.2013

PowerShell Script that removes VSS bindings and files from a Visual Studio Project

Below is a powershell script I found from the web that I have been using for a while to remove the bindings from SourceSafe.

First, unbind the project from VSS within Visual Studio, then run this script.
# This script removes VSS bindings and files from a VS Project
# Taken from http://blog.magenic.com/blogs/daniels/archive/2008/11/18/Removing-VSS-Bindings-to-Migrate-SSRS-2005-Solutions-to-TFS-Using-Powershell.aspx

# First thing to do before running this script is to specify where the project is located
$Folder = "C:\dev\vs\2008\SalesSync"
#first clear the read-only flag from all files
get-childitem "$folder" -Recurse | % {         
        # Test for ReadOnly flag and remove if present 
     if ($_.attributes -band [system.IO.FileAttributes]::ReadOnly) {  
            $_.attributes = $_.attributes -bxor [system.IO.FileAttributes]::ReadOnly 
   }
}

#next delete all files that are *.suo, *.user, and *.*scc - we don't want them in TFS
Get-ChildItem  $folder *.suo -Recurse -Force | Remove-Item -Force
Get-ChildItem  $folder *.*scc -Recurse -Force | Remove-Item -Force
Get-ChildItem  $folder *.user -Recurse -Force | Remove-Item -Force

#next get all the .sln file - and remove the VSS binding information
$files = Get-ChildItem $folder *.sln -Recurse 
foreach ($file in $files) {
 $fileout = $file.FullName + ".new"
 Set-Content $fileout $null
 $switch=0
 Get-Content $file.FullName | % {
  if ($switch -eq 0) {
   if ($_  -eq " GlobalSection(SourceCodeControl) = preSolution") {
    #we found the section to skip - so set the flag and don't copy the content
    $switch=1}
   else {
    #we haven't found it yet - so copy the content
    Add-Content $fileout $_
   }        
   }
  elseif ($switch -eq 1) {
   if ($_ -eq " EndGlobalSection") {
    #last line to skip - after it we start writing the content again
    $switch=2}
   }
  else 
   { #write remaining lines
    Add-Content $fileout $_}
 }
 #remove the original .sln and rename the new one
 $newname = $file.Name
 Remove-Item $file.FullName
 Rename-Item $fileout -NewName $newname
}