🛠 Cheatsheet will rock you: GitSCM
Salute,
Today I want to share with you some cheatsheet on gitscm, it will help you understand the topic and start committing, resolving conflicts with version history when developing software.
Base
$ git init # Initialize an empty local repository
$ git remote add origin URL_link # Linking a remote repository with the name "origin" via the link "URL_link" to the local one
$ git pull origin name_branch # Branch from which we take changes for testing
$ git remote show # Show connected remote repositories
$ git status # Shows the status of the local repository (tracked, changed, new files, etc.)
$git add. # Add to the index all new, changed, deleted files from the current directory and its subdirectories
$ git commit -S -m"added sources" # Commit the indexed changes (commit), add a message
$ git push origin name_branch # Push changes from the local repository to the remote repository in the "name_branch" branch
$ git show HEAD # Information about the latest commit (git log -1)
$ git push --set-upstream origin new-name # Set upstream (links local branch to remote branch)
$ git push origin :old-name # Deleting the old branch in the remote repo
$ git push origin new-name # Publish a new branch
$ git log --oneline --graph --decorate --all
$ tree -I "katalog|katalog" # Output excluding directories for the project tree
Working with index
$ git init # Initialize an empty local repository
$ git remote add origin URL_link # Linking a remote repository with the name "origin" via the link "URL_link" to the local one
$ git pull origin name_branch # Branch from which we take changes for testing
$ git remote show # Show connected remote repositories
$ git status # Shows the status of the local repository (tracked, changed, new files, etc.)
$git add. # Add to the index all new, changed, deleted files from the current directory and its subdirectories
$ git commit -S -m"added sources" # Commit the indexed changes (commit), add a message
$ git push origin name_branch # Push changes from the local repository to the remote repository in the "name_branch" branch
$ git show HEAD # Information about the latest commit (git log -1)
$ git push --set-upstream origin new-name # Set upstream (links local branch to remote branch)
$ git push origin :old-name # Deleting the old branch in the remote repo
$ git push origin new-name # Publish a new branch
$ git log --oneline --graph --decorate --all
$ tree -I "katalog|katalog" # Output excluding directories for the project tree
Conflicts you will definitely face
$ git remote set-url origin ssh://git@github.com_gitlab.com/username/newRepoName.git # URL replacement
$ git remote -v # Verify that the specified link is correct
$ git remote set-head origin -a
$ git pull --rebase origin name_branch # Reinitialize
$ git reset HEAD file # Removes a file from the index
$ git reset HEAD~ # Undo last commit
$ git reset --hard HEAD~ # Removing commit with changes
$ git push origin --delete name_branch / git branch -rD origin/name_branch
$ git branch -d name_branch # Delete local repo
$ git checkout -- file # Undoes a change
$ git clean -fdn # Removes untracked files and directories with preview
# Installing a new master/main branch
$git fetch origin
$ git fetch origin # Hard repository rewrite
$ git branch -u origin/gpages gpages
$ git branch -m master gpages
In summary: tips and edited materials from the experience of colleagues, teachers and people around you can help you grow, that is, find your growth zones and move forward. Swing, it will help 🙏
#toolchain #appsec #specialty #pmcases #paper
