Skip to content

Instantly share code, notes, and snippets.

@nasrulhazim
Last active August 22, 2016 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasrulhazim/e16321af64e54500d977abd82362a5f8 to your computer and use it in GitHub Desktop.
Save nasrulhazim/e16321af64e54500d977abd82362a5f8 to your computer and use it in GitHub Desktop.
Git Practices

Software Development with Git

Self Training 101

Each of the practices need to be repeated 5 times in order to master them. For example, if Practice 1 has a 4 steps to complete the practice, then Practice 1 need to be repeat 5 times with different project name.

Prefer project name with prefix self10x where x is an incremental number starting from 1.

Practice 1 - Initial

Create a directory and initialize a git repository to the directory

	mkdir sefl101
	cd self101
	git init

Create a README.md file

	touch README.md

Add README.md to git (staging)

	git add README.md

Commit the changes

	git commit -m "Added Readme"

Practice 2 - Making Changes

Update README.md

Add README.md to staging

	git add README.md

Commit changes

	git commit -m "Update README.md"

Practice 3 - Working with Remote Server

Create a repository in remote server - can be GitHub, BitBucket, GitLab or any Git Server.

Add remote repository to local repository

	git remote add remote_name http://remote_url

Push changes to remote server

	git push remote_name master

Practice 4 - Making Changes and Push to Remote Server

Make changes to local repository - add or update files

Add file to staging & commit

	git add file_name
	git commit -m "doing updates"

Push changes to remote serve

	git push remote_name master

Practice 5 - Create Branch, Change Branch, Push Branch to Remote Server

Create a new develop branch

	git branch develop

List all available branch

	git branch

Change current branch to develop branch

	git checkout `develop`

Push develop branch to remote serve

	git push origin develop

Practice 6 - Merge Develop Branch into Master Branch

Change to master branch

	git branch master

Check Differences Between Master and Develop Branch

	git diff master develop

Merge Develop into Master Branch

	git merge develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment