GitHub Basic to Advanced: Command Line Guide mesameergaikwad
Follow me Sameer Gaikwad then follow the link below! 👉 💯day challenge 📩 Reach out to me on Twitter or Linkedin, or Blogspot if you want to discuss this further. :)
Introduction:
GitHub provides a powerful command-line interface that empowers developers to interact with repositories, branches, and collaborators efficiently. Whether you’re a beginner or experienced developer, understanding basic command-line operations is essential for effectively managing your GitHub workflow. In this blog post, we’ll explore some fundamental command-line GitHub operations that will enhance your productivity and streamline your development process.
1. Initializing a Repository:
To create a new repository on GitHub using the command line, follow these steps:
git init // Initialize a new Git repository
git remote add origin <repository_url> // Link the local repository to a remote repository
Replace `<repository_url>` with the URL of the repository you want to link to. This command sets up the remote repository as the origin.
2. Checking Repository Status:
You can check the status of your local repository and view the changes made using the following command:
git status
This command displays information about modified files, untracked files, and the current branch status.
3. Adding and Committing Changes:
To add and commit changes to your repository, use the following commands:
git add <file_name> // Add specific files
git add . // Add all changes
git commit -m "Commit message" // Commit changes with a descriptive message
Replace `<file_name>` with the name of the specific file you want to add. The `git add .` command adds all changes in the current directory.
4. Pushing Changes:
To push your committed changes to the remote repository on GitHub, use the following command:
git push origin <branch_name>
Replace `<branch_name>` with the name of the branch you want to push changes to. By default, the primary branch is often named `main` or `master`.
5. Pulling Changes:
To incorporate changes made by others into your local repository, use the `git pull` command:
git pull origin <branch_name>
Replace `<branch_name>` with the name of the branch you want to pull changes from. This command fetches and merges the latest changes into your local repository.
6. Branching and Merging:
Branching allows you to work on different features or fixes in isolation. Use the following commands to create, switch, and merge branches:
git branch // List all branches
git branch <branch_name> // Create a new branch
git checkout <branch_name> // Switch to an existing branch
git merge <branch_name> // Merge changes from one branch into another
Replace `<branch_name>` with the desired name of your branch.
7. create file command
Make directory
mkdir samp
8. Remove file command
remover directory
rmdir sam
9. create and remove zip file git bash command
create zip file git bash command
touch sample.zip
Remove Zip file git Bash Command
rm sample.zip
10. create new txt file and edit
touch sample.txt
touch sample.txt
nano sample.txt
11.List Command — ls
12. Change Directory — cd
13. Clear Page — clear
14. Exit — exit
15. Git config username and email
git config — global user.name “xxxxxxxx”
git config — global user.email “xxxxxxxx@gmail.com”
git config — global user.password “xxxxxxxx”
16. project page upload GitHub repository sync code [new page upload]
git init // [local system folder location]
git add index.html // [single page upload name extension local system folder]
git commit -m “add page” // [highlights commanders page update your task]
git push // [code upload github repository]
17. project page update GitHub repository sync code [old page update]
git add index.html // [single page update name extension local system folder]
git commit -m “title page” // [highlights commanders page update your task]
git push // [code update github repository]
18. GitHub repository folder all upload file list (ls)
Conclusion:
Mastering these basic command-line GitHub operations will significantly improve your productivity and efficiency when working with repositories, branches, and collaborators. From initializing a repository to pushing and pulling changes, and managing branches, these commands are fundamental to your GitHub workflow. As you gain more experience, you’ll explore advanced command-line operations and optimize your development process. Embrace the power of the command line and make the most out of your GitHub experience. Happy coding!