Git Version Control (Basic to Advanced)

2 / 3

Git - Version Control Part 2






In this video, we are covering the following topics:
- Creating a repository.
- Setting up a repository.
- Cloning a repository.
- Various Git file status.
- Tagging.
- Undoing commits.
- Using the Git reset and remove commands.
- Collaborating with Git.
- Git Branching.
- Making a pull request.

Download the slides


Please login to comment

93 Comments

the webpage is opening like this.

but i am not getting the link of my name under about us

 

  Upvote    Share

Hi jasmeen, 
Here are a few things to check:

1. Check the HTML File:
Open your Flask template (e.g., about.html) and ensure your name is linked correctly:

<a href="{{ url_for('your_page_route') }}">Your Name</a>

or

<a href="jasmeen.html">Jasmeen</a>

2. Check Flask Routing:
If your page is dynamically generated, ensure you have a Flask route like this:

@app.route('/jasmeen')
def jasmeen():
    return render_template('jasmeen.html')

3. Ensure Static Files Load Properly:
If using static HTML files, make sure jasmeen.html is inside the templates folder and properly linked.

4.Inspect Page Source:
Right-click on the page and select "View Page Source" to check if your name's link appears in the HTML.

5.Clear Cache & Restart Flask Server:
- Clear your browser cache and reload.
- If using Flask, restart the development server with flask run.

If you've tried these steps and still face issues, let me know what your code looks like, and I can help debug further!

  Upvote    Share

there were some faults in syntax . now it works fine. thanks.

  Upvote    Share

(webserver01) [jasmeenkaur0919997520@cxln4 Session3]$ git clone https://github.com/singh-ashok25/webserver.git

Cloning into 'webserver'...remote: Enumerating objects: 147, done.remote: Counting objects: 100% (143/143), done.remote: Compressing objects: 100% (71/71), done.remote: Total 147 (delta 76), reused 115 (delta 64), pack-reused 4 (from 1)

fatal: write error: Bad file descriptorfatal: index-pack failed

(webserver01) [jasmeenkaur0919997520@cxln4 Session3]$ cd /tmp

(webserver01) [jasmeenkaur0919997520@cxln4 tmp]$ git clone https://github.com/singh-ashok25/webserver.git

Cloning into 'webserver'.../tmp/webserver/.git: Permission denied

 

I tried cloning the repo in session3 but it failed. so i tried cloning it in /tmp but then again it says permission denied.

 

  Upvote    Share

Hey Jasmeen, Make sure you follow all the steps as listed in: https://discuss.cloudxlab.com/t/bad-file-descriptor-while-running-git-clone/8351.

I see you have missed out on 'After that, create a directory with your username to avoid ownership issues, and clone the repo inside the newly created directory.'.

  Upvote    Share

done. Thanks

  Upvote    Share

[jasmeenkaur0919997520@cxln4 lab03]$ git remote add origin git@github.com:Jasmeen-1999/lab03.

gitfatal: remote origin already exists.

[jasmeenkaur0919997520@cxln4 lab03]$ git push -u origin main

Username for 'https://github.com': Jasmeen-1999

Password for 'https://Jasmeen-1999@github.com':

fatal: Authentication failed for 'https://github.com/Jasmeen-1999/lab03.git/'

[jasmeenkaur0919997520@cxln4 lab03]$

 

I used the SSH instead of https but still the authentication fails. what to do now?

  Upvote    Share

I was facing Authentication issue.. And it got resolve by Creating PAT on github.com and using it to commit and push.
1. Create PAT and noteit down somewhere as it is visioble once while it get created.
then use below commands.
 *  git remote set-url origin https://<YOUR_PAT>@github.com/<USERNAME>/<REPOSITORY>.git

after that it will work for commit and push.

  Upvote    Share

Thanks. I created PAT in github.

but still it shows an error

[jasmeenkaur0919997520@cxln4 lab03]$ git push -u origin main

error: src refspec main does not match any.

error: failed to push some refs to 'https://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@github.com/Jasmeen1999/lab03.git

would you mind suggesting me where i could have gone wrong.

  Upvote    Share

Hey Jasmeen,

The error you're encountering, error: src refspec main does not match any, usually happens when:

1. The local branch doesn't exist: Your local branch might not be named main or might not have any commits yet.

2. Repository was initialized but has no commits: If your repository is newly created and has no commits, you’ll see this error when trying to push.

  Upvote    Share

yes the repository is newly created. Thanks.

  Upvote    Share

Hey Jasmeen,

If your repository is empty and you haven’t committed any changes, Git won’t have a branch to push. Make some changes first and then try committing.

  Upvote    Share

executed successfully. Thank you for your support.

  Upvote    Share

Getting this error

  Upvote    Share

How to fix it?

  Upvote    Share

Hi Sushant,

You can remove the port number from the url to access it. If you are running any app on our lab, then make sure you have mentioned the correct port number.

  Upvote    Share

Hi Shubh i was trying to access this URL as part of the lab after changing the port number in "app.py" , I even tried with port no: 4080 but it stil gives the same error

  Upvote    Share

No worries, I figured it out

  Upvote    Share

Hi I am unable to push my branch to repo help me ...

  Upvote    Share

Hi Prince,

What do you understand from the displayed error?

  Upvote    Share

This comment has been removed.

I think i dont have authentication to mearge any mew change in this repo

  Upvote    Share

Hi Prince,

I will advise you to go through this project first: https://cloudxlab.com/assessment/playlist-intro/435/getting-started-with-git?course_id=206&playlist_id=435. It will help clarify all the basics of Git and give you a better understanding. Once you've completed it, you can revisit this exercise and see if you can complete it with more confidence.

 

 1  Upvote    Share

Complete sir but i did't figure out this error my username and password is also correct but same output again and again

  Upvote    Share

Hi sir i also generate PAT(Personal Access Token ) but again error ..... Please guide me where i am wrong

  Upvote    Share

It looks like you're trying to push your changes directly to the original repository, but you're encountering a 403 error, which means you don't have permission to push to that repository. Here's what you need to do:

1. Fork the repository: Go to the repository (https://github.com/singh-ashok25/webserver/) on GitHub and click 'Fork' to create a copy under your account.

2. Clone your fork: Clone your forked repository to your local machine using the following command:

git clone https://github.com/Prince5104/webserver.git

3.  Add your changes: Move your changes to this cloned repository (your forked version).

4. Push to your fork: After making the changes, push them to your forked repository's branch:

git push origin feature/add_new_page
5. Create a pull request (PR): Once your changes are in your forked repo, go to the original repository and create a pull request. This will allow the maintainers to review your changes and merge them into the original repository.

If you need help with any of these steps, feel free to ask!

 1  Upvote    Share

Hii! Sir i follow step by step as u said but output are remain same .....

  Upvote    Share

You can switch to SSH for authentication, which avoids the need for a password or token. You can refer to https://cloudxlab.com/assessment/displayslide/4953/github-project-getting-started-with-git-creating-ssh-keys-and-adding-to-github?course_id=206&playlist_id=435 for it.

 1  Upvote    Share

This comment has been removed.

Hi Sir, I didn't get any reply of my questions from any working professional of your team. where i go sir, how many comment required to get attention of you guys ? u don't told us before about this truth if i know i do every things from my own and self reading then i thoughts 1 time before taking admission .Sorry sir but all students are not from it background so they have so many doubt but no any answer and if some one reply they reply after 7 days or sometime a monts later . Its not fair sir at least you guys should reply every comment, if its not possible then please create ai for best and better understandability of students .. Thanks for your precious time if u reply me Sir

 1  Upvote    Share

Hi Prince,

Thank you for sharing your thoughts and for your patience. I understand how frustrating it must be to have unanswered questions, especially when you're navigating a field that may be new to you. We genuinely appreciate your feedback, and I sincerely apologize for any delays in responses you've experienced.

At the moment, I cannot see any of your other comments apart from this slide. It seems that your query regarding hardlinks to a directory was already resolved via email, which is why it was not answered again in the comments section. Could you please share any other questions or concerns, or links to your previous comments, so we can assist you further?

Your learning experience is important to us, and we're here to support you throughout your journey.

Thank you again for your understanding and for bringing this to our attention!

  Upvote    Share

Hi , I can't understant anythings in this 4 lab if anyone avlaible please help me . I am too confuse 

and the tutior of this video make more confusable this topic please help....

 1  Upvote    Share

Hi Prince,

Let's understand it step by step.

Here, the goal is to develop a feature in a public repository by adding functionality to a web server. Specifically, we are adding a personalized link to the homepage, which will lead to a custom HTML page named after you.

Steps Breakdown:

1. Create a feature branch and switch to the newly created branch

In Git, branches allow you to work on different parts of a project separately without affecting the main (or "production") version of the code. By creating a branch named feature/<name>, you’re setting up an isolated environment to implement and test new features. This branch can later be merged into the main project once everything works as expected.

After creating the branch, you need to switch to it so you can start making changes in that branch. The below command creates a new branch and switches to it:

git checkout -b feature/<name>

2. Make the required changes

Now that you’re in your feature branch, you can do your work—whether it’s editing index.html or making any other changes required for the task. In this case, you're adding a personalized link to the homepage and creating a custom HTML page.

3. Commit the changes and merge them into the main branch

Once your changes are done and you’ve tested them, you need to commit them to your feature branch. Then, you can merge your feature branch into the main branch to make your changes live.

This process ensures that your new feature is successfully added to the main project, maintaining a clean and organized workflow.

  Upvote    Share

 * Debug mode: on
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://10.142.1.4:4180/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 673-864-876 ,

 

I Have chnaged port in app.py file nad running url  am using http://f.cloudxlab.com:4180/ 

but showing This site can’t be reached

Please  Guide.

  Upvote    Share

Hi Priyanka,

Can you try http://e.cloudxlab.com:4180/? The 'f' cluster is currently not in use, so we recommend using the 'e' cluster instead.

If you face any further issues, feel free to reach out, and we’ll be happy to assist you!

 

  Upvote    Share

Hi ,

I have checked with URl as you have suggested with 'e' cluster.

Tried all steps from begaining again and install flask everything but still having same issue This site can’t be reached URL not working.

Kindly Suggest.

  Upvote    Share

Can you share screenshot of the issue you are facing?

  Upvote    Share

This comment has been removed.

Hi , I have attahed screenshot please check

  Upvote    Share

Let’s debug it. We can start with some basic steps such as:

1. Check port in app2.py: Ensure the app is running on port 4080 in the app.run() line.

2. Verify server listening on port: Use netstat -tuln | grep 4080 to confirm if the server is active on the specified port.

  Upvote    Share

Thank You. Issue Solved. The support  received here is one of the standout features of this platform.

  Upvote    Share

Please help to resolve this issue - (venv) [pmokase185079@cxln4 webserver]$ python app.py
Traceback (most recent call last):
  File "app.py", line 1, in <module>
    from flask import Flask,  escape, request
ModuleNotFoundError: No module named 'flask'

  Upvote    Share

Hi Priyanka,

Make sure you have installed flask in your virtual environment.

  Upvote    Share

HI Team,

 

I am getting an error while peforming Git Push. I ensured my ID and PWd is correct by signing out and signing into github. Kindly guide.

webserver01) [vidyakuruvalli8417@cxln4 webserver]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for 'https://github.com': Vidya-kuruvalli
Password for 'https://Vidya-kuruvalli@github.com':
fatal: Authentication failed for 'https://github.com/singh-ashok25/webserver/'
(webserver01) [vidyakuruvalli8417@cxln4 webserver]$

  Upvote    Share

Hi VIdya,

Are you trying to push to ashok's repository https://github.com/singh-ashok25/webserver/ ?
if yes, then this won't execute because you don't have access to the repository.

  Upvote    Share

Hello, while installing flask getting an SSL verification failer error.

  Upvote    Share

(webserver01) [vidyakuruvalli8417@cxln4 webserver]$ pip install Flask
Collecting Flask
  Could not fetch URL https://pypi.python.org/simple/flask/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852) - skipping
  Could not find a version that satisfies the requirement Flask (from versions: )
No matching distribution found for Flask

  Upvote    Share

To resolve the SSL certificate issue while installing Flask with pip, follow these steps:

1. Upgrade pip:

python -m pip install --upgrade pip

2. Install certifi:

pip install certifi

3. Set REQUESTS_CA_BUNDLE environment variable:

export REQUESTS_CA_BUNDLE=$(python -m certifi)

 

  Upvote    Share

This comment has been removed.

Got the below error when tried upgrading pip

(webserver01) [vidyakuruvalli8417@cxln4 webserver]$ python -m pip install --upgrade pip
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852) - skipping
Requirement already up-to-date: pip in /home/vidyakuruvalli8417/webserver01/lib/python3.6/site-packages
(webserver01) [vidyakuruvalli8417@cxln4 webserver]$ python -m pip install --upgrade pip
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852) - skipping
Requirement already up-to-date: pip in /home/vidyakuruvalli8417/webserver01/lib/python3.6/site-packages
(webserver01) [vidyakuruvalli8417@cxln4 webserver]$ pip install certifi
Collecting certifi
  Could not fetch URL https://pypi.python.org/simple/certifi/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852) - skipping
  Could not find a version that satisfies the requirement certifi (from versions: )
No matching distribution found for certifi
(webserver01) [vidyakuruvalli8417@cxln4 webserver]$ export REQUESTS_CA_BUNDLE=$(python -m certifi)
/home/vidyakuruvalli8417/webserver01/bin/python: No module named certifi
(webserver01) [vidyakuruvalli8417@cxln4 webserver]$

  Upvote    Share

It seems there is an issue with virtual environment. Can you please delete the environment, and re-create it. You can follow the steps mentioned at: https://cloudxlab.com/blog/install-python-packages-cloudxlab/ to create a virtual environment and installing python packages in it. 

  Upvote    Share

Hi, I did start from scratch and followed the steps but it is still the same issue

  Upvote    Share

This comment has been removed.

https://cloudxlab.com/blog/install-python-packages-cloudxlab/  this way of creating Virtual environment helped

I am able to install flask

  Upvote    Share

I tried to deploy the app using flask. Getting the below error

  Upvote    Share

Hi Kaustubh,

What I can understand from the error is that URL is incorrect. It will be like this: http://f.cloudxlab.com:4100/

  Upvote    Share

Thanks. Problem Solved. This kind of support that you provide is the best feature of this course.

  Upvote    Share

Thanks for the appreciation Kaustubh! :)

  Upvote    Share

Please help me with this following issue

 

  Upvote    Share

Hi Vishwajeet,

You must set your identity, i.e., email and name, before committing so that git can track who has made the commit. You can use the commands that git suggested in above screenshot to set your email and name.

  Upvote    Share

Please help me with folloeing issue.

  Upvote    Share

Hi Vishwajeet,

To resolve that, you can clone the repo in the tmp directory and then move it to your home directory. You can move to the tmp directory by using:

cd /tmp

After that, clone the repo as told in the tutorial. After the repo gets cloned, move the webserver directory to your home directory by-

mv source destination

where, source is the path of the directory which you want to move, and destination is the path of the directory where you want to move the source directory.

That may do your work.

 1  Upvote    Share

This comment has been removed.

This comment has been removed.

Thanks for your help!

It worked...

  Upvote    Share

Hi I am facing the same issue. It is showing the following error message:
mv: cannot move ‘/tmp’ to ‘/Session3’: Permission denied

  Upvote    Share

Hi Kaustubh,

You cannot move the whole /tmp directory but only the files owned by you present inside the /tmp directory.

  Upvote    Share

I used the following command. I am still facing issues.
mv /tmp/webserver ~/Session3

  Upvote    Share

Problem Solved. Thanks for the help.

  Upvote    Share

This comment has been removed.

For Lab 4 in GITHUB Course
The "git push origin <feature-branch>" command prompts for credentials, Do we need to have Ashok's credentials or is there another way to proceed with this.

 

  Upvote    Share

Hi RIshab,

You can't push to someone's else repository. You can only clone/fork it if it is public. 

  Upvote    Share

 

While doing Lab03 (Git Clone), getting above message, please suggest.

  Upvote    Share

Hi Sachin,

Make sure you are entering the correct credentials when asked. I would suggest you to setup up ssh access from the command line and add it to GitHub. Then you will not need to enter username and password again and again.

You can refer to https://cloudxlab.com/assessment/displayslide/4953/github-project-getting-started-with-git-creating-ssh-keys-and-adding-to-github?course_id=116&playlist_id=435 for it.

  Upvote    Share

But it doesn't ask for authentication when cloning public repositories. You are using an incorrect URL to clone the webserver directory. The correct command is:

git clone https://github.com/singh-ashok25/webserver.git

You have replaced 'singh-ashok25' with 'singh.ashok25'.

  Upvote    Share

In Lab02, after creating Repository it doesn't shows commands (as explained by tutor). Please suggest.

  Upvote    Share

Hi Sachin,

In earlier versions of GitHub, the list of commands used to be displayed. To learn the essential commands, you can follow the video tutorial and replicate the actions of the instructor.

  Upvote    Share

I am unable to create a virtual environment using the virtualenv package on my local machine. For reference i am ran this command on a windows system (VS Code terminal) 

  Upvote    Share

What error does it shows?

  Upvote    Share

This comment has been removed.

Much helpful content!!

  Upvote    Share

This comment has been removed.

Hi,

    I am getting the below permission error, while installing Flask

[manojtechie8066@cxln4 ~]$ export PATH=/usr/local/anaconda/bin:$PATH
[manojtechie8066@cxln4 ~]$ cd Session3/
[manojtechie8066@cxln4 Session3]$ cd webserver/
[manojtechie8066@cxln4 webserver]$ pip install Flask
Collecting Flask
  Downloading https://files.pythonhosted.org/packages/f2/28/2a03252dfb9ebf377f40fba6a7841b47083260bf8bd8e737b0c6952df83f/Flask-1.1.2-py2.py3-none-any.whl (94kB)
     |????????????????????????????????| 102kB 1.2MB/s
Requirement already satisfied: Jinja2>=2.10.1 in /usr/local/anaconda/lib/python3.6/site-packages (from Flask) (2.10.1)
Requirement already satisfied: click>=5.1 in /usr/local/anaconda/lib/python3.6/site-packages (from Flask) (7.0)
Requirement already satisfied: Werkzeug>=0.15 in /usr/local/anaconda/lib/python3.6/site-packages (from Flask) (0.15.4)
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/anaconda/lib/python3.6/site-packages (from Flask) (1.1.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/anaconda/lib/python3.6/site-packages (from Jinja2>=2.10.1->Flask) (1.1.1)
Installing collected packages: Flask
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/anaconda/lib/python3.6/site-packages/flask'
Consider using the `--user` option or check the permissions.

[manojtechie8066@cxln4 webserver]$ ls
app1.py  app2.py  app3.py  app.py  docker-compose.yml  Dockerfile  README.md  requirements.txt  static  templates

Kindly suggest.

  Upvote    Share

Hi,

Please use a virtual environment if you want to install any modules on the lab. For directions in virtual environment usage, please visit https://cloudxlab.com/blog/install-python-packages-cloudxlab/

Thanks.

 1  Upvote    Share

 i am trying to push but it is giving the error

 remote: Permission to singh-ashok25/webserver.git denied to ashishsharma0286.
fatal: unable to access 'https://github.com/singh-ashok25/webserver/': The requested URL returned error: 403

  Upvote    Share

Hi,

Could you please elaborate on what you were trying to do? Please tell what exactly you wanted to do. If possible, please attach the screenshot of the issue.

Thanks.

  Upvote    Share

After chaning port to 4080 getting werkzeug.routing.BuildError

werkzeug.routing.BuildError: Could not build url for endpoint 'about'. Did you mean 'main' instead?

  Upvote    Share

This site can’t be reached

e.cloudxlab.com took too long to respond.

Trying to access http://e.cloudxlab.com:5080/ where I launched app1.py

  Upvote    Share

Hi,

Are you still facing the same issue?

Thanks.

  Upvote    Share