Day 08/90 Task: Basic Git & GitHub for DevOps Engineers

Day 08/90 Task: Basic Git & GitHub for DevOps Engineers

Git is a distributed version control system (DVCS) that multiple developers and other contributors can use to work on a project. It provides a way to work with one or more local branches and then push them to a remote repository.

?

GitHub is a cloud platform that uses Git as its core technology. GitHub streamlines project collaboration by offering a website, command-line tools, and a cohesive workflow for developers and users to work together. GitHub act s as the remote repository mentioned earlier.

?

git add

git add is the command you use to tell Git to start keeping track of changes in certain files.

The technical term is staging these changes.

?

git commit

After you've staged some changes for commit, you can save your work to a snapshot by invoking the git commit command.

?

git log

The git log command allows you to see information about previous commits. Each commit has a message attached to it (a commit message saved.

?

git help

You've already tried out the git help command, but it's worth reminding you about. Use this command to easily get information about all the commands you've learned so far, and more.

?

Exercises:

?

Create a new repository on GitHub and clone it to your local machine.

?

Repo : Day8-sample-task

ubuntu@DevOps:~$ git clone https://github.com/ds-kamran/day8-sample-task.git

Cloning into 'day8-sample-task'...

warning: You appear to have cloned an empty repository.

?

Make some changes to a file in the repository and commit them to the repository using Git.

?

ubuntu@DevOps:~$ cd day8-sample-task/

ubuntu@DevOps:~/day8-sample-task$ vi index.txt

ubuntu@DevOps:~/day8-sample-task$ ls

index.txt

ubuntu@DevOps:~/day8-sample-task$ git add .

ubuntu@DevOps:~/day8-sample-task$ git commit -m "An empty index.txt file has been created" index.txt

[main (root-commit) 9b61c01] An empty index.txt file has been created

?1 file changed, 1 insertion(+)

?create mode 100644 index.txt

?

?

Push the changes back to the repository on GitHub.

?

Set the connection of local repo with remote repo git remote set-url origin https://<token_number>@github.com/ds-kamran/day8-sample-task.git

?

Move to the master origin:

?

Git checkout -b master

?

git remote push origin

?

Example Commands:

?

ds_kamranarif [ ~ ]$ git --version

git version 2.33.8

ds_kamranarif [ ~ ]$ git config --global user.name "ds********"

ds_kamranarif [ ~ ]$ git config --global user.email "[email protected]"ds_kamranarif [ ~ ]$

ds_kamranarif [ ~ ]$ git config --list

http.sslcapath=/etc/ssl/certs

user.name=ds-kamran

[email protected]

ds_kamranarif [ ~ ]$ mkdir Cats?? # make a directory

ds_kamranarif [ ~ ]$ cd Cats/

ds_kamranarif [ ~/Cats ]$ git init --initial-branch=main # initialize the new directory and name the branch as main

Initialized empty Git repository in /home/ds_kamranarif/Cats/.git/

ds_kamranarif [ ~/Cats ]$

ds_kamranarif [ ~/Cats ]$ git status

On branch main

?

No commits yet

?

nothing to commit (create/copy files and use "git add" to track)

ds_kamranarif [ ~/Cats ]$ ls -a

.? ..? .git

ds_kamranarif [ ~/Cats ]$

要查看或添加评论,请登录

社区洞察

其他会员也浏览了