Useful Git Commands listed with its uses briefly


Here is some useful commands to manage your development using git


git init (Initialize your git project directory)
git status (Check current status)
git add filename (Add a single file created or modified)
git add . (Add all new file created or modified)
git add *.html (Only add html files that is newly created or modified)
git commit -m “first commit” (Commit to repository after add with a comment)
git push origin master (Push all files to origin master)
git log (Check log)
touch gitignore (Create a .gitingore file, enter a file name will be ignored while adding/updating)
git branch MyBranch (Create Own Branch)
git checkout MyBranch (Select a branch for work/change)
git merge MyBranch (Merge my new branch with master branch)
git merge master (merge master with branches)
git stash (save the new file created yet for future commit)
git stash apply (Commit the stash file/files)
git remote (view remote repositories)
git clone repository-url (Checkout the remote git project)
git remote -v (See original source url)
git fetch origin (Will download but not merge)
git pull origin ( will download and merge altogether)

Advertisements

GitHub: How to clone repo, checkout and push.


1. First you need to create your account at GitHub.com and login.
2. Create a Repositorie of your project say “test-repo”.
3. After creating your repositorie you will find a link for example “https://github.com/ziyed/test-repo.git”
4. Copy this link.
5. Now Open Command prompt and go to the location where you want to put the repo clone.
6. Now type the following command, run it


     git clone https://github.com/ziyed/test-repo.git

7. You will find a project clone will be created in your defined location.
8. If you want to add new files and push it to remote Repositorie, just go through the following command…

		
git add .

git commit -m "uploading client fils"

git push