Warning: Invalid argument supplied for foreach() in /home/lazacode/public_html/qa-include/qa-base.php(572) : eval()'d code on line 79
Handy Git command
Are you first timer at lazacode.org? Why not join us and start exchange your knowledge with everyone. Register today!

Handy Git command

0 votes
15 views
added Jul 21 in Repository by Helangmerah Staff Sergeant (2,570 points)
edited Aug 10 by LC Marshal
CommandProperties
git init create a new repository

git clone /path/to/repository

Clone to local

git clone username@host:/path/to/repositoryWhen clone with remote server
git clone -b <feature_name> --single-branch https://github.com/user/repo.gitClone and switch new branch
git checkout -b <feature_name>Create and checkout to a new branch "feature_name"
git checkout masterCheckout to master
git branch -d <feature_name>Delete the "feature_name" branch
git branch -u origin/mybranchDelete local branch
git branch -m [<old-branch-name>] <new-branch-name>Rebases 'feature' to 'master' and merges it in to master
git add <filename>To add files
git add .To add all unstage files
git add <yourfolder/filename>To add folder to repository
git commit -m "Commit message"Now the file is committed to the HEAD, but not in your remote repository yet.
git commit -am "my commit message"To stage and commit with message 
git push origin masterpushing changes - Your changes are now in the HEAD of your local working copy. To send those changes to your remote 
git remote add origin <server>- If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with
- Now you are able to push your changes to the selected remote server
git pullUpdate local repository to latest commit.
git merge <branch>Merge another branch into your active branch.
git commit -v --amendSee commit history for just the current branch
git branch -aGet only remote branches
git stash -- remove unwanted changes
git stash saveSaving current state of unstaged changes to tracked files
git stash --allgit stash save --all
Show list of all saved stashes
git ls-files -tShow all untracked files
git ls-files --othersShow all ignored files
git clean -nForcefully remove untracked files
git clean -fForcefully remove untracked directory
git clean -X -fRestore deleted file.
git config --listMake git case sensitive.
git checkout --orphan <branch_name>Extract file from another branch.
git push -f <remote-name> <branch-name>Adding remote name
git diffdiff of what is changed but not staged
git clone [url]retrieve an entire repository from a hosted location via URL
git logshow all commits in the current branch’s history
   

3 Responses

0 votes
responded Jul 24 by LC Marshal Second Warrant Officer (3,200 points)

Click the following link for more git cheatsheet provide by Github.

https://education.github.com/git-cheat-sheet-education.pdf

0 votes
responded Jul 31 by FeruzRahim Private (500 points)

git add . 
git add -A

Add all files to index/commit

git status
Review your changes

git pull
Get latest version

0 votes
responded Aug 9 by Callum Corporal (880 points)

git commit -am "my commit message"

To stage and commit with message 

...