Terminology
- HEAD is not the latest revision, it's the current revision. Usually, it's the latest revision of the current branch, but it doesn't have to be.
- master is a name commonly given to the main branch, but it could be called anything else (or there could be no main branch).
- origin is a name commonly given to the main remote. remote is another repository that you can pull from and push to. Usually it's on some server, like github.
Good GUI Software
- Git Extensions - Very good for bash and windows explorer integration
- SourceTree - Excellent GUI to manage the whole repository and look at it visually. Better visual representation by default then git extensions since gives the exact date and time.
Updating a submodule
- Open a git bash at the sub-module directory then type:
Informational Commands
- Repository Status
- Commit History
- Get current branch name
Checkin Commands
- Push code to a remote at a particular branch
-
-u
option points your current local branch to the remote branch named
- Stage files
- Stages all
- Stages new and modified, without deleted
- stages modified and deleted, without new
- Commit
- Aborting a merge
- Discard local changes
- Stash Local changes and drop them
Checkout
- Fetch all information about new branches etc. from remote
- Pull the branch data from remote
Branching
- Switch to existing branch
- Switch to new branch on the current workspace i.e. branch off
- Push current branch to remote and track it
Remotes
- List Remotes
- Change Remote URL
- Change Remote name
- Remove a remote
- Add a remote
Tutorial and Help
Issues
Unsafe repository
After upgrading GIT started receiving unsafe repository - not the owner error whenever I tried running pull on the previous repository folders. So need to change the owner to myself. In the folder properties dialog I don't see the security tab. So needed to enable it. For that needed the Group Policy Editor. Windows Home edition does not have it so had to install it:- Open cmd as adiministrator.
- Run a batch file with the following contents:
- Open it with windows+R key and type gpedit.msc.
- Now navigate to: User Configuration -> Administrative Templates -> Windows Components -> File Explorer On the right hand side, double-click the “Remove Security tab” setting. See here.
- Select disabled and the policy setting will take effect immediately.
This also did not bring the security tab. Realized that my repository is in my USB drive formatted with the FAT filesystem. So could not figure out how to change the owner.
Finally just did this from the git bash:
For example: