Skip to content

Instantly share code, notes, and snippets.

@umeshnrao
Created July 20, 2017 06:08
Show Gist options
  • Save umeshnrao/c8f26951ca03b40948d5ba4263ec4ae7 to your computer and use it in GitHub Desktop.
Save umeshnrao/c8f26951ca03b40948d5ba4263ec4ae7 to your computer and use it in GitHub Desktop.
git command commands
# Clone data from a remote repository to local machine
git clone <repo_url>
# Change dir to the downloaded repo
cd <folder_name>
# Show current branch
git branch
# Create a new branch for local development(maybe name it same as idsid)
git branch <branch_nm>
# Switch to the new branch
git checkout <branch_nm>
# pull from the remote repo
git pull origin <branch_nm>
# Gets details about the files
git status
### Create the required program source files / copy the files to the directory if they are present elsewhere
# Add the source files for tracking . Can specify individual file names or use wild cards
git add <filename>
### Addition of files can be verified using 'git status'
# Commit the added files/changes to local repo
git commit -m "Some comment about the change"
## it is a good practice to pull before pushing code changes when multiple people are working on same piece of code
# Push local changes to the remote repo
git push origin <branch_nm>
## This can be verified by logging into the github website
## Merging Branches ##
# Switch to the branch to which you intent to merge
git checkout <target_branch>
#Pull from remote repo to the target branch
git pull origin <target_branch>
# Merge with your updated branch. Provide the merge comments if prompted.
git merge <branch_nm>
# Push change to remote repo
git push origin <target_branch>
# Switich back to your branch
git checkout <branch_nm>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment