Learning How to use git

  Learning How to use git


1. Configuring credentials

  • git config --global user.name "The name" //sets the default name
  • git config --global user.email "The email" //sets the default email address





2. Creating a repositiory



After starting the repository , you will be redirected to a page where further instructions are given.



  • echo "*text*" >>  README.md  //creates a README text file


  • git init // initializes  repository


By default 'master' is used for the name of the initial branch. The name will be changed later


  • git status //shows which files are being tracked
Using git status we can view what files are being tracked.



  • git add // add files to be tracked
Using the git add command i add the labsheets and README.md file to be tracked




  • git commit -m "message" //creates a commit with the message



  • git branch -M *name* //  Renames initial branch to the name
Using the command i rename the initial branch to main


  • git remote add origin main //pushes local commit to remote repository


** We will need to create a token to be used as a password 






A repository should now have been created.

3. Downloading and modifying a repository


1. We will need to fork the repository and copy the URL of the forked repository




  • git clone *url* // downloads a clone of the repository



  • cd *repository location*// Changes to the repository directory on the computer.
  • git switch -c *new-branch-name* //Creates a new branch with the specified name.


  •  git status // shows changes made to the repository
After modifying the files , we can use git status to view the changes

  • git add *file name* //Adds the changes to the branch created
We use the git add command to add the modified README.md file



  • git commit -m "message" // Commit the changes 

  • git push -u origin *branch name* // Pushes the changes



Comments

Popular posts from this blog

Learning about Post Quantum cryptography (PQC)

Learning how to use commands on ubuntu