Git Notes

These are a few notes I took when I needed to learn git a few months ago so I decided why not publish them here. I got my notes from this YouTube Video by Jake@Linux

Creating a new repo

Make sure you make a new folder for your project then once you cd into the directory. You can then do git init or git init project directory

Adding files to a commit

git add .

Choose what to git add

You are able to do git add ExampleFile1 Examplefile2 and that works fine but you can also git add -p which will provide you with a status

Output of the git add -p command which shows the edited changes of my robots.txt file and asks if I want to stage this hunk.

Then you can say yes or no to staging the hunk which is just asking if you want to push it to your repo.

Making a commit

git commit -m "The commit name hehehe"

Pushing it

git push [url or ssh thingy] will push your changes to the git repository.

Creating a new branch

To check all the branches in a repository do git branch

Output of the git branch command which only shows the main* branch.

Creating a new branch all you have to do is git branch TheNameofTheBranchHere

To push the branch to the repository do the command: git checkout TheNameofTheBranchHere