Navigation |
---|
🠜 go back |
git init
:: Initiates a repository
git add filename.ext
:: Stages the `filename.ext` for commit
If you use a dot . instead of the file name, all the changes will be staged
git status
:: Show the current branch status
git commit -m "message to commit"
:: makes a commit with a custom message for all the staged files
git push
:: Pushes all the commits to the [HEAD](#head) branch
git clone <repo url>
:: Clones the repository to the current folder
git clone -b [tag_name] [repository_url]
:: Clones the repository linked to the specified tag
git clone -b v1.2 https://github.com/bosko-pnap/git-project.git
:: Example
:: To download only the latest commit in the branch and reduce the download size, add the --depth 1 flag to the command.
git clone --depth 1 --branch <tag_name> <repo_url>
git branch development
:: Creates a new branch named developed
Tip: When creating a branch e.g.
git branch development
, you can publish this branch with the following command:git push --set-upstream origin development
git checkout
:: The git checkout command switches branches or restores working tree files.
It operates on files, commits, and branches. The git checkout command allows switching between multiple features in just a single repository
git checkout development -b
:: Creates a branch and directly switches to it
git marge development
:: Unifies two or more histories together
The HEAD should be pointing to the ramification who will receive the merged files. So if you want to merge the development branch into the main, you should do
git checkout main
and thengit merge development
git remote
:: List of the [remote](#remote) connections you have to other repositories
git remote -v
:: Same as the command above, but include the URL of each connection
git remote add <name> <url>
:: Create a new connection to a remote repository
git remote rm <name>
:: Remove the connection to the remote repository called <name>
git describe --tags --abbrev=0
:: Shows the current tag you're checked out
Before making commits, git might prompt a window or information that it doesn’t know who is committing the staged files. So the user must provide those data:
git config --global user.email <email>
:: This command sets a global user email
git config --global user.name <username>
:: This command sets a global username
After this, if you try to publish a repository with Vscode, an authentication window will appear so that the user can log in.
git --global editor.core <editor-here> -w
git --global editor.core "code" -w
Navigation |
---|
🠝 go top |
🠜 go back |