Skip to content

Instantly share code, notes, and snippets.

@iLakshya
Created October 10, 2022 07:47
Show Gist options
  • Save iLakshya/5ac50e39ffe95abded7d0210bd66a517 to your computer and use it in GitHub Desktop.
Save iLakshya/5ac50e39ffe95abded7d0210bd66a517 to your computer and use it in GitHub Desktop.
GitHub Basic Commands
git init // initialise the GitHub in local repository
git remote add origin "url link" // adds your repository using the link of the repo in your GitHub
git status // checks the GitHub status (or what's the status of the branch)
git branch -m oldbranchname newbranchname // changes the old branch name to new brnach name
git status // checks the GitHub status (or what's the status of the branch)
git fetch // primary command used to download contents from a remote repository
git pull origin main // used to fetch and download content from a remote repository and immediately update the local repository to match that content
git branch --set-upstream-to=origin/main // used to set track the branch with the 'main'
git status // checks the GitHub status (or what's the status of the branch)
git push origin HEAD // pushes the current branch to the remote ref matching master in the origin repository
git checkout -b branchname origin/main // changes to the new branch and simultaneously sets the branch to track with the 'main'
git status // checks the GitHub status (or what's the status of the branch)
git add . // adds all the file but with same commit message
git add "filename" // adds the specific file (can be with same commit message)
git commit -m "commit message" // a command to capture the state of a project at that point in time
git push origin HEAD // pushes the current branch to the remote ref matching master in the origin repository
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment