Useful GIT commands

Useful Git commands

Use caseCommandComment/Explanation
Download (clone) a remote GIT respositorygit clone [URL]This command does not clone sub-modules.

Example: git clone git@github.com:perthi/productivity.git
Download (clone) a remote GIT repository including all sub-modulesgit clone [URL] -b [branch] --recursiveClones everything including sub-modules.

Example: git clone git@github.com:perthi/logmaster.git -b master --recursive
Merge a feature branch into your development branch# git checkout develop
# git merge feature/myfeature
This assumes that you have renot branch called origin/feature/myfeature that is checked out locally
Check out an track a remote branchgit checkout --track origin/feature/myfeature
# This will checkout the remote feature branch *feature/myfeature* of the origin and track it. The name of the local branch will be *feature/myfeature*
Merge a feature branch into your development branch and squash all commits on the feature branch into a single commit on the development branch# git checkout develop
# git merge --squash feature/myfeature
Commit all changes and a add a commit message from the command linegit commit -a -m "commit message"
Push all local commits to the remote repository (origin)git push
Update your local repository with changes in the remote repositorygit pull
Failed merge: You have just done a merge that failed an regret it dearlygit reset --hard HEAD
This only works if the you have not yet pushed your changes to the remote
Remove branches that is still present in your local repo after they have been removed from the remote#git remote prune origin
#git branch -D mybranch ... X times

Delete a local branch # git branch -d
# git branch -D
The D (capital) option deletes the branch forcefully, i.e even if it is not fully merged.
Create a local branch and push it to a remote repository (origin), Set up the local branch to track the corresponding remote#git checkout -b feature/myfeature
#git push -u origin feature/myfeature
The first command creates and checks out a local branch called feature/myfeature. The second command creates a corresponding remote branch (origin/feature/myfeature) and tracks it
Delete a remote branchgit push origin --delete feature/myfeature
This will delete the branch origin/feature/myfeature at the remote
List of useful git commands

Useful VS code keyboard shortcuts

VS code keyboard shortcuts

ActionKey combination
Select all instances of a wordCTR + SHIFT + L
Move single line up and downmark the line. Press ALT then use up/down arrows
Format selected codeCTRL +K , CTRL +F
Format all code on current open fileCTR + A
CTR+K, CTRL+F
Select next instance of the currently marked word,a and add it to the list of selected wordsMark the first instance of the word, then press CTRL+D for each word
Mark verticallyMark the first line of the selection.
Press SHIFT + ALT. Then mark the next line
Move one word rightCTRL+ RIGHT arrow
Move one word leftCTRL+ LEFT arrow
Delete the next wordCTRL + DELETE
Move to the end of the current lineEND
Move to the beginning of the current lineHOME
Move to the end of the current fileCTRL+END
Move to the beginning of the current fileCTRL + HOME
Open file in new windowMark the tab of the window.
CTRL + K, O
These are my favorite VS code keyboard shortcuts that I use regularly

Scrum/Agile and DevOps

Agile/Scrum & DevOps: Scrim is a metaphor is taken from rugby
  • Scrum (Rugby): is a method of restarting play in rugby football that involves players packing closely together with their heads down and attempting to gain possession of the ball and deliver it further up the filed
  • Scrum (SW): framework to support teams in complex product development. Scrum consists of Scrum Teams and their associated roles

The metaphor SCRUM in SW: A cohesive self contained group of SW developers (players) gains possession of the ball an transport it further up the field (a product deliverable/increment). The group as a whole is responsible for the result, but are free to choose the best strategy to reach the target.

SCRUM is an Agile methodology. The philosophy of Agile is summed up in the Agile manifesto.

  • Individuals and interactions over processes and tools
  • Working software over comprehensive documentation
  • Customer collaboration over contract negotiation
  • Responding to change over following a plan

Thus Agile takes into account the reality of most SW project: The problem to be solved is very often not understood beforehand. The aquiring of the this knowledge is and ongoing adaptive process. Thus the SW development process must also be adaptive.

The problem with Agile is that although it can dramatically improve SW productivity and quality, the bottleneck is very often in other parts of the value chain for instance in production and deployment.

Thus was born DevOPs (Development + Operations). DevOs is the same Agile principles applied to the whole value chain from concept to cash. It is a natural complement and extension of Agile.

In Addition there have been developments in industry the last decade which has dramatically changed the landscape in SW development. In particular cloud computing provided by large companies such as Amazon, Google and Microsoft as well as virtualization SW such as Docker.

An introduction to Scrum and Dev-ops is given in the Videos below.

The definition of Scrum is pretty well defined here https://www.scrum.org/

DevOps is so new that here not yet one single definition that everybody agrees upon, however some important key features are listed below. The list is not complete, but should give some idea.

  • Close collaboration between Developers and Operations (Thereof the name DevOps)
  • Version Control: All artifacts, Documents et is under version control and configuration management
  • Continuous testing: Unit testing, functional testing and Integration testing is don frequently, typically every time any part of the system changes
  • Continuous delivery: New SW releases is performed several times a day
  • Infrastructure as a code: All servers are described as code that generates virtual machines, (for ins by using Docker files), this code in under version control just as any other part of the system
  • Developer on call: There shall always be a developer on call to assist with support request
  • Chaos Monkey: For larger systems, an application that randomly bring down severs in order to force the developers to make the system resilient to hardware faults, databases going down etc,
  • Rapid feedback from production and operations to developers if something is wrong with as little administration as possible

These are just some of the features I feel is mots important, please free to leave a comment in the comment filed below.

How to succeed with Software

The main challenge, in particular with large SW project is complexity. As the complexity increases it becomes increasingly more difficult to verify the software, and they number of ways things ways can go wring rises exponentially.  Fortunately there is a golden bullet.  But before I reveal the secret I would like to review why things go wrong

The list is based on my almost 20 years experience on various project. Its applicability is in my opinion not limited to SW, however SW will be the focus here,

How Companies fails with SW

  • Failing to view themselves as a SW company when they should
    • Fundamental principles in SW development not implemented
  • Pushing rapid progress in the start of a project and postponing to implement an adequate test regime.
    • Progress is rapid in the beginning and everybody is but the fast progress normally come at the cost of buildup of technical debt. The total cost of the project increases dramatically.
  • Lack of version control and configuration management
    • Stuff that worked before stops working and nobody knows why
  • No common code base for your company core SW
    • Several similar project with “almost” similar code where “resuse” is implemented as “copy and paste”. Combined with lack of version control this constitutes a maintenance nightmare.
  • Lack of a common strategy for SW developed.
  • Lack of a proper regime for regression testing.
    • Nobody dares to touch the code and fix bugs because one has no control of the consequences. The risk of introducing new bugs is too big.
  • Lack of documentation.

The Solution

Get the right people for the job: This is number one on my list and an absolute requirement. If you hire the wrong people, the changes for success i very slim. There are no remedy for lack of ability. To find the right people you will need somebody who can ask the right question during an interview. Embedded Consulting can assist as a neutral 3rd party to assess your candidates.

Implement a SW development regime that takes into account the reality of SW development: The requirements of a complex SW system is rarely known in advance. This is why a waterfall model is doomed to fail. During the last decade or so there are methodologies that have evolve which takes this fact into account

  • Agile/Scrum
  • DevOps

Whereas Agile focuses mainly on SW development, DevOps takes same principles and applies them to the whole value chain. DevOps is an extension and a complement to Agile which as taken the industry by storm. This is for one simple reason, it dramatically increase bot production and customer satisfaction

You can read more about Agile and DevOps in this article.