GIT & GITHUB ACCESSIBILTY [Beginners]

Kona Venkata Sai Lakshmi
11 min readApr 16, 2021

--

GIT [ ‘VCS’ through which Testers can Depict the BUG and Dev can Fix the BUG! ] GITHUB [Code-Hosting platform with lots of integrated features].

Accessing GITHUB with GIT terminal ^_^

Thinking about How to Add Files to Github Repo? Want to know how to collaborate with Team? Want to add Awesome intro for your profile? Oh! you are Developer and looking to Track files? …

Great! then you are at Right place. This blog is for you! :)

GIT [ Version Control System]:

Suppose you have file/folders and you want to make all the changes that you want to do with that file/folders can be done using VCS. Along with that it will track all the changes and maintain Version history as well. Another Major benefit with git is you can collaborate with team.

GIT Version Storage Management

Centralized Version control:

People from multiple work stations can commit or update files on single repository which is on server. If anything goes wrong on that repo then it’s highly typical to backup those files as there’s only single copy in server along with that people who are connected to that repo need to be online continuously.

CENTRALIZED VERSION CONTROL

Distributed Version Control System:

Every individual in different work stations who are working on same repository in server are able to create local repository. Here if anything goes wrong on Repo exists in server we can backup that repo with local Repo. Other benefit is no need to be connected for long individual can work on local repo’s once it’s done you can push the files in main Repo.

Distributed Version control

So what I want to say is….

GIT is Free and Open Source DVCS [Distributed Control System].

Source: https://git-scm.com/downloads

GITHUB:

Code-hosting platform where Developers can host their websites for free. Mostly it provides Visual User Interface for your Repo along with that it will make collaborations Easier. Place where you can emerge with technologies with incredible Github features in your finger tips.

click on new Repository

GITHUB SIGNUP > +[top right corner] > Update( Repository name, include Readme file)>Create Repository

