I’ve used git since a while now but I don’t consider myself a git expert, far from it. The following tips and tricks is a series of GIT commands that will get you out of the mess and will make you more confortable.
make « com » alias for « commit »
make « co » alias for « checkout »
make « br » alias for « branch »
make « lg » alias for « log »
make « df » alias for « diff »
make « st » alias for « status »
Get a project on remote server
Create a new branch from the master
Positioning the reference branch back to the master branch
Update the master from the original filing
Push the history of the branch on the remote branch of the same name
git push -u origin <new branch>
To change the branch with modified files
Modify a commit that you just made
When you come to a commit and it contains errors (forgotten or too wrong message files), it is possible to amend the last commit.
Change the last commit (message files)
You can also undo the last commit while keeping changes in the workspace.
Undo the last commit
Resetting the work environment
To clean all modified files. Warning, all changes are lost.
Deletes all local changes
Remove unversioned files
Make a rebase a branch from the master
Before a branch is merged, it is best to re-apply every commit branch after history master.
Position on the branch to rebase
Get the historical branches on the server
Make the rebase
Conflicts may arise. We must then deal with commit. For each conflict, after editing the file in your favorite editor:
Add conflict resolved files
git add <file1> <file2> ...
We continue the rebase
git rebase --continue
When you go to push the changes on the server, it will reject them because you change the existing historic. It is therefore necessary to force the operation.
Push the rebased branche
Create a commit on behalf of someone else.
When you apply a patch from someone else, you can give him.
Where a branch was built, it must be removed from the local repository and remote repository.
Delete the server
Install and update Submodules
git submodule update --init
Add and remove all modified / deleted files
Delete all files marked as « deleted »
Put the file chmod 644 instead of 755 before adding the files
Squash your commit before asking for merge request
git rebase -i HEAD~4
Change the last 3 commits into squash when editing files
squash 6340aaa Moving license into its own file
squash ebfd367 Jekyll has become self-aware.
squash 30e0ccb Changed the tagline in the binary, too.
Move the changes made in a dirty working directory away to work on other branches
Get the changes back when return to the branch
List all stash on a branche
Git is a very powerful tool to manipulate with precaution when working on big project with severals branches. Hope this will help ! Please share !