Pitch your project

Random text


By admin Category Uncategorized, Posted February 21st, 2016
Git commands

Git is a version control system(a system that tracks changes to a file/a set of files) which handles both large and small projects. Git can be accessed through the command line or through GUI such as SourceTree. Git basically has three states in which files can reside in, these states are modified, staged and committed. Modified state means you have altered files existing in your working directory, staged means you have added the modified file to the staging area and committed means you have stored the file in the git repository. Usually after committing files you need to to push the files to a feature branch so that it can be pull by other developers you working with on the project. Below are some git commands:

git init <name of repository> Creates a new repository
git clone <url> Clones an existing repository
git status Checks states of files in directory
git diff Displays the modified files in your working directory that have not been staged
git log Lists commits made in the repository
git add <filename> Adds a modified file to the staging area example git add students.java
git add * Adds all the modified files in the working directory to the staging area
git commit -m "<commitmessage>" Commits all the staged files to the repository example git commit -m "file for student entity"
git commit -a -m "</commitmessage><commitmessage>" Stages and commits all modified file example git commit -a -m "added footer"
git push <remotename> <branchname> Pushes committed files to the specified branch example git push origin backend
git pull <remotename> <branchname> Fetches files from a branch and places them on our working directory example git pull origin frontend
git branch </branchname><branchname> Creates a new branch example git branch common_backend
git branch -d </branchname><branchname> Deletes the specified branch example git branch -d students
git checkout </branchname><branchname> Switches to an existing branch example git checkout courses_student
git checkout -b </branchname><branchname> Creates a new branch and switches to the newly created branch example git checkout -b frontend
git merge </branchname><branchname> Merges the specified branch with the branch you are currently switched onto example git merge common_backend
git reset HEAD <filename> Unstages a file from the staging area example git reset HEAD students.java
git remote Lists the short name of each remote handle you have specified
git remote add <shortname> <url> Adds a new remote git repository example git remote add jt https://github.com/jeronotembu/jtgit

Posted by Jerono Tembu

Leave a Reply

Your email address will not be published. Required fields are marked *