to ignore some files/folders and even don't display them on git status, if .gitignore is not enough, add unwanted files ref in this text file : .git/info/exclude
git status
git reflog // see any action made by user!
git log // see commits on branch
git branch -avv // see all branches
git remote -v // see remote url // -vv for more details
git should be configured to get "main" brach by default
echo "# Git-test" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:Peanuts-83/Git-test.git
git fetch // get all remote branches & history commits
git push -u origin/main // -u = --set-upstream-to=origin/main // origin = remote-repo-url // main = remote-branch
git remote add origin git@github.com:Peanuts-83/Git-test.git
git push -u origin main
git clone git@github.com:Peanuts-83/Git-test.git
git status
git add .
git commit -m 'commit message'
git push
<<<<<<< HEAD
git push origin production:master
Deleted files will be restored IF they have been previously validated in Git.
git ls-files -d | xargs git checkout
ref : https://git-scm.com/book/fr/v2/Utilitaires-Git-Sous-modules
git submodule add git@github.com:Peanuts-83/Git-test.git
git submodule add git@github.com:Peanuts-83/Git-test.git folderName // optional
git clone --recurse-submodules git@github.com:Peanuts-83/Git-test.git
git submodule update --init --recursive
Make sure parent repo knows its submodule tracks a branch
git config -f .gitmodules submodule.<path>.branch <branch>
git config -f .gitmodules submodule.front.branch production
Target right branch in your submodule folder (here my main submodule branch will follow remote production branch)
git branch -u origin/production
ref : https://stackoverflow.com/questions/1260748/how-do-i-remove-a-submodule/36593218#36593218
git submodule deinit -f <pathToSubmodule>
rm -rf .git/modules/<pathToSubmodule>
git rm -f <pathToSubmodule>
git checkout branchName fileOrDirName
git rm --cached fileName
git commit -m'fileName removed'
git push
https://learngitbranching.js.org
=======
05312000ee67288ec57624deaf70634999b5b63c
git branch branchName
git checkout branchName
// or short command
git checkout -b branchName
<<<<<<< HEAD
Originals remain the same
git cherry-pick branch1 branch2 de9a6fb // branch or commit names
Merged branch ends to merge point. Original branches remain the same. Get merged branch to new commit on active branch.
CAUTION : Deleted common files on any branch are deleted!
git checkout main
git merge branch2 // branch2 comes to main in new commit ahead last commit on main
main: A--B--C main: A--B--C--F
branch2 : \D--E branch2: \D--E/
Places HEAD branch ahead rebased branch. Original branches are changed, history rewritten... Destroys active branch to put it ahead on rebased branch.
CAUTION : Do not use on public branch used by others!
git checkout branch1
git rebase main // branch1 comes ahead main
main: A--B--C main: A--B--C--D--E
branch2 : \D--E branch2: no more
Places HEAD branch on other branch before deleting.
CAUTION : Do not use on public branch used by others!
git branch -d <branchName> // -D for delet --force
git reset // clear staging area
git reset <file> // clear file from staging area
git revert <commit-hash> // creates a new commit to undo changes made by selected commit
From commit C:
git reset --soft A // will move HEAD and branch to commit A; staging and working directory will still be at state of C.
git reset --mixed A // will move HEAD and branch to commit A, and staging; working directory will still be at state of C.
git reset --hard A // will move HEAD and branch to commit A, staging and working directory; you will go back to the state of A completely.
05312000ee67288ec57624deaf70634999b5b63c