Git and GitHub Tutorial
***** Git and GitHub Tutorial *****
Steps to Practice Cmd:-
1) Create an account in GitHub and create one repository with a readme file.
2) Download and install git for your OS.
3) Open Git Bash cmd and check git version
cmd => $ git --version
4) You can setup git credentials using
cmd=> git config --global user.name "YourUsername" and
cmd=> git config --global user.email "YourEmailID"
5) Move to the desired directory using the cd command
6) Now to clone the repository from Github
cmd => git clone <github url of your repo> .....
ex => git clone https://github.com/rajmote/helpdeskui.git
7) check what you got from GitHub
cmd=> ls (It will give you readme.txt file in the list.)
8) Now check the status by
cmd => git status (On branch main Your branch is up to date with 'origin/main'.)
9) Now add your project or project files in a directory which you want to check-in and hit
cmd => git status
(Untracked files: (use "git add <file>..." to include in what will be committed) filename.ext)
10) Now if you want to check in a single file then
cmd => git add <filename>
11) if you want to check in all files then
cmd=> git add .
12) Now check status
cmd => git status
13) Now commit the added changes cmd=> git commit -m "Give comment for committing changes"
14) check status
cmd => git status
15) Its time to push committed changes to the GitHub repository
cmd=> git push origin master (make sure about your origin/main or something else)
16) If you face any issue in the above cmd then try
cmd=> git push (It will work)
17) Then status check
cmd => git status
18) Now if someone else had made changes in code and you want to pull it then
cmd => Git pull
19) Check status again cmd => git status
20) Once you done with the above steps then practice following things,
Some cheat codes and bonus points in details:-
INSTALLATION & GUIS With platform-specific installers for Git, GitHub also provides the ease of staying up-to-date with the latest releases of the command-line tool while providing a graphical user interface for day-to-day interaction, review, and repository synchronization.
GitHub for Windows
htps://windows.github.com
GitHub for Mac
htps://mac.github.com
For Linux and Solaris platforms, the latest release is available on the official Git website.
Git for All Platforms htp://git-scm.com
SETUP
Configuring user information used across all local repositories
cmd=> git config --global user.name “[firstname lastname]”
set a name that is identifiable for credit when review version history
cmd => git config --global user.email “[valid-email]”
set an email address that will be associated with each history marker
cmd=> git config --global color.ui auto
set automatic command line coloring for Git for easy reviewing
SETUP & INIT
Configuring user information, initializing and cloning repositories
cmd=> git init
initialize an existing directory as a Git repository
cmd=> git clone [url]
retrieve an entire repository from a hosted location via URL
STAGE & SNAPSHOT
Working with snapshots and the Git staging are
cmd=> git status
show modified files in the working directory, staged for your next commit
cmd=> git add [file]
add a file as it looks now to your next commit (stage)
cmd=> git reset [file]
unstage a file while retaining the changes in the working director
cmd=> git diff
diff of what is changed but not staged
cmd=> git diff --staged
diff of what is staged but not yet committed
cmd=> git commit -m “[descriptive message]”
commit your staged content as a new commit snapshot
BRANCH & MERGE
Isolating work in branches, changing context, and integrating changes
cmd=> git branch
list your branches. a * will appear next to the currently active branch
cmd=> git branch [branch-name]
create a new branch at the current commit
cmd=> git checkout
switch to another branch and check it out into your working directory
cmd=> git merge [branch]
merge the specified branch’s history into the current one
cmd=> git log
show all commits in the current branch’s history
SHARE & UPDATE
Retrieving updates from another repository and updating local repos
cmd=> git remote add [alias] [url]
add a git URL as an alias
cmd=> git fetch [alias]
fetch down all the branches from that Git remote
cmd=> git merge [alias]/[branch]
merge a remote branch into your current branch to bring it up to date
cmd=> git push [alias] [branch]
Transmit local branch commits to the remote repository branch
cmd=> git pull
fetch and merge any commits from the tracking remote branch
REWRITE HISTORY
Rewriting branches, updating commits and clearing history
cmd=> git rebase [branch]
apply any commits of current branch ahead of specified one
cmd=> git reset --hard [commit]
clear staging area, rewrite working tree from specified commit
INSPECT & COMPARE
Examining logs, diffs and object information
cmd=> git log
show the commit history for the currently active branch
cmd=> git log branchB..branchA
show the commits on branchA that are not on branchB
cmd=> git log --follow [file]
show the commits that changed file, even across renames
cmd=> git diff branchB...branchA
show the diff of what is in branchA that is not in branchB
cmd=> git show [SHA]
show any object in Git in human-readable format
TRACKING PATH CHANGES
Versioning file removes and path changes
cmd=> git rm [file]
delete the file from project and stage the removal for commit
cmd=> git mv [existing-path] [new-path]
change an existing file path and stage the move
cmd=> git log --stat -M
show all commit logs with indication of any paths that moved
TEMPORARY COMMITS
Temporarily store modified, tracked files in order to change branches
cmd=> git stash
Save modified and staged changes
cmd=> git stash list
list stack-order of stashed file changes
cmd=> git stash pop
write working from top of stash stack
cmd=> git stash drop
discard the changes from top of stash stack
Comments
Post a Comment