Use Full Git Details | ||
Installing Git | Linux: Apt-get install git-core | |
Windows: http://msysgit.github.com | ||
Git –version | ||
Configuring Git | system level configuration | git config --global user.name "phani git" it config --global user.email "venkataphanikumar.r@gmail.com" git config --global –list git config --global core.editor vim git config --global help.autocorrect 1 git config --global color.ui auto git config --global color.ui auto cat ~/.gitconfig git config --global --unset core.editor |
git config –sytem | ||
stored in /etc/gitconfig or c:\programFiles\Git\etc\gitconfig | ||
User-level configuration | ||
git config –global | ||
Stored in ~/.gitconfig or c:\Users\name\.gitconfig | ||
Repository-level configuration | ||
git config –global | ||
stored in .git/config in each repo | ||
Creating a local repository Adding files Comimting changes Viewing history Viewing a diff Working copy, staging, and repository Deleting files Cleaning the working copy Ignoring files with .gitignore |
Initiate link to git git init Initialized empty Git repository in /home/phani/code-git/.git/ echo "Hello, Git" > README.txt git status Untracked files: README.txt Add new file to git repo git add README.txt git status Changes to be committed : README.txt Changes to be committed git commit Added README.txt git log nano README.txt Modify the file in second time git status Changes not staged for commit ; README.txt Update file in git repo git add -u git status Changes to be committed: README.txt git log git commit -m "updated README.txt" git log Changes between 2 commits git diff a5b807..9a3dd7 (or) Git diff HEAD~1..HEAD [HEAD= latest version, HEAD~1 = latest -1 version] (or) Git diff HEAD~1.. Add new files to stating git add file1.txt file2.txt (or) Git add -A Git commit -m “adding new 2 files” [-m = comments] Remove file rm file2.txt git status Changes not staged for commit: git add -u git status git add file3.txt Mv file1.txt new_file_name.txt git add -A (-A=add all) git commit -m "Reorganized" [commit for stating] Revert our local changes to latest version in git git checkout README.txt HARD, SOFT RESET git reset –hard git reset --soft HEAD~1 Cleaning the working copy git clean -f Ignoring files with .gitignore |
creating a local repository Adding, updating , and deleting files Commiting changes Viewing history and diffs Working copy, staging, and repository Cleaning the working copy Ignoring files with .gitignore |
Cloning a remote repository Listing remote repositories Feching changes from a remote Merging changes Pulling from a remote Pushing changes remotely Working with tags |
git clone https://github.com/jquery/jquery.git git log –onelineoption [comments for all commits will display] git log --oneline |wc -l git log --oneline –graph git shortlog git shortlog -sne git show HEAD [Last commit made] git log --oneline git show 2b5f5d5 git remote git remove -v Git protocols http(s) 80/443 – read-write pwd for auth firewall friendly Git 9418 –read-only anonymous only Ssh 22 – read-write SSH key for auth File n/a – read write local only git branch git branch -r git tag git remote add origin https://github.com/venkataphanikumarr/GitFundamentals.git Git fetch git fetch original git log original/master git merge origin/master git branch -r git fetch; git merge original/master (or) get pull git push Tags are 3types git tag v1.0 git tag -a v1.0_with_message git tag -s v1.0_signed git push –tags |
Cloning a remote repository Fetching and pulling from a remote repository Pushing changes Working with tags |
Working with local branches Stashing changes Merging branches Rebasing commits Cherry-picking commits Working with remote branches |
git log --graph –oneline git log --graph --oneline --all –decorate git config --global alias.lga "log --graph --oneline --all –decorate" git lga cat ~/.gitconfig Git branch feature1 git checkout feature1 echo "Feature1" >> README.txt git commit -am "added feature1" git lga Note: branches follow commits as you add aditional commits to that branch Tags: stay on same commit (friendly name for perticular commit) Git checkout master git branch fix1 561e0ef git checkout fix1 echo "Fixing bug #1234" >> README.txt git commit -am "fix bug 1234" git branch -m fix1 bug1234 (rename the branch) git branch -D bug1234 (delete the branch) Bring back deleted branch (only available 30 days) git reflog git branch bug1234 8335b38 git checkout bug1234 Git stash Git stash pop GIT MERGE BRANCH git merge bug1234 git mergetoo |
Local and remote branches Stashing changes Merging, rebashing, and cherry-picking |
Sunday, 15 April 2018
Use Full Git Details
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment