1. Global config:
git config --global help.autocorrect 1
git config --global core.editor notepad
git config --global core.autocflf = 1 #valid on Windows OS
git config core.autocrlf true # use to keep endline formatting
git config --global user.name "Billy Everyteen"
git config --global user.email "Someone@gmail.com"
git config --global --list #verify config
#Windows:
git config --global core.autocrlf true
#Linux
git config --global core.autocrlf input
2. Basics
git init #Creating a new local repository
echo "Hello World" > run.cmd #add content to file
git status
git add run.cmd or
git add -u # adds if there is new content (will not add empty new files)
git add -A #adds all files, including empty or new
git status
git commit -m "First Commit"
git log # history of commits
git diff HEAD~1..HEAD
git diff HEAD~1.. #veviewing differences between latest commit and previous (number controls which version to compare)
git checkout file.txt #restores previous version of file.txt
gir reset --hard # bring back version to HEAD
git reset --soft HEAD~1 #brings back previous version of code
git reset --soft HEAD~1 #deletes last commit
use .gitignore to ignore files
git clone https://github.com/jquery/jquery.git #clones project
cd jquery
git log
git log --oneline # singe line per commit
git log --oneline --graph # singe line per commit + merges
git shortlog # alphabetical log
git shortlog -sne # number of commmits with email
git show HEAD #shows last changes
git show HEAD~2 #shows previous changes
git branch #display local branch
git branch -r #display remote branch
git tag # shows versions of code
git remote add origin https://github.com/someone/project.git # allows to upload there
git push -u origin master #uploads content
NOTE: use proxy server if needed:
set HTTP_PROXY=http://IP:port
set HTTPS_PROXY=https://IP:port
v
No comments:
Post a Comment