Skip to content

Latest commit

 

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Git and Github

Below tasks have been performed for assignment#1 Git and Github tutorials which is part of "Industry Ready Data Science Projects", a course offered by www.ineuron.ai.

Refer below link for assignment details: https://github.com/Project-Neurons/Industry-Ready-Projects-Tasks/blob/main/Git_&_Docker/Assignment-1.md

Task 1

Demonstrate minimum 15 basic Git command with explanation and screenshot.

Solution:

1. Initialize git in local machine

This command converts the local folder into git repository.

git init

image

2. Configure user details

'config' command can be used for setting multiple configurations. In this step we are configuring the name and email id of user who is performing the operations in the git.

git config user.name = devendra_jakhmola
git config user.email = devjakhmola1990@gmail.com

image image

3. Track files

'add' command is used to place changes in the working directory to git staging area. Before committing a change, we must add it to the staging area.

git add .

image

4. Add files to Staging Area

'commit' command tells the git to store the final changes. Git maintains the history of each commit which makes it is easy to rollback to any previous commit whenever required.

git commit -m "first commit"

image

5. Rename 'master' to 'main'

When we want to publish changes from local git repo to a github repo, we should ensure that the root folder alias are same in git and github. By default, the root folder in github is 'main' while git has 'master'. We run below command to rename 'master' to 'main'.

git remote -M main

image

6. Create a remote for Github repo

To connect local git repo to git hub repo, we have to create a 'remote' pointing to github repository. In below command we are adding a remote for github repository and given it an alias 'origin'.

git remote add origin https://github.com/jakhmoladp/sample_repo.git

image

7. Push changes from local machine to github repo

In below command, we are now pushing the committed changes from local repository (main branch) to github repository via remote (origin) we created in previous step.

git push -u origin main

image

8. Create and activate a branch

Git allows the developers to create copy of main repository, make changes in the copy and easily merge their changes to the parent repository without too much efforts. These copies are called 'branches' in git. Developers can create branches from last working code and perform their changes, test them and merge them to parent branch. This allows multiple developers to collaborate easily.

In below command we are creating a branch named 'dev' and then switch to it. Changes done in this branch are limited to the 'dev' branch only, until he/she merges the changes with main branch.

git checkout -b dev

image

9. Merge changes in branch to main

Make some changes in the files and merge the changes to 'main' branch.

git checkout main
git merge dev

image

10. Remove a file

# Remove a previously created document
git rm "15 commands.docx"

image

11. Clone github repo to local machine

'cloning' allows downloading a github repository into local machine.

# Create a folder in local machine.
# cd the folder and run below mentioned clone command.
git clone https://github.com/Project-Neurons/Industry-Ready-Projects-Tasks.git

image

12. Check the list of untracked, unstaged or uncommited changes

git status

image

13. Rollback commit

As git saves the history of changes through commits, we can always go back to the previous commits.

a. Add a new line in app.py file:

image

b. Add and commit the change:

image image

c. Rollback the last commit:

# Remove the last commit to tracking area
git reset HEAD~1

After running the reset command, it will show the last changes as not staged for commit. image

14. Check git logs

This command shows the list of all commits. Use this to see the commit history and id of specific commit. It also shows the pointer to the current head.

git log

image

15. Create Stashes

Git stash is a built-in command with the distributed Version control tool in Git that locally stores all the most recent changes in a workspace and resets the state of the workspace to the prior commit state.

git stash 
git stash apply

image


Task 2

Consider that you want to start an open-source project in your organization. Perform all the standard operation to create a repository with minimal permision for all the users. It should contain.

  1. Proper open source structure
  2. Proper Readme
  3. Add 2 collaborator
  4. Host GitHub Pages using settings (Designed to host your personal, organization, or project pages from a GitHub repository)

Solution:

1. Open source project structure has been created

https://github.com/jakhmoladp/git_project_structure.git

image

2. Read me file added:

image image image

3. Two Collaborators have been added

image

4. Host GitHub Pages using settings

image

image


Task 3

1. Create a Issue in your github repository.

image

2. Raise a pull request.

A pull request has been created after adding a file in branch. image

3. Merge A pull request.

a. A sample file has been added in the branch:

image

b. Switch to main --> Pull Requests --> Click 'new pull requests' --> Select branch name --> create pull request

c. click on 'merge pull request' and 'confirm': image

d. Sample file will now appear under main branch: image

4. Reject a pull request with proper comments.

Click on "pull requests". It will show list of all open pull requests. Select the request, and click on 'close the request' by putting remarks:

image

5. Add a Dependabot alerts in your github.(for above cases)

image

6. Stash changes

image

7. Create a release your package

setup.py file has been created for releasing the package. image

8. Setup a Projects Board for your project.

Created a projects board: image

Releases

Packages

Contributors

Languages