INSTALLATION OF GIT [WINDOWS, MAC, LINUX

Game begins now!!

Introduce yourself to Git by giving following command!

$ git — — Version

if you are able to see the version you installed then your git is installed successfully if not you find any Error like “Command Not found” indicate your git is not installed or not compatible.

Now Add your Username and Email to Git by following commands

$ git config — — global user.name “<Github_Username>”

$ git config — — global user.email “<Email@email.com>”

Note: Username need not to be GITHUB username just give the name with which name you want to made changes everytime or for every repo and email need to be email you have used for GITHUB.

Adding Files/Folders to GIT:

Initially change Directory in terminal by following command in place of FolderPath copy path of folder you want to add/push into repo and paste it there.

$ cd “FolderPAth”

eg:$ cd /Users/sai/Desktop/Test

Initialising Git: empty git Repo will be initialised in that local folder. once it’s initialised .git hidden folder will be created.

$ git init

Viewing Hidden files in MAC:

$ defaults write com.apple.finder AppleShowAllFiles YES

closing Hidden Files in MAC:

$ defaults write com.apple.finder AppleShowAllFiles NO

Status: View the status of git. Number of files added/Modified.

$ git status

Now lets add files in 2 different ways 1st command to add files One by One and 2nd command is to add all at a time.

$ git add <filename>

$ git add .

to add all of your files to the staging area. You can commit these changes with the command.

$ git commit -m “<include commit description>”

Now signin to GITHUB and Create Repository

GITHUB SIGNUP > +[top right corner] > Update( Repository name, include Readme file)>Create Repository

Once it’s done GOTO Repo from dashboard and click on code then copy path to that Repo.

You can view path in Clone dialogue box

$ git remote add origin “<paste repository path>”

$ git Push -u origin master

Now you know how to create Github Repository and how to add files to it!

GITHUB TEAM COLLABORATION:

Initially clone that Repo you want to work in your local Repo.

Click on Download Zip

Use following commands to collaborate with team

$ git pull origin master

if you want to add new feature to master branch then use following command

$ git checkout -b “new feature”

save that source code you are working on now add files

$ git add.

$ git commit -m “commit Message”

Now push all the files to master branch

$ git push origin “<New_feature>”

Now to Github and check the Repo you can see Compare & pull request button click on that it will redirect to create pull request page just click on that create PR button after adding proper description.

if you have PR then after performing proper code review you can Merge Pull Request which changes your source code.

No conflicts just click on Merge PR

Or use following commands to merge

$ git checkout master

$ git merge “<new_feature>”

In order to create an upstream branch so that you can push your changes and set the remote branch as upstream, you will push your feature by running

$ git push — — set-upstream origin “<new_feature>”

Great! Now you viewed commands for GITHUB Team collaboration!! ^_^

Hosting Webpages on GITHUB:

GITHUB> Create new Repo> Open cmd

$ git init

$ git status

$ git add .

$ git commit -m “commit message” .

$ git remote add origin “<Path_of_repository>”

$ git push -u origin master

//Provide login credentials and goto github repo you created

Settings>Github pages>Source[Master]>save

select main

then right click on the link displayed and open in new tab. There you go you have hosted your webpage.

GIT Cheat sheet:

Git Basics

$ git init <directory>

Create empty Git repo in specified directory. Run with no arguments to initialize the current directory as a git repository.

$ git clone <repo>

Clone repo located at <repo> onto local machine. Original repo can be located on the local filesystem or on a remote machine via HTTP or SSH.

$ git config user.name <name>

Define author name to be used for all commits in current repo. Devs commonly use — global flag to set config options for current user.

$ git add <directory>

Stage all changes in <directory> for the next commit. Replace <directory> with a <file> to change a specific file.

$ git commit -m “<message>”

Commit the staged snapshot, but instead of launching a text editor, use <message> as the commit message.

$ git status

List which files are staged, unstaged, and untracked.

$ git log

Display the entire commit history using the default format. For customization see additional options.

$ git diff

Show unstaged changes between your index and working directory.

Undoing Changes

$ git revert <commit>

Create new commit that undoes all of the changes made in

<commit>, then apply it to the current branch.

$ git reset <file>

Remove <file> from the staging area, but leave the working directory unchanged. This unstages a file without overwriting any changes.

$ git clean -n

Shows which files would be removed from working directory. Use the -f flag in place of the -n flag to execute the clean.

Rewriting Git History

$ git commit — — amend

$ git rebase <base>

$ git reflog

Replace the last commit with the staged changes and last commit combined. Use with nothing staged to edit the last commit’s message.

Rebase the current branch onto <base>. <base> can be a commit ID, a branch name, a tag, or a relative reference to HEAD.

Show a log of changes to the local repository’s HEAD. Add

— — relative-date flag to show date info or — — all to show all refs.

Git Branches

$ git branch

List all of the branches in your repo. Add a <branch> argument to create a new branch with the name <branch>.

Create and check out a new branch named <branch>. Drop the -b

flag to checkout an existing branch. Merge <branch> into the current branch.

$ git checkout -b <branch>

$ git merge <branch>

Remote Repositories

$ git remote add <name> <url>

Create a new connection to a remote repo. After adding a remote, you can use <name> as a shortcut for <url> in other commands.

$ git fetch <remote> <branch>

Fetches a specific <branch>, from the repo. Leave off <branch> to fetch all remote refs.

$ git pull <remote>

Fetch the specified remote’s copy of current branch and immediately merge it into the local copy.

$ git push <remote> <branch>

Push the branch to <remote>, along with necessary commits and objects. Creates named branch in the remote repo if it doesn’t exist.

$ git config

$ git config — — global user.name <name>

Define the author name to be used for all commits by the current user.

Define the author email to be used for all commits by the current user.

Create shortcut for a Git command. E.g. alias.glog log — — graph

— — oneline will set git glog equivalent to git log — — graph — oneline.

Set text editor used by commands for all users on the machine. <editor>

arg should be the command that launches the desired editor (e.g., vi). Open the global configuration file in a text editor for manual editing.

git config — global user.email <email>

$ git config — — global alias. <alias-name><git-command>

$ git config — — system core.editor <editor>

$ git config — — global — — edit

$ git log

$ git log — — limit>

Limit number of commits by <limit>. E.g. git log -5 will limit to 5 commits.

Condense each commit to a single line. Display the full diff of each commit.

Include which files were altered and the relative number of lines that were added or deleted from each of them.

Search for commits by a particular author.

Search for commits with a commit message that matches <pattern>.

Show commits that occur between <since> and <until>. Args can be a commit ID, branch name, HEAD, or any other kind of revision reference.

Only display commits that have the specified file.

— — graph flag draws a text based graph of commits on left side of commit msgs. — — decorate adds names of branches or tags of commits shown.

$ git log — — oneline

$ git log -p

$ git log — — stat

$ git log — — author=”<pattern>”

$ git log — — grep=”<pattern>”

$ git log <since>..<until>

$ git log — — <file>

$ git log — — graph — — decorate

$ git diff

$ git diff HEAD

$ git diff — — cached

Show difference between working directory and last commit.

Show difference between staged changes and last commit

Git Reset

$ git reset

Reset staging area to match most recent commit, but leave the working directory unchanged.

$ git reset — — hard

Reset staging area and working directory to match most recent commit and overwrites all changes in the working directory.

git reset <commit>

Move the current branch tip backward to <commit>, reset the staging area to match, but leave the working directory alone.

$ git reset — — hard<commit>

Same as previous, but resets both the staging area & working directory to match. Deletes uncommitted changes, and all commits after <commit>.

git rebase

$ git rebase -i <base>

Interactively rebase current branch onto <base>. Launches editor to enter commands for how each commit will be transferred to the new base.

$ git pull

$ git pull — — rebase<remote>

Fetch the remote’s copy of current branch and rebases it into the local copy. Uses git rebase instead of merge to integrate the branches.

$ git push

$ git push <remote> — — force

Forces the git push even if it results in a non-fast-forward merge. Do not use the — — force flag unless you’re absolutely sure you know what you’re doing.

$ git push <remote> — — all

Push all of your local branches to the specified remote.

$ git push <remote> — — tags

Tags aren’t automatically pushed when you push a branch or use the

— — all flag. The — — tags flag sends all of your local tags to the remote repo.

Integrating GITHUB with Eclipse:

Initially copy URL of the Repo from Github in which you want to add files.

Right click on Package explorer left panel then click on import.

click on import

if you can’t find Git plugin then you need to install it. if it’s there select Projects from Git.

select projects from Git

if you already have project in existing repo then choose clone Repository if not choose local Repository then click on next.

select clone Repository

Now paste Project URL in URL input box and enter user github credentials and click on next.

provide valid user credentials!

Check the Master/Main branch and click on next.

Check the Repo you created is empty or not if not just rename it and click on next.

Once it’s cloned choose import existing eclipse projects and click on next.

Once it’s imported you can view your project on eclipse left panel. After performing changes in source if you want to update it in Master Branch of Github.

Right click on left panel >Team>Push BRanch ‘main’…

Now click on Preview.

Click on Push!

//If Repo already exists and just want to update changes then you can right click on project> Team>pull

While doing commit update commit message as well!

Thanks for the patience!! I hope you found this post useful!

I would be more than happy if you send your feedback, suggestions or ask queries. Moreover, I love to connect people who are really passionate about building real time products!!

If you have any suggestions or queries contact me:

Github: https://github.com/KONA-VENKATA-SAI-LAKSHMI

Linkedin: https://www.linkedin.com/in/kona-venkata-sai-lakshmi-938842154/

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Kona Venkata Sai Lakshmi
Kona Venkata Sai Lakshmi

Written by Kona Venkata Sai Lakshmi

IBMer || Lazy Programmer | Artificial Intelligence Enthusiast | Tech Blogger | Sketcher || https://www.linkedin.com/in/kona-venkata-sai-lakshmi-93884

No responses yet

Write a response