Version control systems are software that help you track changes you make in your code over time. As you edit to your code, you tell the version control system to take a snapshot of your files. The version control system saves that snapshot permanently so you can recall it later if you need it. By: Robert Outlaw Link
- Find a comprehensive Git introduction on Microsoft docs Learn Git.
- Inclduing how Microsoft uses Git How We Use Git at Microsoft.
- If you are working in a team a good branching policy is adviced, find some inspiration on Adopt a Git branching strategy, also see Cloud Automation DevOps.
Install git via Chocolatey.
choco install git
Table to list the common commands used in git They are ordered by execution flow.
Command | Description |
---|---|
git status | Show the working tree status |
git fetch | Updates the local repository with all remote changes |
git pull | Fetch from and integrate with another repository or a local branch |
git branch | List, create, or delete branches |
git branch -v -a | List, create, or delete branches -all -verbose (Including Remote Branches -- in case you are missing them locally) |
Git checkout - - track origin/feature/... | Checkout specific branch -- including remote branches if you are missing them locally.Use origin/feature/<WORKITEMNUMBER_WORKITEMDESCRIPTION> (don't include the remote/ before) |
git add . | Adds all changes in the current directory (and sub directories) to the staging (need commit after) |
git add <PATH_TO_FILE> | Adds a specific file to the staging (Needs commit after) |
git commit -am "Text" | Commit the changes (provide a descriptive message like "adds" ,"removes", "fixes" - those commit messages should describe the changes made) |
git push | Update remote refs along with associated objects |
A common sequence to check in code is:
git add .
git commit -am '<COMMITMESSAGE>'
git push
Where add .
stages all files. commit -am
commits all changes with a given message. And push
changes into remote repository.
For more details see Save and share code with Git
Get Free AzureSubscription and Azure DevOps access through Visual Studio