This is just a study repository for a beginner in Git. You can check the 'Git-commands.txt' file for all the basic commands and initial setup.
-
Install git/git-bash
-
Create project directory - We can create files directly inside the repository if we want. Eg: touch index.html, touch app.js, touch .gitignore, touch README.md
-
The files or directories added in the .gitignore file will not get tracked
-
git init (This will add a hidden .git folder inside directory)
- git config --global user.name 'Sudhil'
- git config --global user.email 'email@gamil.com'
- Run anytime if we want to know the status of the git tree
- Add all the modified files
- This will only the index.html file
- Untrack the tracked file
- Commit the staged changes after adding files with a message
- To view all the previous commits
- Create a new branch with branch-name
- To switch between branches
- This will create a new branch switch to it together
- This will merge the changes made in one branch to another. For eg. if we are in master branch and run the above command, the branch-name will gets merged to master branch
- Create a repo in GitHub - (Add name and description)
- This will help us to link our local repository to a remote repository in GitHub
- Make sure the root branch name is same in both local and remote (Eg:master or main), Otherwise rename it.
- This will push the master branch from local repository to remote repository in GitHub
- We can add directly from GitHub or we can add in local and then push
- Pull/Retrieve the latest changes added in the remote repository to local repository(Eg: To get changes from an other developer)
- This is same as pulling but merge our local master along with the remote master while pulling
- git clone repo-url
Once you are familiar with all these basic commands, you can use GUI or the awesome extensions in the IDE (Eg: Extensions like Git History, Git Blame, Git Lens, etc in VS code)