/Git-basic

Basic git commands in that case if You not used git too much time

Important git commands

1. Check git version

git --version

2. Manage git config

git config

3. Get details about command

git help "command name"/ git "command name" --help /(UNIX) man git "command name"

4. Check status of files/directories

git status

5. Clone a remote repos

git clone "https://github.com/name"

6. Add track for some files

git add "file/folder/*"

7. Remove track for some files

git rm "file/folder/*"

8. Create a branch

git branch "name" / git checkout -b "name"

9. Pin changes in the branch

git commit -m "name"

10. Change the name and files of the last commit

git commit --amend -m "new name"(optional)

11. Show commit logs

git log

12. Connect to remote repos

git remote add "local-name/(origin)" "https://github.com/reposName"

13. Push changes

git push "name/(origin)" "branch/(master)"

14. Apply changes

git pull "name/(origin)" dev  ==== git fetch + git merge

15. Change current branch

git switch "branch-name"

16. Go to the last other branch

git switch -

17. Show difference with same file in other branch

git diff "other-branch" --"name.txt"

18. Show difference with same file in other branch

git diff "other-branch" --"name.txt"

19. Copy all commits from other branch

git fetch "branch-name"

20. Delete branch

git branch -d "branch-name"

21. "F??? GO BACK..." (undo all commits)

git reset --hard "branch-name(master)"

22. Apply all fetched commits (Do it after "git fetch")

git merge